Skip to content

Add a rule to the compiler options to disallow the assert keyword for import attributesΒ #58453

Open

Description

πŸ” Search Terms

"import assertions", "import attributes", "assert"

βœ… Viability Checklist

⭐ Suggestion

Currently Stage 3 Import Attributes deprecates the assert keywords and is working to remove them from the spec if possible. V8 will remove support for the assert keywords, so Node.js and Chrome will follow suit.

Hey, quick update on this. Node.js is planning to remove support for assert in v22 (which will be released in April) and Chrome in v126 (which will be released in May).

denoland/deno#17944 (comment)

I would like to remove support for the assert keywords from TypeScript as well, and would like to add disallowAssertKeywords to the compiler options as a beginning.

FYI

JSR bans publishing of TypeScript/JavaScript files that use the assert keywords.
jsr-io/jsr#427

I've made a PR for swc, but it is pending because I can't include features that are not in tsc.
swc-project/swc#8913

πŸ“ƒ Motivating Example

The following code will fail if the disallowAssertKeywords option is enabled.

import foo from "./foo.json" assert { type: "json" };

πŸ’» Use Cases

  1. What do you want to use this for?

Deno / JSR

  1. What shortcomings exist with current approaches?

Deprecated the assert keywords cannot be rejected

  1. What workarounds are you using in the meantime?

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    CommittedThe team has roadmapped this issueFix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions