diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage
index 1943ceef..1edea936 100644
--- a/TypeScript.YAML-tmLanguage
+++ b/TypeScript.YAML-tmLanguage
@@ -1107,7 +1107,7 @@ repository:
- include: '#interface-declaration'
- include: '#expression'
- name: meta.export.ts
- begin: '{{startOfIdentifier}}(export)(?!\s*:)((?=\s*[\{*])|((?=\s*{{identifier}}(\s|,))(?!\s*{{constructsAndModifiers}})))'
+ begin: '{{startOfIdentifier}}(export)\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*{{identifier}}(\s|,))(?!\s*{{constructsAndModifiers}})))'
beginCaptures:
'0': { name: keyword.control.export.ts }
end: (?=$|{{endOfStatement}})
diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage
index f0b42e2e..23315e83 100644
--- a/TypeScript.tmLanguage
+++ b/TypeScript.tmLanguage
@@ -3581,7 +3581,7 @@
name
meta.export.ts
begin
- (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?!\s*:)((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))
+ (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))
beginCaptures
0
diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage
index 6d654aef..9f916619 100644
--- a/TypeScriptReact.tmLanguage
+++ b/TypeScriptReact.tmLanguage
@@ -3585,7 +3585,7 @@
name
meta.export.tsx
begin
- (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?!\s*:)((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))
+ (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))
beginCaptures
0
diff --git a/tests/baselines/Issue662.baseline.txt b/tests/baselines/Issue662.baseline.txt
new file mode 100644
index 00000000..f9365e75
--- /dev/null
+++ b/tests/baselines/Issue662.baseline.txt
@@ -0,0 +1,182 @@
+original file
+-----------------------------------
+const a = (() => {
+ let exports;
+ exports = {
+ x: {},
+ };
+ if (exports.x) {
+ console.log("");
+ }
+});
+
+// no highlighting
+class C {}
+function f() {}
+-----------------------------------
+
+Grammar: TypeScript.tmLanguage
+-----------------------------------
+>const a = (() => {
+ ^^^^^
+ source.ts meta.var.expr.ts storage.type.ts
+ ^
+ source.ts meta.var.expr.ts
+ ^
+ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
+ ^
+ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
+ ^
+ source.ts meta.var.expr.ts keyword.operator.assignment.ts
+ ^
+ source.ts meta.var.expr.ts
+ ^
+ source.ts meta.var.expr.ts meta.brace.round.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.end.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts
+ ^^
+ source.ts meta.var.expr.ts meta.arrow.ts storage.type.function.arrow.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
+> let exports;
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.var.expr.ts storage.type.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.var.expr.ts
+ ^^^^^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.terminator.statement.ts
+> exports = {
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^^^^^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts support.type.object.module.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts keyword.operator.assignment.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts punctuation.definition.block.ts
+> x: {},
+ ^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts punctuation.separator.key-value.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.objectliteral.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts meta.object.member.ts meta.objectliteral.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts punctuation.separator.comma.ts
+> };
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.objectliteral.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.terminator.statement.ts
+> if (exports.x) {
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts keyword.control.conditional.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
+ ^^^^^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts support.type.object.module.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.accessor.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts support.variable.property.dom.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.brace.round.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
+> console.log("");
+ ^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts
+ ^^^^^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts meta.function-call.ts support.class.console.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts meta.function-call.ts punctuation.accessor.ts
+ ^^^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts meta.function-call.ts support.function.console.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts meta.brace.round.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts meta.brace.round.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.terminator.statement.ts
+> }
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
+>});
+ ^
+ source.ts meta.var.expr.ts meta.arrow.ts meta.block.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.var.expr.ts meta.brace.round.ts
+ ^
+ source.ts punctuation.terminator.statement.ts
+>
+ ^
+ source.ts
+>// no highlighting
+ ^^
+ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
+ ^^^^^^^^^^^^^^^^
+ source.ts comment.line.double-slash.ts
+>class C {}
+ ^^^^^
+ source.ts meta.class.ts storage.type.class.ts
+ ^
+ source.ts meta.class.ts
+ ^
+ source.ts meta.class.ts entity.name.type.class.ts
+ ^
+ source.ts meta.class.ts
+ ^
+ source.ts meta.class.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.class.ts punctuation.definition.block.ts
+>function f() {}
+ ^^^^^^^^
+ source.ts meta.function.ts storage.type.function.ts
+ ^
+ source.ts meta.function.ts
+ ^
+ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
+ ^
+ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
+ ^
+ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
+ ^
+ source.ts meta.function.ts
+ ^
+ source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
+ ^
+ source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
\ No newline at end of file
diff --git a/tests/cases/Issue662.ts b/tests/cases/Issue662.ts
new file mode 100644
index 00000000..5299cd0e
--- /dev/null
+++ b/tests/cases/Issue662.ts
@@ -0,0 +1,13 @@
+const a = (() => {
+ let exports;
+ exports = {
+ x: {},
+ };
+ if (exports.x) {
+ console.log("");
+ }
+});
+
+// no highlighting
+class C {}
+function f() {}
\ No newline at end of file