diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage
index b7b12313..32cc2b6b 100644
--- a/TypeScript.YAML-tmLanguage
+++ b/TypeScript.YAML-tmLanguage
@@ -586,31 +586,28 @@ repository:
field-declaration:
name: meta.field.declaration.ts
- begin: (?x)(?
- - match: |-
- (?x)({{identifier}})(\?)?(?=(\?\s*)?{{functionLikeAssignmentOrType}})
- captures:
- '1': { name: meta.definition.property.ts entity.name.function.ts }
- '2': { name: keyword.operator.optional.ts }
- - name: meta.definition.property.ts variable.object.property.ts
- match: '{{identifier}}'
- - name: keyword.operator.optional.ts
- match: \?
+ - include: '#type-annotation'
+ - include: '#string'
+ - include: '#array-literal'
+ - include: '#numeric-literal'
+ - include: '#comment'
+ # function assignment |
+ # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
+ - match: |-
+ (?x)({{identifier}})(\?)?(?=(\?\s*)?{{functionLikeAssignmentOrType}})
+ captures:
+ '1': { name: meta.definition.property.ts entity.name.function.ts }
+ '2': { name: keyword.operator.optional.ts }
+ - name: meta.definition.property.ts variable.object.property.ts
+ match: '{{identifier}}'
+ - name: keyword.operator.optional.ts
+ match: \?
variable-initializer:
patterns:
diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage
index 30d34569..e84c6583 100644
--- a/TypeScript.tmLanguage
+++ b/TypeScript.tmLanguage
@@ -1783,7 +1783,7 @@
(?:\b[0-9][0-9_]*(\.)\B)| # 1.
(?:\B(\.)[0-9][0-9_]*\b)| # .1
(?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
+)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:|;|$))
beginCaptures
1
@@ -1802,7 +1802,7 @@
(?:\b[0-9][0-9_]*(\.)\B)| # 1.
(?:\B(\.)[0-9][0-9_]*\b)| # .1
(?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
+)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:|;|$))))|(?<=\})
patterns
@@ -1810,53 +1810,28 @@
#variable-initializer
- begin
- (?x)(?=((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
- end
- (?x)(?=[};,=]|$|(^(?!\s*((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
- patterns
-
-
- include
- #type-annotation
-
-
- include
- #string
-
-
- include
- #array-literal
-
-
- include
- #numeric-literal
-
-
- include
- #comment
-
-
- match
- (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s*
+ include
+ #type-annotation
+
+
+ include
+ #string
+
+
+ include
+ #array-literal
+
+
+ include
+ #numeric-literal
+
+
+ include
+ #comment
+
+
+ match
+ (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s*
# function assignment |
(=\s*(
((async\s+)?(
@@ -1929,33 +1904,31 @@
)
))
)))
- captures
-
- 1
-
- name
- meta.definition.property.ts entity.name.function.ts
-
- 2
-
- name
- keyword.operator.optional.ts
-
-
-
+ captures
+
+ 1
name
- meta.definition.property.ts variable.object.property.ts
- match
- [_$[:alpha:]][_$[:alnum:]]*
+ meta.definition.property.ts entity.name.function.ts
+ 2
name
keyword.operator.optional.ts
- match
- \?
-
+
+
+
+ name
+ meta.definition.property.ts variable.object.property.ts
+ match
+ [_$[:alpha:]][_$[:alnum:]]*
+
+
+ name
+ keyword.operator.optional.ts
+ match
+ \?
diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage
index 694c2d17..5758a0c0 100644
--- a/TypeScriptReact.tmLanguage
+++ b/TypeScriptReact.tmLanguage
@@ -1787,7 +1787,7 @@
(?:\b[0-9][0-9_]*(\.)\B)| # 1.
(?:\B(\.)[0-9][0-9_]*\b)| # .1
(?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
+)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:|;|$))
beginCaptures
1
@@ -1806,7 +1806,7 @@
(?:\b[0-9][0-9_]*(\.)\B)| # 1.
(?:\B(\.)[0-9][0-9_]*\b)| # .1
(?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
+)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:|;|$))))|(?<=\})
patterns
@@ -1814,53 +1814,28 @@
#variable-initializer
- begin
- (?x)(?=((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
- end
- (?x)(?=[};,=]|$|(^(?!\s*((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
-)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
- patterns
-
-
- include
- #type-annotation
-
-
- include
- #string
-
-
- include
- #array-literal
-
-
- include
- #numeric-literal
-
-
- include
- #comment
-
-
- match
- (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s*
+ include
+ #type-annotation
+
+
+ include
+ #string
+
+
+ include
+ #array-literal
+
+
+ include
+ #numeric-literal
+
+
+ include
+ #comment
+
+
+ match
+ (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s*
# function assignment |
(=\s*(
((async\s+)?(
@@ -1933,33 +1908,31 @@
)
))
)))
- captures
-
- 1
-
- name
- meta.definition.property.tsx entity.name.function.tsx
-
- 2
-
- name
- keyword.operator.optional.tsx
-
-
-
+ captures
+
+ 1
name
- meta.definition.property.tsx variable.object.property.tsx
- match
- [_$[:alpha:]][_$[:alnum:]]*
+ meta.definition.property.tsx entity.name.function.tsx
+ 2
name
keyword.operator.optional.tsx
- match
- \?
-
+
+
+
+ name
+ meta.definition.property.tsx variable.object.property.tsx
+ match
+ [_$[:alpha:]][_$[:alnum:]]*
+
+
+ name
+ keyword.operator.optional.tsx
+ match
+ \?
diff --git a/tests/baselines/Issue642.baseline.txt b/tests/baselines/Issue642.baseline.txt
index 4f9880e3..fe0d3b4f 100644
--- a/tests/baselines/Issue642.baseline.txt
+++ b/tests/baselines/Issue642.baseline.txt
@@ -34,11 +34,11 @@ Grammar: TypeScript.tmLanguage
^
source.ts meta.class.ts
^^^^^^^^
- source.ts meta.class.ts storage.modifier.ts
+ source.ts meta.class.ts meta.field.declaration.ts storage.modifier.ts
^
- source.ts meta.class.ts
+ source.ts meta.class.ts meta.field.declaration.ts
^^^^^
- source.ts meta.class.ts variable.other.readwrite.ts
+ source.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
^
source.ts meta.class.ts punctuation.terminator.statement.ts
>}
diff --git a/tests/baselines/Issue643.baseline.txt b/tests/baselines/Issue643.baseline.txt
new file mode 100644
index 00000000..fbf2a48f
--- /dev/null
+++ b/tests/baselines/Issue643.baseline.txt
@@ -0,0 +1,92 @@
+original file
+-----------------------------------
+export class TestClient {
+ private readonly test1;
+ private readonly test2?;
+ private readonly test3;
+ private readonly test4;
+}
+-----------------------------------
+
+Grammar: TypeScript.tmLanguage
+-----------------------------------
+>export class TestClient {
+ ^^^^^^
+ source.ts meta.class.ts keyword.control.export.ts
+ ^
+ source.ts meta.class.ts
+ ^^^^^
+ 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
+> private readonly test1;
+ ^^^^
+ source.ts meta.class.ts
+ ^^^^^^^
+ source.ts meta.class.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts
+ ^^^^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts meta.field.declaration.ts
+ ^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
+ ^
+ source.ts meta.class.ts punctuation.terminator.statement.ts
+> private readonly test2?;
+ ^^^^
+ source.ts meta.class.ts
+ ^^^^^^^
+ source.ts meta.class.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts
+ ^^^^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts meta.field.declaration.ts
+ ^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
+ ^
+ source.ts meta.class.ts meta.field.declaration.ts keyword.operator.optional.ts
+ ^
+ source.ts meta.class.ts punctuation.terminator.statement.ts
+> private readonly test3;
+ ^^^^
+ source.ts meta.class.ts
+ ^^^^^^^
+ source.ts meta.class.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts
+ ^^^^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts meta.field.declaration.ts
+ ^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
+ ^
+ source.ts meta.class.ts punctuation.terminator.statement.ts
+> private readonly test4;
+ ^^^^
+ source.ts meta.class.ts
+ ^^^^^^^
+ source.ts meta.class.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts
+ ^^^^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts storage.modifier.ts
+ ^
+ source.ts meta.class.ts meta.field.declaration.ts
+ ^^^^^
+ source.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
+ ^
+ source.ts meta.class.ts punctuation.terminator.statement.ts
+>}
+ ^
+ source.ts meta.class.ts punctuation.definition.block.ts
\ No newline at end of file
diff --git a/tests/baselines/SyntacticallyIncorrectStrings.baseline.txt b/tests/baselines/SyntacticallyIncorrectStrings.baseline.txt
index 47a53924..1ffaa07e 100644
--- a/tests/baselines/SyntacticallyIncorrectStrings.baseline.txt
+++ b/tests/baselines/SyntacticallyIncorrectStrings.baseline.txt
@@ -34,13 +34,13 @@ Grammar: TypeScript.tmLanguage
source.ts meta.class.ts punctuation.definition.block.ts
> "some string"
^^^^
- source.ts meta.class.ts
+ source.ts meta.class.ts meta.field.declaration.ts
^
- source.ts meta.class.ts string.quoted.double.ts punctuation.definition.string.begin.ts
+ source.ts meta.class.ts meta.field.declaration.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^^^^^
- source.ts meta.class.ts string.quoted.double.ts
+ source.ts meta.class.ts meta.field.declaration.ts string.quoted.double.ts
^
- source.ts meta.class.ts string.quoted.double.ts punctuation.definition.string.end.ts
+ source.ts meta.class.ts meta.field.declaration.ts string.quoted.double.ts punctuation.definition.string.end.ts
>}
^
source.ts meta.class.ts punctuation.definition.block.ts
diff --git a/tests/baselines/SyntacticallyIncorrectStrings.txt b/tests/baselines/SyntacticallyIncorrectStrings.txt
index 8fb26e83..4ab7f820 100644
--- a/tests/baselines/SyntacticallyIncorrectStrings.txt
+++ b/tests/baselines/SyntacticallyIncorrectStrings.txt
@@ -18,7 +18,7 @@ Grammar: TypeScript.tmLanguage
>class SomeClass {
> "some string"
^
- [4, 5]: source.ts meta.class.ts string.quoted.double.ts punctuation.definition.string.begin.ts
+ [4, 5]: source.ts meta.class.ts meta.field.declaration.ts string.quoted.double.ts punctuation.definition.string.begin.ts
>}
>
>var y "some string 2"
diff --git a/tests/cases/Issue643.ts b/tests/cases/Issue643.ts
new file mode 100644
index 00000000..a2f07ebf
--- /dev/null
+++ b/tests/cases/Issue643.ts
@@ -0,0 +1,6 @@
+export class TestClient {
+ private readonly test1;
+ private readonly test2?;
+ private readonly test3;
+ private readonly test4;
+}
\ No newline at end of file