Skip to content

Commit

Permalink
[JavaScript] Support import assertions (#3186)
Browse files Browse the repository at this point in the history
See https://github.com/tc39/proposal-import-assertions.

It's in Stage 3, which is our benchmark for inclusion. It is also part of TypeScript 4.5.
  • Loading branch information
Thom1729 authored Dec 31, 2021
1 parent 73d86db commit 68b5d59
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ contexts:
set:
- import-meta
- expect-semicolon
- import-assert
- import-string-or-items
- import-check-branch

Expand Down Expand Up @@ -338,6 +339,14 @@ contexts:
push: import-export-alias
- include: else-pop

import-assert:
- match: assert{{identifier_break}}
scope: keyword.control.import-export.js
set:
- include: object-literal
- include: else-pop
- include: else-pop

export-meta:
- meta_include_prototype: false
- meta_scope: meta.export.js
Expand Down
1 change: 1 addition & 0 deletions JavaScript/TypeScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ contexts:
set:
- import-meta
- expect-semicolon
- import-assert
- import-string-or-items
- ts-import-type
- import-check-branch
Expand Down
19 changes: 19 additions & 0 deletions JavaScript/tests/syntax_test_js_import_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ import thing, {identifier as otherIdentifier}, * as otherName from "otherplace";
import 'module';
// ^^^^^^^^^^^^^ meta.import

import foo from 'bar' assert { type: "json" };
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.import.js
//^^^^ keyword.control.import-export.js
// ^^^ variable.other.readwrite.js
// ^^^^ keyword.control.import-export.js
// ^^^^^ meta.string.js string.quoted.single.js
// ^ punctuation.definition.string.begin.js
// ^ punctuation.definition.string.end.js
// ^^^^^^ keyword.control.import-export.js
// ^^^^^^^^^^^^^^^^ meta.mapping.js
// ^ punctuation.section.block.begin.js
// ^^^^ meta.mapping.key.js
// ^ punctuation.separator.key-value.js
// ^^^^^^ meta.string.js string.quoted.double.js
// ^ punctuation.definition.string.begin.js
// ^ punctuation.definition.string.end.js
// ^ punctuation.section.block.end.js
// ^ punctuation.terminator.statement.js

// Better highlighting while typing.
import
import;
Expand Down

0 comments on commit 68b5d59

Please sign in to comment.