Repository navigation
Can't disable type definitions for one special library #17042
Description
Activity
I hit a similar problem with the new weak type checking:
#16968The more strict checks are fine for code you have control over, but for third party libs it is a problem. Even if the author updates, the newer version may have breaking changes.
Theoretically each third party dependency should be compiled using the compiler version specified by it, however this is impractical. A way to disable these type checks on a per library basis may be more realistic.
screendriver commented
on Jul 10, 2017 AuthorMore actionsThe best solution would be the opposite of
"types"in the compiler options in the compiler options.typesis exactly what I want but in the other direction: I want to exclude some type definitions.Reacted by Jonathan RaoultHave you tried
excludein yourtsconfig.json?screendriver commented
on Jul 10, 2017 AuthorMore actionsexcludedoes not work for type definitions. For example:exclude: ["node_modules"]still contains all type definitions of all installed dependencies.- marked this as a duplicate of Suggestion: add config excludeTypes #17242
on Jul 17, 2017 This option would be awesome to avoid transitive definition files to "pollute" the "ambient" space. My case, for example, I want
react-modaltypes but not thereactit imports.RyanCavanaugh commented
on Jul 25, 2017 MemberMore actionsHave you tried path mapping (https://www.typescriptlang.org/docs/handbook/module-resolution.html) to map that path to a non-existant one?
Reacted by Aluan HaddadThanks Ryan Cavanaugh (@RyanCavanaugh) it worked indeed, nice workaround. Small gotcha, I had to make sure the file actually existed (I first tried with a fake file name)
- addedQuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
on Aug 21, 2017 Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Hi, Jonathan Raoult (@jraoult) .
Can you share yourtsconfig.json?I tried this but failed:
"paths": { "node_modules/@types/node" : ["NOT_EXISTS"], "@types/node" : ["NOT_EXISTS"], "node" : ["NOT_EXISTS"] }Hi Ryan Cavanaugh (@RyanCavanaugh) ,
I tried this , but it seems cannot disable those global declaration.
Such as@type/nodeZhongyang Wang (@k8w) sure thing
"paths": { "react": [ ".sink.d.ts" ], "inferno-mobx": [ ".sink.d.ts" ] }So as I mentioned earlier you actually need the file (.sink.d.ts in this case) to exist.
Jonathan Raoult (@jraoult) Ryan Cavanaugh (@RyanCavanaugh)
Well, sopathscan disable a specific type, but it seems cannot do that to global declaration.
Like@types/node...for global declarations set
"types" : []this will not load any packages from@types. you can add ones you want e.g."types": ["node"]Mohamed Hegazy (@mhegazy)
Should I add all types one by one only for excluding specific one?
Maybe better if it is likeincludeandexclude?screendriver commented
on Sep 12, 2017 AuthorMore actionsfor global declarations set "types" : [] this will not load any packages from Types (@types). you can add ones you want e.g. "types": ["node"]
Mohamed Hegazy (@mhegazy) but that's not what I want as I said before.
Reacted by Zhongyang Wang- locked and limited conversation to collaborators
on Jun 14, 2018
TypeScript Version: 2.4.1
For example I want to consume a library from npm called
awesome-lib. This library already ships with a TypeScript type definition but this one is outdated and buggy. The author of the library doesn't update this one.I've tried to disable that type definition completely in my own
declarations.d.tsfile in my project:Unfortunately TypeScript reads first the type definition in the library and throws some errors. So it is not possible for me to disable / hide this library for my project.