Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: Mention how to ban top-level-await #10920

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating
@kirkwaiblinger

Description

@kirkwaiblinger

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

node 23 now supportsrequire(esm) (unflagged), soTS 5.8 now won't always error whenrequire()ing an ESM from CJS. That means that any upstream code using top level await ("TLA") (see also the term "async module") will cause the program to fail at runtime, whichwon't be validated at all by TS. Therefore, projects wanting to take advantage ofrequire(esm) to migrate CJS to ESM will want to ban TLA from appearing in their application's ESM. Similarly, libraries publishing ESM intended to be possible torequire() must also not use TLA.

There are also times where you would want to use TLA (for example, top level of node js CLI scripts).

Let's provide an example in no-restricted-syntax of how to ban TLA if people want to for their projects.

Here's the config (playground):

{"no-restricted-syntax": ["warn",      {"selector":"AwaitExpression:not(:matches(FunctionExpression AwaitExpression, ArrowFunctionExpression AwaitExpression, FunctionDeclaration AwaitExpression))","message":"TLA makes it impossible to `require()` this module or any of its downstream dependencies."      }    ]}

Affected URL(s)

https://typescript-eslint.io/troubleshooting/faqs/general/#how-can-i-ban-specific-language-feature

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp