diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index eadfe027fe..39c779b536 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -921,14 +921,43 @@ contexts: scope: punctuation.section.sequence.end.js pop: 1 - include: comma-separator - - match: \.\.\. - scope: keyword.operator.spread.js - match: (?=\S) push: - ts-type-annotation-optional - ts-type-expression-end - ts-type-expression-end-no-line-terminator - ts-type-expression-begin + - ts-type-tuple-spread + - ts-type-tuple-possible-member-label + + ts-type-tuple-possible-member-label: + - match: '' + branch_point: ts-type-tuple-member-label + branch: + - ts-type-tuple-member-label + - immediately-pop + pop: 1 + + ts-type-tuple-member-label: + - match: '{{identifier_name}}' + scope: variable.other.member.js + set: + - ts-type-tuple-member-label-separator + - ts-type-annotation-optional + - include: else-pop + + ts-type-tuple-member-label-separator: + - match: ':' + scope: punctuation.separator.type.js + pop: 1 + - match: (?=\S) + fail: ts-type-tuple-member-label + + ts-type-tuple-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + pop: 1 + - include: else-pop ts-type-object: - match: \{ diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 5eb155ab3c..981618d40f 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -866,6 +866,37 @@ let x: [ any , any ? , ... any [] ]; // ^^ storage.modifier.array // ^ punctuation.section.sequence.end +let x: [ first: any, rest: ...any ]; +//^ keyword.declaration +// ^ meta.binding.name variable.other.readwrite +// ^ punctuation.separator.type +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.type +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence +// ^ punctuation.section.sequence.begin +// ^^^^^ variable.other.member +// ^ punctuation.separator.type +// ^^^ support.type.any +// ^ punctuation.separator.comma +// ^^^^ variable.other.member +// ^ punctuation.separator.type +// ^^^ keyword.operator.spread +// ^^^ support.type.any +// ^ punctuation.section.sequence.end +// ^ punctuation.terminator.statement + +let x: [ + typeof +// ^^^^^ variable.other.member + ? +// ^ storage.modifier.optional + : +// ^ punctuation.separator.type + ... +// ^^^ keyword.operator.spread + any +// ^^^ support.type.any +]; + let x: any & any; // ^^^^^^^^^ meta.type // ^^^ support.type.any