Skip to content

Commit

Permalink
[TypeScript] Better highlighting while typing declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom1729 committed Sep 23, 2023
1 parent a05930d commit 2bb96ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 9 additions & 4 deletions JavaScript/TypeScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ contexts:
- include: immediately-pop

ts-interface-name:
- match: '{{identifier_name}}'
- match: '{{non_reserved_identifier}}'
scope: entity.name.interface.js
pop: 1
- include: else-pop
Expand All @@ -348,6 +348,7 @@ contexts:
scope: punctuation.section.block.end.js
pop: 1
- include: ts-type-members
- include: else-pop

ts-type-members:
- match: '[,;]'
Expand Down Expand Up @@ -456,7 +457,7 @@ contexts:
- include: immediately-pop

ts-type-alias-name:
- match: '{{identifier_name}}'
- match: '{{non_reserved_identifier}}'
scope: entity.name.type.js
pop: 1
- include: else-pop
Expand All @@ -475,7 +476,7 @@ contexts:
scope: keyword.declaration.js
set:
- ts-namespace-meta
- block
- ts-namespace-body
- ts-namespace-name-end
- ts-namespace-name

Expand All @@ -484,14 +485,18 @@ contexts:
- meta_scope: meta.namespace.js
- include: immediately-pop

ts-namespace-body:
- include: block
- include: else-pop

ts-namespace-name-end:
- match: \.
scope: punctuation.accessor.dot.js
push: ts-namespace-name
- include: else-pop

ts-namespace-name:
- match: '{{identifier_name}}'
- match: '{{non_reserved_identifier}}'
scope: entity.name.namespace.js
pop: 1
- include: else-pop
Expand Down
13 changes: 13 additions & 0 deletions JavaScript/tests/syntax_test_typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,19 @@ import foo;
// ^^^ entity.name.namespace
// ^^ meta.block punctuation.section.block

// Don't break highlighting while typing
interface
class Foo {}
// <- meta.class keyword.declaration.class

type
class Foo {}
// <- meta.class keyword.declaration.class

namespace
class Foo {}
// <- meta.class keyword.declaration.class

/* Annotations */

var x: any = 42;
Expand Down

0 comments on commit 2bb96ae

Please sign in to comment.