Some more changes to type alias on multi line

Fixes #812 #824 #843
This commit is contained in:
Sheetal Nandi 2023-02-09 11:34:50 -08:00
Родитель 355ee0e1ad
Коммит 07819cfcb8
9 изменённых файлов: 115 добавлений и 13 удалений

Просмотреть файл

@ -2219,7 +2219,7 @@ repository:
begin: (:)(?=\s*\S)
beginCaptures:
'1': { name: keyword.operator.type.annotation.ts }
end: (?<![:|&])((?=$|^|[,);\}\]]|//)|(?==[^>])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))
end: (?<![:|&])(?!\s*[|&]\s+)((?=^|[,);\}\]]|//)|(?==[^>])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))
patterns:
- include: '#type'
# if type starts on next line use modified line endings as end of type annotation eg. complete empty line

Просмотреть файл

@ -6776,7 +6776,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;![:|&amp;])((?=$|^|[,);\}\]]|//)|(?==[^&gt;])|((?&lt;=[\}&gt;\]\)]|[_$[:alpha:]])\s*(?=\{)))</string>
<string>(?&lt;![:|&amp;])(?!\s*[|&amp;]\s+)((?=^|[,);\}\]]|//)|(?==[^&gt;])|((?&lt;=[\}&gt;\]\)]|[_$[:alpha:]])\s*(?=\{)))</string>
<key>patterns</key>
<array>
<dict>

Просмотреть файл

@ -6724,7 +6724,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;![:|&amp;])((?=$|^|[,);\}\]]|//)|(?==[^&gt;])|((?&lt;=[\}&gt;\]\)]|[_$[:alpha:]])\s*(?=\{)))</string>
<string>(?&lt;![:|&amp;])(?!\s*[|&amp;]\s+)((?=^|[,);\}\]]|//)|(?==[^&gt;])|((?&lt;=[\}&gt;\]\)]|[_$[:alpha:]])\s*(?=\{)))</string>
<key>patterns</key>
<array>
<dict>

Просмотреть файл

@ -114,23 +114,23 @@ Grammar: TypeScript.tmLanguage
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts string.quoted.single.ts punctuation.definition.string.end.ts
> | 'a2' // oh , the color is not good !
^^^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts keyword.operator.type.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts string.quoted.single.ts punctuation.definition.string.begin.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts string.quoted.single.ts punctuation.definition.string.begin.ts
^^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts string.quoted.single.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts string.quoted.single.ts
^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts string.quoted.single.ts punctuation.definition.string.end.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts string.quoted.single.ts punctuation.definition.string.end.ts
^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts comment.line.double-slash.ts punctuation.definition.comment.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts comment.line.double-slash.ts
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts meta.field.declaration.ts comment.line.double-slash.ts
> | 'a3' // oh , the color is not good !
^^^
source.ts meta.interface.ts meta.field.declaration.ts meta.type.annotation.ts meta.object.type.ts

Просмотреть файл

@ -168,7 +168,7 @@ Grammar: TypeScript.tmLanguage
source.ts meta.var.expr.ts meta.object.type.ts meta.type.annotation.ts
^
source.ts meta.var.expr.ts meta.object.type.ts meta.type.annotation.ts keyword.operator.ternary.ts
^
^^
source.ts meta.var.expr.ts meta.object.type.ts meta.type.annotation.ts
> () => void;
^^^^^^

Просмотреть файл

@ -0,0 +1,52 @@
original file
-----------------------------------
type Foo = {
bar: number
| string;
};
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>type Foo = {
^^^^
source.ts meta.type.declaration.ts storage.type.type.ts
^
source.ts meta.type.declaration.ts
^^^
source.ts meta.type.declaration.ts entity.name.type.alias.ts
^
source.ts meta.type.declaration.ts
^
source.ts meta.type.declaration.ts keyword.operator.assignment.ts
^
source.ts meta.type.declaration.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts punctuation.definition.block.ts
> bar: number
^^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts
^^^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^^^^^^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
> | string;
^^^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts
^^^^^^
source.ts meta.type.declaration.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts meta.type.declaration.ts meta.object.type.ts punctuation.terminator.statement.ts
>};
^
source.ts meta.type.declaration.ts meta.object.type.ts punctuation.definition.block.ts
^
source.ts punctuation.terminator.statement.ts

Просмотреть файл

@ -0,0 +1,44 @@
original file
-----------------------------------
export let a: string
| boolean | number;
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>export let a: string
^^^^^^
source.ts meta.var.expr.ts keyword.control.export.ts
^
source.ts meta.var.expr.ts
^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts support.type.primitive.ts
> | boolean | number;
^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts punctuation.terminator.statement.ts

4
tests/cases/issue812.ts Normal file
Просмотреть файл

@ -0,0 +1,4 @@
type Foo = {
bar: number
| string;
};

2
tests/cases/issue824.ts Normal file
Просмотреть файл

@ -0,0 +1,2 @@
export let a: string
| boolean | number;