Matt Matt - 16 days ago 7
TypeScript Question

Typescript is giving error TS2411 on it's own Typescript module?

I've switched to using @types (as one should in Typescript 2.0). So I ran

npm i -S typescript @types/typescript
to get
typescript
running all hunky dory.

However, now when I run
tsc
on my own project with
"exclude": ["node_modules"]
, I get the following error about 20 times (for different lines of the file).

node_modules/@types/typescript/index.d.ts(1306,9): error TS2411: Property
'allowNonTsExtensions' of type 'boolean | undefined' is not assignable to
string index type 'string | number | boolean'.


My code still runs fine, but it's forcing me to check whether or not the transpiling is actually wrong, or it's just these errors. Is there a way to prevent this "error" from occuring?

*edit - The more I think about it, do I even need
typescript
in my
node_modules
? Should it just be a global install?

Answer

1) Don't install @types/typescript. The typescript module contains everything it needs. Type definition files are already included in typescript/lib folder.

2) You should definitely have typescript installed globally, but if you want to share your project (e.g. on GitHub), you should install it also locally. People won't have problems about missing dependancies or version mismatches.