diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index b0e9699..aeb304f 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -425,11 +425,13 @@ repository: - include: '#string' - include: '#array-literal' - include: '#comment' - - name: meta.definition.property.ts entity.name.function.ts - # function assignment | - # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => - match: |- - (?x)({{identifier}})(?=(\?\s*)?{{functionLikeAssignmentOrType}}) + # 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 diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage index 5ebb6b0..01d4ca2 100644 --- a/TypeScript.tmLanguage +++ b/TypeScript.tmLanguage @@ -1234,10 +1234,8 @@ #comment - name - meta.definition.property.ts entity.name.function.ts match - (?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\?\s*)?\s* + (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s* # function assignment | (=\s*( ((async\s+)?( @@ -1305,6 +1303,19 @@ ) )) ))) + captures + + 1 + + name + meta.definition.property.ts entity.name.function.ts + + 2 + + name + keyword.operator.optional.ts + + name diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index fc8f3fa..7c6a853 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -1238,10 +1238,8 @@ #comment - name - meta.definition.property.tsx entity.name.function.tsx match - (?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\?\s*)?\s* + (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s* # function assignment | (=\s*( ((async\s+)?( @@ -1309,6 +1307,19 @@ ) )) ))) + captures + + 1 + + name + meta.definition.property.tsx entity.name.function.tsx + + 2 + + name + keyword.operator.optional.tsx + + name diff --git a/tests/baselines/Issue581.baseline.txt b/tests/baselines/Issue581.baseline.txt new file mode 100644 index 0000000..b9b7830 --- /dev/null +++ b/tests/baselines/Issue581.baseline.txt @@ -0,0 +1,78 @@ +original file +----------------------------------- +interface Foo { + a: () => void; + b?: () => void; +} +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>interface Foo { + ^^^^^^^^^ + source.ts meta.interface.ts storage.type.interface.ts + ^ + source.ts meta.interface.ts + ^^^ + source.ts meta.interface.ts entity.name.type.interface.ts + ^ + source.ts meta.interface.ts + ^ + source.ts meta.interface.ts punctuation.definition.block.ts + ^^ + source.ts meta.interface.ts +> a: () => void; + ^^ + source.ts meta.interface.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.definition.property.ts entity.name.function.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts + ^^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts storage.type.function.arrow.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts + ^^^^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts support.type.primitive.ts + ^ + source.ts meta.interface.ts punctuation.terminator.statement.ts + ^^ + source.ts meta.interface.ts +> b?: () => void; + ^^ + source.ts meta.interface.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.definition.property.ts entity.name.function.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts keyword.operator.optional.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts + ^^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts storage.type.function.arrow.ts + ^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts + ^^^^ + source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.type.function.return.ts support.type.primitive.ts + ^ + source.ts meta.interface.ts punctuation.terminator.statement.ts + ^^ + source.ts meta.interface.ts +>} + ^ + source.ts meta.interface.ts punctuation.definition.block.ts \ No newline at end of file diff --git a/tests/cases/Issue581.ts b/tests/cases/Issue581.ts new file mode 100644 index 0000000..9e698e1 --- /dev/null +++ b/tests/cases/Issue581.ts @@ -0,0 +1,4 @@ +interface Foo { + a: () => void; + b?: () => void; +} \ No newline at end of file