Skip to content

fix(46149): Add specific top level await error messages #46488

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

Closed
wants to merge 7 commits into from

Conversation

sidharthv96
Copy link
Contributor

Fixes #46149

@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #46149. If you can get it accepted, this PR will have a better chance of being reviewed.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Oct 22, 2021
@sidharthv96
Copy link
Contributor Author

These two messages could be unified, but I wasn't sure if removing an existing error code is a good idea.

  • The module setting '{0}' does not support top-level 'await' expressions. Consider switching to '{1}'.
  • The module setting '{0}' does not support top-level 'for await' loops. Consider switching to '{1}'.

@sandersn
Copy link
Member

Do you want to keep working on this? Otherwise I'd like to close it to reduce the number of open PRs.

@sidharthv96
Copy link
Contributor Author

Sorry, got really busy @work. Will push the changes over the weekend.

* upstream/main: (473 commits)
  Correct node used for isDefinition calculation (microsoft#48499)
  fix(48405): emit dummy members from a mapped type (microsoft#48481)
  CFA for dependent parameters typed by generic constraints (microsoft#48411)
  No contextual typing from return types for boolean literals (microsoft#48380)
  fix(47733): omit JSDoc comment template suggestion on node with existing JSDoc (microsoft#47748)
  Ensure that we copy empty NodeArrays during transform (microsoft#48490)
  Add a new compiler option `moduleSuffixes` to expand the node module resolver's search algorithm (microsoft#48189)
  feat(27615): Add missing member fix should work for type literals (microsoft#47212)
  Add label details to completion entry (microsoft#48429)
  Enable method signature completion for object literals (microsoft#48168)
  Fix string literal completions when a partially-typed string fixes inference to a type parameter (microsoft#48410)
  fix(48445): show errors on type-only import/export specifiers in JavaScript files (microsoft#48449)
  Fix newline inserted in empty block at end of formatting range (microsoft#48463)
  Prevent looking up symbol for as const from triggering an error (microsoft#48464)
  Revise accessor resolution logic and error reporting (microsoft#48459)
  fix(48166): skip checking module.exports in a truthiness call expression (microsoft#48337)
  LEGO: Merge pull request 48450
  LEGO: Merge pull request 48436
  fix(48031): show circularity error for self referential get accessor annotations (microsoft#48050)
  Revert "Fix contextual discrimination for omitted members (microsoft#43937)" (microsoft#48426)
  ...
@sidharthv96 sidharthv96 requested a review from weswigham April 1, 2022 04:45
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what, between the major refactoring to the checker and us removing node12 and replacing it with node14, I think this needs some changes at this point to make sense. I'm going to close this PR - if you or anyone else wants to take another crack at better TLA errors in this new context, feel free to open a new PR - that way it'll get back on the pile of things for us to look at faster. Thanks for the help 💖

@@ -815,6 +815,10 @@ namespace ts {
return isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
}

export function isNotTopLevelAwaitSupportedModuleKind(kind: ModuleKind, impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS){
return kind !== ModuleKind.ES2022 && kind !== ModuleKind.ESNext && kind !== ModuleKind.System && !(kind === ModuleKind.NodeNext && impliedNodeFormat === ModuleKind.ESNext);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We bumped from node12 to node14, specifically for TLA, so this needs to be updated to account for that.

@weswigham weswigham closed this Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Provide a specialized error on top-level await and --module node12
5 participants