I would like to know, if is there some option, how to exclude node_modules packages from TSC command.
I'm using Typescript v3.5.3. My tsconfig.json is
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es2018", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "preserve",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"typeRoots": ["node_modules/@types"]
},
"exclude": [
"build",
"config",
"node_modules"
],
"include": [
"src"
]
}
And an angular script like this
import { Component } from "@angular/core";
@Component({
selector: "app-home",
styleUrls: ["./home.component.less"],
templateUrl: "./home.component.html"
})
export class HomeComponent {
title = "angular home";
constructor(){
this.log(123);
this.log('hello world');
}
log(someArg) {
console.log(someArg);
}
}
Now i'm expecting error if i will run TSC, because function log is with implicit any type. In this case is everything ok! But if i will use this code
import { Node } from "@alfresco/js-api";
import { Component } from "@angular/core";
@Component({
selector: "app-home",
styleUrls: ["./home.component.less"],
templateUrl: "./home.component.html"
})
export class HomeComponent {
title = "angular home";
selectedNode: Node;
constructor(){
this.log(123);
this.log('hello world');
}
log(someArg) {
console.log(someArg);
}
}
I will get errors from package from node_modules like
node_modules/@alfresco/js-api/src/authentication/processAuth.ts:181:9 - error TS2322: Type 'null' is not assignable to type 'string | undefined'.
181 this.authentications.basicAuth.username = null; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I know why, beacuse "noImplicitAny" is set to true, but what i want is, to ignore node_modules packages! Therefore in Angular exclude option from tsconfig mean nothing. I think, that with build is package @alfresco/js-api included to script and checked as one.
Interesting thing is, if i will use similar code in React.js, everything is as i excpect. Is there some option or something, when i use command "TSC" with "noImplicitAny" = true and node_modules packages will be ignored? Thanks a lot!
node_modules/@alfresco
toexclude
array incompilerOptions
won't work? – Andrei Gătej