microsoft / TypeScript

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

es2021 is not a valid value for lib compiler option #45063

Closed Zuckjet closed 3 years ago

Zuckjet commented 3 years ago

Bug Report

🔎 Search Terms

es2021

🕗 Version & Regression Information

typescript version is 4.3.2

⏯ Playground Link

Playground link with relevant code

💻 Code

const text = "typescript is awesome";
text.replaceAll(/typescript/g, 'ts');

🙁 Actual behavior

Property 'replaceAll' does not exist on type '"typescript is awesome"'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. ts(2550)

But es2021 is not a valid value for lib compiler option in tsconfig.json:

Value is not accepted. Valid values: "ES5", "ES6", "ES2015", "ES2015.Collection", "ES2015.Core", "ES2015.Generator", "ES2015.Iterable", "ES2015.Promise", "ES2015.Proxy", "ES2015.Reflect", "ES2015.Symbol.WellKnown", "ES2015.Symbol", "ES2016", "ES2016.Array.Include", "ES2017", "ES2017.Intl", "ES2017.Object", "ES2017.SharedMemory", "ES2017.String", "ES2017.TypedArrays", "ES2018", "ES2018.AsyncGenerator", "ES2018.AsyncIterable", "ES2018.Intl", "ES2018.Promise", "ES2018.Regexp", "ES2019", "ES2019.Array", "ES2019.Object", "ES2019.String", "ES2019.Symbol", "ES2020", "ES2020.BigInt", "ES2020.Promise", "ES2020.String", "ES2020.Symbol.WellKnown", "ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.BigInt", "ESNext.Intl", "ESNext.Promise", "ESNext.String", "ESNext.Symbol", "DOM", "DOM.Iterable", "ScriptHost", "WebWorker", "WebWorker.ImportScripts".(1)

image

image

🙂 Expected behavior

IllusionMH commented 3 years ago

Is it reproducible when you use TS 4.3.5 in CLI?

What VS Code version are you using and what TS version is used for this workspace (bottom right corner)? Is it workspace version 4.3.5 or some other built-in?

VS Code might yell on lowercase value es2021 (because apparently validation expects uppercase only) but from CLI it would work as expected and replaceAll won't trigger an error in editor.

Zuckjet commented 3 years ago

Thanks, I can use uppercase to fix the problem. But I expect it should be case-insensitive. So I have sent a PR for fix this.

IllusionMH commented 3 years ago

That's awesome!

nata7che commented 2 years ago

having the same issue still. uppercase does not help. any other thoughts on how to solve this?

cb109 commented 2 years ago

Changing tsconfig.json lib: ["ES2020"] to lib: ["ES2021"] did indeed solve it for me.

Amn3s1a2018 commented 1 year ago

I got the same, because of the file wasn't in the scope of tsconfig (wasn't imported from any of tsconfig.files) It was really confusing, 'til found out.