← Back to release summary

Deprecate and remove import assertion 'assert' syntax

Category
JavaScript
Type
Feature removal
Status
Deprecated (Chrome 126)
Intent stage
None

Summary

TC39 has consensus for trying to deprecate and remove the `assert` keyword in favor of the new `with` keyword in import attribute syntax. That is, `import m from 'foo' assert { type: 'json' }` will now throw a SyntaxError, and developers must change to `import m from 'foo' with { type: 'json' }`. https://github.com/tc39/proposal-import-attributes/issues/135

Motivation

The import assertions proposal (now called "import attributes") [1] in TC39 shipped in M91 with the `import mod from 'foo' assert { type: 'json' }` syntax. The original semantics was that additional information following the `assert` keyword cannot cause the module to be reinterpreted or change the semantics of the module in any way, i.e., a pure assertion. Following an HTML integration issue with CSP [2] that required changing Accept headers depending on the requested module type, TC39 reached consensus that the "pure assertion" semantics are to be relaxed to allow reinterpretation, and that the `assert` keyword be changed to `with` to reflect the new semantics. [1] https://github.com/tc39/proposal-import-attributes/ [2] https://github.com/whatwg/html/issues/7233

Standards & signals

View on chromestatus.com