Repository navigation
Request: Compiler option to specify an alternate lib.d.ts #494
Description
Activity
compiler option to specify a .d.ts file or files to automatically include before compiling each .ts file. Such an option would make it much easier to use an alternate lib.d.ts.
👍
I believe there is a larger issue here than simply including an alternate
lib.d.ts. If we have a mechanism for specifying a directory then it should be possible to add the shared declarations there, for example,node.d.tsetc.This would also solve the problem Split official "lib.t.ts" into different files / Special references clauses
We have a requirement to reduce the number of global variables (properties on window) such as
name,length,locationetc, because it causes errors to slip through (e.g. renaming a local variable callednamewill fail to highlight occurrences).Noel Abrahams (@NoelAbrahams) I've been bitten by
item:) (not badly though)Basarat Ali Syed (@basarat), that's an interesting one. It's quite a significant problem. In the old codeplex site it was common for people new to TypeScript to file bugs because they couldn't understand why code like the snippet below would compile;
var fullName: string; name = 'John Smith';
Noel Abrahams (@NoelAbrahams) the idea of splitting lib.d.ts is that node.d.ts would take dependency on lib.core.d.ts and not the normal lib, then when you reference node.d.ts you do not get any dom types as you would expect.
For this issue, we need two things:
- a command line switch to allow you to specify a specific lib
- some notion of search paths, so that when you add /// it knows you mean the one in the folder next to the compiler.
- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptand removedBugA bug in TypeScriptA bug in TypeScript
on Apr 21, 2015 - addedIn DiscussionNot yet reached consensusNot yet reached consensus
on Dec 9, 2015 this should be covered by the proposal in #6974
- addedDuplicateAn existing issue was already createdAn existing issue was already createdand removedIn DiscussionNot yet reached consensusNot yet reached consensus
on Feb 20, 2016 - locked and limited conversation to collaborators
on Jun 18, 2018
The compiler has an option noLib which disables the default inclusion of lib.d.ts during compilation. Unfortunately there is no compiler option to specify a .d.ts file or files to automatically include before compiling each .ts file. Such an option would make it much easier to use an alternate lib.d.ts.
The work around now is to use the noLib option and then to add a line to each source file to manually pull in your alternate lib.d.ts.