You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have following settings that play together:
CompilerOptions.lib - Specifies the list of library files to include, if unspecified default lib.d.ts (or specific to target like lib.esnext.full.d.ts) file is included
CompilerOptions.noLib - we do not include any lib files (specified by CompilerOptions.lib or specific to target or lib.d.ts) or process lib reference directives.
This is like noResolve but for libReference directives and including default lib files.
On a side note, with noResolve we do not process reference and type reference directives, we do module resolution and then ignore it. Probably should stop doing module resolution as well
/// <reference no-default-lib="true"/> directive in the file
This means this file is treated as default library file and will skip typechecking with CompilerOptions.skipDefaultLibCheck and some other implications like not emitting this file etc.
Currently this also means if any of the root files, reference or type reference directive or module resolution file if has this set, we will not include default library (either specified by CompilerOptions.lib or specific to target or lib.d.ts) file because we will treat this file encountered as default library. But if file was included for the first time through library reference directive (/// <reference lib="webworker") in any of the other files included in the program, we will not skip including default lib files (either specified by CompilerOptions.lib or specific to target or lib.d.ts)
We also use this sometimes to determine if we should skip reporting error like type came from elaboration. (We do not check if the file is js or ts or declation so thats another issue)
These options together seem to be intended to solve following use cases:
User wants to include default library file - does not set CompilerOptions.lib and relies on target to include target specific or lib.d.ts
User wants to include specific libraries so specifies CompilerOptions.lib. Looks like this should always be honoured
CompilerOptions.noLib - do not include any lib files (event if CompilerOptions.lib was specified), do not process lib reference directives, user is in charge of include lib file paths in the config as part of include.
Include their own file as default library- so stop processing CompilerOptions.lib - can set this as [] in the config instead if thats the intention (because the default library will conflict with the one user has marked). Currently marking file as no-default-lib
Why would user want to mark file as default library - skip typechecking - may be not a good idea if its user specified file.
-But then how do we mark typescript default library - ones processed through CompilerOptions.lib or default library or through lib reference directive.
Current problem is that js files are marked as default lib and will skip typechecking if CompilerOptions.skipDefaultLibCheck is specified Current problem is that many times user dont know why they arent getting library files, and one of their ts or js file has this (eg Fix incorrect condition of noLibΒ #58867 fixed issue where js file was including this. We ignore treating js files as ).
With noLib how do we mark typescript files as default libs if user specifies them on root. noLib seems to be used mainly for transpilation so no error reporting so doesnt matter if they are marked as "default lib"?
So it seems like no-default-lib predates CompilerOptions.lib so it was designed such that if we encountered this we would not include default library file as it might contradict with what user wants to include. But now that we have CompilerOptions.lib, it should not mean skip including default library file, whether CompilerOptions.lib was specified or not. Currently it seems like this option can be deprecated.
π Motivating Example
#57524 - reports lib files are not included because one of the file has this flag on - why should it be on? #58867 in the repro one of the js file had /// <reference no-default-lib="true"/>, seems totally accidental
π» Use Cases
What do you want to use this for?
Simplifying lib options and avoiding surprises.
What shortcomings exist with current approaches? no-default-lib was before we had lib CompilerOptions so is not useful any more.
What workarounds are you using in the meantime?
no workaround - Had to mark as not breaking change but this would be a breaking change
The text was updated successfully, but these errors were encountered:
I strongly agree with the idea that no-default-lib should not disable inclusion from lib files. We now have a way to , and users should be able to re-enable that behavior with an empty "lib": []. We also have a mechanism for overriding with custom lib files via resolution to @typescript/lib-*; for example, with the following package.json.
I don't know if I have a strong feeling about whether it should permit a file to opt out of skipDefaultLibCheck checking. I believe @RyanCavanaugh might have chatted with a team a while back who wanted to turn on skipLibCheck with the exception of a specific set of hand-authored .d.ts files.
Implement the `isolated_typecheck` parameter and support for type-checking dependent projects in parallel.
When `isolated_typecheck` is set `ts_project` assumes tsc can emit the declaration files without the need for declarations from dependencies. This way the only inputs required to tsc are the source files and tsconfig, not dependencies.
Full type-checking is done as a separate isolated action which does depend on all transitive declarations and is only depended on by a test rule.
Close#374
Ref #374, #679
See [future improvements to noCheck](microsoft/TypeScript#59067)
π Search Terms
lib
,no-default-lib
,noLib
β Viability Checklist
β Suggestion
Currently we have following settings that play together:
CompilerOptions.lib
- Specifies the list of library files to include, if unspecified defaultlib.d.ts
(or specific to target likelib.esnext.full.d.ts
) file is includedCompilerOptions.noLib
- we do not include any lib files (specified byCompilerOptions.lib
or specific to target orlib.d.ts
) or process lib reference directives.This is like noResolve but for libReference directives and including default lib files.
On a side note, with noResolve we do not process reference and type reference directives, we do module resolution and then ignore it. Probably should stop doing module resolution as well
/// <reference no-default-lib="true"/>
directive in the fileThis means this file is treated as default library file and will skip typechecking with
CompilerOptions.skipDefaultLibCheck
and some other implications like not emitting this file etc.Currently this also means if any of the root files, reference or type reference directive or module resolution file if has this set, we will not include default library (either specified by
CompilerOptions.lib
or specific to target orlib.d.ts
) file because we will treat this file encountered as default library. But if file was included for the first time through library reference directive (/// <reference lib="webworker"
) in any of the other files included in the program, we will not skip including default lib files (either specified byCompilerOptions.lib
or specific to target orlib.d.ts
)We also use this sometimes to determine if we should skip reporting error like type came from elaboration. (We do not check if the file is js or ts or declation so thats another issue)
These options together seem to be intended to solve following use cases:
CompilerOptions.lib
and relies on target to include target specific orlib.d.ts
CompilerOptions.lib
. Looks like this should always be honouredCompilerOptions.noLib
- do not include any lib files (event ifCompilerOptions.lib
was specified), do not process lib reference directives, user is in charge of include lib file paths in the config as part of include.CompilerOptions.lib
- can set this as[]
in the config instead if thats the intention (because the default library will conflict with the one user has marked). Currently marking file asno-default-lib
-But then how do we mark typescript default library - ones processed through
CompilerOptions.lib
or default library or throughlib reference directive
.CompilerOptions.skipDefaultLibCheck
is specified Current problem is that many times user dont know why they arent getting library files, and one of their ts or js file has this (eg Fix incorrect condition of noLibΒ #58867 fixed issue where js file was including this. We ignore treating js files as ).noLib
how do we mark typescript files as default libs if user specifies them on root.noLib
seems to be used mainly for transpilation so no error reporting so doesnt matter if they are marked as "default lib"?So it seems like
no-default-lib
predatesCompilerOptions.lib
so it was designed such that if we encountered this we would not include default library file as it might contradict with what user wants to include. But now that we haveCompilerOptions.lib
, it should not mean skip including default library file, whetherCompilerOptions.lib
was specified or not. Currently it seems like this option can be deprecated.π Motivating Example
#57524 - reports lib files are not included because one of the file has this flag on - why should it be on?
#58867 in the repro one of the js file had
/// <reference no-default-lib="true"/>
, seems totally accidentalπ» Use Cases
What do you want to use this for?
Simplifying lib options and avoiding surprises.
What shortcomings exist with current approaches?
no-default-lib
was before we hadlib
CompilerOptions so is not useful any more.What workarounds are you using in the meantime?
no workaround - Had to mark as not breaking change but this would be a breaking change
The text was updated successfully, but these errors were encountered: