nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

error TS7019: Rest parameter 'args' implicitly has an 'any[]' type #299

Closed alexander-ossur closed 6 years ago

alexander-ossur commented 6 years ago

I'm submitting a...


[ ] Regression 
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Webpack + NestJS with help of ts-loader compiles with error

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\execution-context.interface.d.ts
(3,15): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\websockets\gateway-metadata-explorer.d.ts
(13,16): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\web-socket-adapter.interface.d.ts
(6,47): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\web-socket-adapter.interface.d.ts
(7,51): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\web-socket-adapter.interface.d.ts
(8,85): error TS7006: Parameter 'data' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\web-socket-adapter.interface.d.ts
(9,47): error TS7006: Parameter 'socket' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\web-socket-adapter.interface.d.ts
(9,55): error TS7006: Parameter 'next' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\pipe-transform.interface.d.ts
(5,21): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\custom-route-param-factory.interface.d.ts
(1,43): error TS7006: Parameter 'data' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\common\interfaces\custom-route-param-factory.interface.d.ts
(1,49): error TS7006: Parameter 'req' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\core\injector\module.d.ts
(14,18): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\client\client-proxy.d.ts
(4,63): error TS7006: Parameter 'err' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\client\client-proxy.d.ts
(4,68): error TS7006: Parameter 'result' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\client\client-proxy.d.ts
(6,58): error TS7006: Parameter 'err' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\client\client-proxy.d.ts
(6,63): error TS7006: Parameter 'result' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\interfaces\message-handlers.interface.d.ts
(3,25): error TS7006: Parameter 'data' implicitly has an 'any' type.

ERROR in c:\Workspace\market\node_modules\@nestjs\microservices\server\server.d.ts
(15,34): error TS7006: Parameter 'data' implicitly has an 'any' type.

Once tsconfig.json is set to noImplicitAny: false it will compile just fine.

Expected behavior

It should not allow implicit "any" and compile with noImplicitAny: true without errors

Minimal reproduction of the problem with instructions

tsconfig.json


{
    "compilerOptions": {
        "inlineSourceMap": true,
        "inlineSources": true,

        "target": "ES6",
        "allowSyntheticDefaultImports": true,

        "module": "commonjs",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,

        "noImplicitAny": true,
        "strictNullChecks": true
    }
}

webpack.config.js


var path = require ("path");
var webpack = require ("webpack");

module.exports = [{
    name: "server",
    target: "node",
    devtool: "inline-source-map",

    entry: {
        "server": "./src/server/server.ts"
    },

    output: {
        filename: "[name].js",
        path: path.resolve (__dirname, "dist/server")
    },
    resolve: {
        // Add `.ts` and `.tsx` as a resolvable extension.
        // '.ts', '.tsx', '.js', 'json', '.jsx'
        extensions: [".ts", ".tsx", '.js']
    },
    module: {
        rules: [
            // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
            { test: /\.tsx?$/, loader: "ts-loader" }
        ]
    },
    plugins: [
        // Enables Scope Hoisting
        // https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b
        new webpack.optimize.ModuleConcatenationPlugin ()
    ]
}];

What is the motivation / use case for changing the behavior?

Environment


Nest version: 4.4.2


For Tooling issues:
- Node version: v8.1.2  
- Platform:  Windows

Others:

"ts-loader": "^2.2.2",
"typescript": "^2.4.1",
"webpack": "^3.10.0",
"@nestjs/common": "^4.4.2",
"@nestjs/core": "^4.4.2",
"@nestjs/microservices": "^4.4.1",
"@nestjs/testing": "^4.4.1",
"@nestjs/websockets": "^4.4.1",
wbhob commented 6 years ago

remove noImplicitAny. This functionality is not currently available.

wbhob commented 6 years ago

or you can set skipLibCheck to true in tsconfig.

alexander-ossur commented 6 years ago

Thank you @wbhob,

skipLibCheck also did the trick. I think we will just put this into webpack.config.js, as long as our setup is complex (wallaby, mocha, and ton of others), and we want to be strict with our code as much as possible.

Meanwhile, is there any reason you won't plan to fix this? AFAIK it's pretty easy: function (args: any []): any

wbhob commented 6 years ago

We may fix this in the next minor. @kamilmysliwiec if I PR can I get an express review and merge?

kamilmysliwiec commented 6 years ago

Hi @alexander-ossur, Thanks for reporting. @wbhob sure, feel free to create a PR 🙂

wbhob commented 6 years ago

PR openned. Tests passing

wbhob commented 6 years ago

@alexander-ossur it is very easy in concept, but all the internal code has to be refactored as well. I had to manually decide what type pretty much everything was in 170 different files.

alexander-ossur commented 6 years ago

Thank you guys. @wbhob Yes now, by seeing the changes made, I understand. Anyway thank you for your awesome work!

wbhob commented 6 years ago

My pleasure!

wbhob commented 6 years ago

Nest supports noImplicitAny now, as far as I know. This issue can be closed @kamilmysliwiec

robertmain commented 6 years ago

I'm getting this error message after following the instructions here and running $ git clone https://github.com/nestjs/typescript-starter.git project like it says

wbhob commented 6 years ago

that repo is out of date. please use the cli or upgrade to nest v5

robertmain commented 6 years ago

Ah ok. Thanks

wbhob commented 6 years ago

@kamilmysliwiec do you want me to update the ts- and js-starter repos?

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.