awesome-typescript-loader
awesome-typescript-loader copied to clipboard
Awesome typescript loader not respecting "exclude" property for type checking
I tried every combination I can think of any awesome typescript loader will not respect the exclude property in tsconfig.json
"exclude": [
"compiled",
],
"exclude": [
"compiled/*",
],
"exclude": [
"**/compiled/*",
],
Full config
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es6"
],
"moduleResolution": "node",
"noStrictGenericChecks": true,
"outDir": "lib",
"paths": {},
"pretty": true,
"sourceMap": true,
"sourceRoot": ".",
"strictNullChecks": false,
"target": "es5",
"typeRoots": [
"./node_modules/@types"
],
"types": [
"core-js",
"hammerjs",
"lodash",
"materialize-css",
"node",
"jasmine",
"source-map",
"uglify-js",
"webpack"
]
},
"exclude": [
"./node_modules",
"./compiled",
"./wwwroot",
"../backend-nodejs",
"./src/**/*.e2e.ts",
"./src/**/*.spec.ts",
"./config/protractor.config.ts"
],
"filesGlob": [
"src/**/*.ts",
"src/custom-typings.d.ts",
"src/types/require.d.ts"
],
"atom": {
"rewriteTsconfig": false
},
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"resolveGlobs": true,
"useCache": false
},
"buildOnSave": false,
"compileOnSave": false
}
It still checks the compiled folder for type errors, even though this folder is not referenced in my current webpack build. What is the proper way to exclude a folder from type checking?
Is this repo still being maintained? lots of unanswered issues and no commit for 6 weeks. Just wondering if I should switch to ts-loader, last commit 22 hours ago.
In my case it's not ignoring node_modules :(
That gives me
[at-loader] Checking started in a separate process...
[at-loader] Checking finished with 11 errors
[at-loader] ./node_modules/@angular/cdk/table/typings/table.d.ts:38:22
TS2420: Class 'CdkTable<T>' incorrectly implements interface 'CollectionViewer'.
Types of property 'viewChange' are incompatible.
Type 'BehaviorSubject<{ start: number; end: number; }>' is not assignable to type 'Observable<{ start: number; end: number; }>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<{ start: number; end: number; }, R>) => Observable<{ start: number; end: n...' is not assignable to type '<R>(operator: Operator<{ start: number; end: number; }, R>) => Observable<R>'.
Type 'Observable<{ start: number; end: number; }>' is not assignable to type 'Observable<R>'.
Type '{ start: number; end: number; }' is not assignable to type 'R'.
[at-loader] ./node_modules/@angular/material/chips/typings/chip-list.d.ts:27:22
TS2420: Class 'MdChipList' incorrectly implements interface 'MdFormFieldControl<any>'.
Types of property 'stateChanges' are incompatible.
Type 'Subject<void>' is not assignable to type 'Observable<void>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<void, R>) => Observable<void>' is not assignable to type '<R>(operator: Operator<void, R>) => Observable<R>'.
Type 'Observable<void>' is not assignable to type 'Observable<R>'.
Type 'void' is not assignable to type 'R'.
[at-loader] ./node_modules/@angular/material/input/typings/input.d.ts:15:22
TS2420: Class 'MdInput' incorrectly implements interface 'MdFormFieldControl<any>'.
Types of property 'stateChanges' are incompatible.
Type 'Subject<void>' is not assignable to type 'Observable<void>'.
[at-loader] ./node_modules/rxjs/Subject.d.ts:16:22
TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
Type 'Observable<T>' is not assignable to type 'Observable<R>'.
Type 'T' is not assignable to type 'R'.
@naivefun post your entire .tsconfig file for review
I observed this issue, too. I'd like to use "exclude" in my .tsconfig.
My project is still fairly small, so I managed to work around the issue with an "include" configuration instead:
{
...
"include": [
"./src/**/*"
],
"awesomeTypescriptLoaderOptions": {
"reportFiles": [
"./src/**/*"
]
}
}
This tells at-loader to only nag about errors in the listed files/directories
(src is where I keep all my Javascript and Typescript sources).
I'm seeing the same issue, although it's flakey. It appears to only occur when at-loader chooses to fork the compiler to do type-checking in a separate process.
Please use reportFiles option
@s-panferov So exclude does not work? Please example reportFiles
I'm seeing the same issue!
@IAMtheIAM From looking at the README, it seems you can edit the loader options in your webpack config to only emit TS errors for the files that match a glob. Something like this:
rules: [{
test : /\.ts$/,
use : {
loader : 'awesome-typescript-loader',
options : {
reportFiles: [
'src/**/*.{ts,tsx}'
]
},
},
}]
This results in no change to the actual behaviour you expect from the loader and webpack, but squelches the TypeScript checker errors for anything outside src/.
Of course, if your node_modules is in src/ this gets trickier. Globs for excluding a directory are not so pretty:
'{,!(node_modules)/}**/*.{ts,tsx}'
That second one is untested, but I think it should work.
(I know I'm replying to a comment that's almost a year old, but this thread was top of the Google results when I was trying to solve the same problem, so I'm providing the example for those who come later)
@IAMtheIAM From looking at the README, it seems you can edit the loader options in your webpack config to only emit TS errors for the files that match a glob. Something like this:
rules: [{ test : /\.ts$/, use : { loader : 'awesome-typescript-loader', options : { reportFiles: [ 'src/**/*.{ts,tsx}' ] }, }, }]This results in no change to the actual behaviour you expect from the loader and webpack, but squelches the TypeScript checker errors for anything outside
src/.Of course, if your
node_modulesis insrc/this gets trickier. Globs for excluding a directory are not so pretty:
'{,!(node_modules)/}**/*.{ts,tsx}'That second one is untested, but I think it should work.
(I know I'm replying to a comment that's almost a year old, but this thread was top of the Google results when I was trying to solve the same problem, so I'm providing the example for those who come later)
Thank you so much!And do you know why the tsconfig.json file doesn't work ? thanks again!
@Enzo1994 Not a clue! I've got nothing to do with at-loader, I'm just a user of it, like you.
I would think, though, that you could put the reportFiles option in your tsconfig.json (in awesomeTypescriptLoaderOptions) instead of inside your webpack config, and it would work the same. You're supposed to be able to do that for all loader options. See the code snippet in kreba's comment above.