microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
99.81k stars 12.35k forks source link

Deprecating no-default-lib and rethinking of other lib related CompilerOptions #59067

Open sheetalkamat opened 1 month ago

sheetalkamat commented 1 month ago

🔍 Search Terms

lib, no-default-lib, noLib

✅ Viability Checklist

⭐ Suggestion

Currently we have following settings that play together:

📃 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

  1. What do you want to use this for? Simplifying lib options and avoiding surprises.

  2. What shortcomings exist with current approaches? no-default-lib was before we had lib CompilerOptions so is not useful any more.

  3. What workarounds are you using in the meantime? no workaround - Had to mark as not breaking change but this would be a breaking change

DanielRosenwasser commented 1 month ago

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.

{
 "dependencies": {
    "@typescript/lib-dom": "npm:@types/web"
  }
}

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.