Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should target: es2020 set module: es2020 by default? #46144

Open
saschanaz opened this issue Sep 30, 2021 · 6 comments
Open

Should target: es2020 set module: es2020 by default? #46144

saschanaz opened this issue Sep 30, 2021 · 6 comments
Labels
Needs Investigation This issue needs a team member to investigate its status. Suggestion An idea for TypeScript

Comments

@saschanaz
Copy link
Contributor

From #44656

Should this function return ModuleKind.ES2020 and ES2022 following the target version? It seems #33893 missed this, and I wonder this needs to be fixed.

export function getEmitModuleKind(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) {
return typeof compilerOptions.module === "number" ?
compilerOptions.module :
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
}

@dnalborczyk
Copy link

dnalborczyk commented Sep 30, 2021

on a similar note regarding #44656

shouldn't top-level-await only be available when the target is set to ES2022 (doesn't exist yet) or higher/ESNext incl. module set to ES2022 or higher/ESNext (above PR). I personally would assume yes.

nm, I got it mixed up.

@saschanaz
Copy link
Contributor Author

I think that's a different issue and should be filed separately 🤔

@sandersn sandersn added Needs Investigation This issue needs a team member to investigate its status. Suggestion An idea for TypeScript labels Oct 7, 2021
@sandersn
Copy link
Member

sandersn commented Oct 7, 2021

@weswigham has the way that target maps to module changed? Above it looks like anything about ES2015 maps to ES2015 modules.

@weswigham
Copy link
Member

I don't think so? The new node module modes imply some target modes if it's unset, but I don't think anything else has changed.

@jimmywarting
Copy link
Contributor

thinking there should be a target option in vs code itself...
not everyone use typescript... i use vanilla javascript. if no tsconfig/jsconfig is available then it should assume esnext i.m.o.

don't assume that you know what the target the developer is developing for, i'm getting red lines about top level await everywhere
i wish i did not have to add a tsconfig.json just so i can get rid of this annoying error messages with checkJS turned on

@saschanaz
Copy link
Contributor Author

saschanaz commented Feb 20, 2022

thinking there should be a target option in vs code itself...

Well, jsconfig exists solely for that purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants