s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 181 forks source link

Loader breaks build - non-existant errors are reported at invalid places (tsc alone compiles project just fine) #262

Open mnn opened 7 years ago

mnn commented 7 years ago

(I am total newbie concerning TypeScript and Webpack. I already asked at TypeScript and they pointed out that TS compiler is working well and it must be something at higher layers which breaks error reporting/build.)

Running TS compiler alone works fine (./node_modules/.bin/tsc -p . --pretty --outDir out reports 4 valid errors, explained bellow), but when run via webpack mysterious errors appear.

Here is a repro:

Please note there is a few errors which are valid (those in app.module.ts). 19 of 22 reported errors are invalid, reported in non-existing places. (Error in api.service.spec.ts reported by tsc is not printed, probably because only used files for build are compiled?)

Example (the path is in my source, not in some library):

[default] /xxx/src/main.ts:11:96
    Index signature of object type implicitly has an 'any' type.
...
[default] /xxx/src/main.ts:11:853
    Parameter 'store' implicitly has an 'any' type.

My main.ts:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

// depending on the env mode, enable prod mode or add debugging modules
if (process.env.ENV === 'build') {
  enableProdMode();
}

export function main() {
  return platformBrowserDynamic().bootstrapModule(AppModule);
}

if (document.readyState === 'complete') {
  main();
} else {
  document.addEventListener('DOMContentLoaded', main);
}

It sure looks like those are type errors in libraries, which is very odd because of "skipLibCheck": true. Also if it is already concatenated in one source, why it is not ES5 as config specifies? I am really confused by all this.

mnn commented 7 years ago

Still broken.

Now tested with these versions:

├── awesome-typescript-loader@3.0.0-beta.17 
└── typescript@2.1.4 
mnn commented 7 years ago

Problem persists. Tested with newest versions:

├── awesome-typescript-loader@3.0.4 
├── typescript@2.1.6 
└── webpack@2.2.1 
mnn commented 7 years ago

Still broken. :disappointed: All packages in test repo updated to current version just now.

mnn commented 7 years ago

Aaand ... still broken. Updated all packages just now. Versions:

├── awesome-typescript-loader@3.2.3
├── typescript@2.4.2
├── webpack@3.5.5
mnn commented 6 years ago

Issue still persists with updated packages. test repo: https://github.com/mnn/angular2-webpack/

├── awesome-typescript-loader@3.4.1
├── typescript@2.6.2
├── webpack@3.10.0