Skip to content

Commit

Permalink
Import attributes
Browse files Browse the repository at this point in the history
Fixes #1005
  • Loading branch information
sheetalkamat committed Jan 3, 2024
1 parent 06a03eb commit b80b750
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
7 changes: 4 additions & 3 deletions TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1226,10 +1226,11 @@ repository:
- include: '#import-export-clause'

import-export-assert-clause:
begin: '{{startOfIdentifier}}(assert)\s*(\{)'
begin: '{{startOfIdentifier}}(?:(with)|(assert))\s*(\{)'
beginCaptures:
'1': { name: keyword.control.assert.ts }
'2': { name: punctuation.definition.block.ts }
'1': { name: keyword.control.with.ts }
'2': { name: keyword.control.assert.ts }
'3': { name: punctuation.definition.block.ts }
end: \}
endCaptures:
'0': { name: punctuation.definition.block.ts }
Expand Down
9 changes: 7 additions & 2 deletions TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -3923,15 +3923,20 @@
<key>import-export-assert-clause</key>
<dict>
<key>begin</key>
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(assert)\s*(\{)</string>
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(with)|(assert))\s*(\{)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.assert.ts</string>
<string>keyword.control.with.ts</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.control.assert.ts</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.definition.block.ts</string>
Expand Down
9 changes: 7 additions & 2 deletions TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -3945,15 +3945,20 @@
<key>import-export-assert-clause</key>
<dict>
<key>begin</key>
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(assert)\s*(\{)</string>
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(with)|(assert))\s*(\{)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.assert.tsx</string>
<string>keyword.control.with.tsx</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.control.assert.tsx</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.definition.block.tsx</string>
Expand Down
54 changes: 54 additions & 0 deletions tests/baselines/issue1005.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
original file
-----------------------------------
import foo from "./foo.json" with { type: "json" };
-----------------------------------

Grammar: TypeScript.tmLanguage
-----------------------------------
>import foo from "./foo.json" with { type: "json" };
^^^^^^
source.ts meta.import.ts keyword.control.import.ts
^
source.ts meta.import.ts
^^^
source.ts meta.import.ts variable.other.readwrite.alias.ts
^
source.ts meta.import.ts
^^^^
source.ts meta.import.ts keyword.control.from.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^^^^
source.ts meta.import.ts string.quoted.double.ts
^
source.ts meta.import.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.import.ts
^^^^
source.ts meta.import.ts keyword.control.with.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts punctuation.definition.block.ts
^
source.ts meta.import.ts
^^^^
source.ts meta.import.ts meta.object-literal.key.ts
^
source.ts meta.import.ts punctuation.separator.key-value.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^
source.ts meta.import.ts string.quoted.double.ts
^
source.ts meta.import.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts punctuation.definition.block.ts
^
source.ts punctuation.terminator.statement.ts
1 change: 1 addition & 0 deletions tests/cases/issue1005.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import foo from "./foo.json" with { type: "json" };

0 comments on commit b80b750

Please sign in to comment.