Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS7006: Parameter 'req' implicitly has an 'any' type #2497

Closed
hdorgeval opened this issue Jun 7, 2018 · 3 comments
Closed

error TS7006: Parameter 'req' implicitly has an 'any' type #2497

hdorgeval opened this issue Jun 7, 2018 · 3 comments
Assignees
Labels
AREA: TypeScript definitions STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@hdorgeval
Copy link

hdorgeval commented Jun 7, 2018

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

In TypeScript project, tsc will produce the following errors (due to the "noImplicitAny": true in the tsc configuration file):

node_modules/testcafe/ts-defs/index.d.ts(921,54): error TS7006: Parameter 'req' implicitly has an 'any' type.
node_modules/testcafe/ts-defs/index.d.ts(921,59): error TS7006: Parameter 'res' implicitly has an 'any' type.
node_modules/testcafe/ts-defs/index.d.ts(928,40): error TS7006: Parameter 'req' implicitly has an 'any' type.
node_modules/testcafe/ts-defs/index.d.ts(928,45): error TS7006: Parameter 'res' implicitly has an 'any' type.
node_modules/testcafe/ts-defs/index.d.ts(1573,73): error TS7006: Parameter 'req' implicitly has an 'any' type.
node_modules/testcafe/ts-defs/index.d.ts(1573,78): error TS7006: Parameter 'res' implicitly has an 'any' type.

tsc runs well after doing the following modifications:

interface RequestMock {
    /**
     * Specifies requests to intercept
     * @param filter - Specifies which requests should be mocked with a response that follows in the `respond` method.
     */
    onRequestTo(filter: string | RegExp | object | ((req: any, res: any) => boolean)): RequestMock;
    /**
     * Specifies the mocked response.
     * @param body - The mocked response body.
     * @param statusCode - The response status code.
     * @param headers - Custom headers added to the response in the property-value form.
     */
    respond(body?: object | string | ((req: any, res: any) => any), statusCode?: number, headers?: object): RequestMock;
}

export function RequestLogger(filter?: string | RegExp | object | ((req: any, res: any) => boolean), options?: RequestLoggerOptions): RequestLogger;

What is the expected behavior?

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

Specify your

  • operating system: Windows 10
  • testcafe version: 0.20.3
  • node.js version: v10.1.0
  • typescript: 2.6.1
  • tsconfig.json
    /* Strict Type-Checking Options */
    "strict": true,                   
    "noImplicitAny": true,            
    "strictNullChecks": true,         
    "strictFunctionTypes": true,      
    "noImplicitThis": true,           
    "alwaysStrict": true,             
@AndreyBelym AndreyBelym added TYPE: bug The described behavior is considered as wrong (bug). AREA: TypeScript definitions labels Jun 7, 2018
@AndreyBelym AndreyBelym added this to the Planned milestone Jun 7, 2018
@AndreyBelym
Copy link
Contributor

Hi @hdorgeval, thanks for sharing this issue! I think that TestCafe definitions must pass the strictest typechecks, so it's a bug. I will fix definitons and write a test. Right now you have to add "skipLibCheck": true to your tsconfig.json to keep strict typechecking for your code, and disabling them for TestCafe definitions.

@hdorgeval
Copy link
Author

Hi @AndreyBelym, thank you for your answer. It's always a pleasure to learn something new from people like you. Now, thank's to you, I fully understand the purpose of the skipLibCheck toggle.

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
 DevExpress#2497,DevExpress#2457) (DevExpress#2561)

* enable `noImplicitAny` and disable `skipLibCheck` in TS compiler (closes DevExpress#2497,DevExpress#2457)

* add separate test to --noImplicitAny

* change --implicitAny to --strict

* remove unrequired test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: TypeScript definitions STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants