-
Notifications
You must be signed in to change notification settings - Fork 179
Loader does not use @types definitions #244
Comments
A workaround is to add |
Adding a "compilerOptions": {
"types": ["requirejs", "mocha", "jquery"],
...
} |
Sure, that is an alternative solution instead of the |
It also uses @types/* packages and is an official typescript option (see https://www.typescriptlang.org/docs/handbook/compiler-options.html --types). Yes |
i ran into the same issue, and strangely, adding |
@WuTheFWasThat According documentation it shouldn't work in this case:
|
Relevant handbook section: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types
|
@IRus but it did work ¯_(ツ)_/¯ Also, from the docs you reference
I think perhaps we're not discussing the same situation, but it sounds like this is why it works for me. All my @types packages are in node_modules/@types and are module declarations. Hopefully my comment could be helpful for others in a similar boat, since it was the only way I could figure out to get things working. At any rate, it's unfortunate that tsc would work but not awesome-typescript-loader! |
@WuTheFWasThat If you specify |
yes - tsc works with |
actually, please disregard my messages. I was mistaken about |
So is it just After a lot of head-banging this seems to be a probably with the typescript definition for |
|
I'm really stuck with this issue. While the workaround seems to be to specify an empty types array in tsconfig.json, this causes other compilation issues for me in particular for my unit tests where mocha,sinon,chai functions are globals. I've got it almost working but I just can't seem to get it to pull in the type information for angular when there is an import statement for angular, like: I've also tried specifically adding the @types path to the tsconfig and that does not help either.
The following shows my tsconfig.json, webpack config and output from both tsc and webpack. tsc works just fine, I get an output bundle from webpack, but the checker reports errors. In the listing below ignore the tsc errors. They are involved in the generation of the declarations folder specified in the tsconfig and are unrelated to the atl errors.
|
Any occurence of import * as angular from '@types/angular'; is a bug and will cause a runtime error if angular.module('app', []); in the importing module.
This means that if you $ npm install angular
$ npm install @types/angular then your code needs to always use For each of those errors, you must change More generally, never import anything from |
With Typescript 2.0 you shouldn't have to declare all your typings explicitly, but you can simply ensure that npm installs type packages into the scoped package
@types
(see microsoft/TypeScript#9184).Currently it doesn't seem like ATL respects this, as it fails with missing typings where
tsc
works. Examples of such scoped packages are@types/requirejs
,@types/mocha
,@types/jquery
etc.The text was updated successfully, but these errors were encountered: