Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript] Implement labeled tuple members #3837

Merged
merged 4 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions JavaScript/TypeScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -925,14 +925,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: \{
Expand Down
31 changes: 31 additions & 0 deletions JavaScript/tests/syntax_test_typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,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
Expand Down