Handle '|' and '&' operator in function return type when they are followed by object type
Fixes #427
This commit is contained in:
Родитель
b68820e853
Коммит
2ea303c6ca
|
@ -836,12 +836,12 @@ repository:
|
|||
begin: (?<=\))\s*(:)
|
||||
beginCaptures:
|
||||
'1': { name: keyword.operator.type.annotation.ts }
|
||||
end: (?<!:)((?=$)|(?=[{};,]|//))
|
||||
end: (?<![:|&])((?=$)|(?=[{};,]|//))
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
# Handle returning of object type specifically here so as to not confuse it with the start of function block
|
||||
- name: meta.object.type.ts
|
||||
begin: (?<=:)\s*(\{)
|
||||
begin: (?<=[:|&])\s*(\{)
|
||||
beginCaptures:
|
||||
'1': { name: punctuation.definition.block.ts }
|
||||
end: \}
|
||||
|
@ -970,12 +970,12 @@ repository:
|
|||
begin: '=>'
|
||||
beginCaptures:
|
||||
'0': { name: storage.type.function.arrow.ts }
|
||||
end: (?<!=>)(?=[,\]\)\{\}=;>]|//|$)
|
||||
end: (?<!=>)(?<![|&])(?=[,\]\)\{\}=;>]|//|$)
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
# Handle returning of object type specifically here so as to not confuse it with the start of function block
|
||||
- name: meta.object.type.ts
|
||||
begin: (?<==>)\s*(\{)
|
||||
begin: (?:(?<==>)|(?<=[|&]))\s*(\{)
|
||||
beginCaptures:
|
||||
'1': { name: punctuation.definition.block.ts }
|
||||
end: \}
|
||||
|
@ -1663,7 +1663,7 @@ repository:
|
|||
# TODO: handle the fn and constructor type specifically.
|
||||
# Handle returning of object type specifically here so as to not confuse it with the start of function block
|
||||
- name: meta.object.type.ts
|
||||
begin: (?<=:)\s*(\{)
|
||||
begin: (?<=[:|&])\s*(\{)
|
||||
beginCaptures:
|
||||
'1': { name: punctuation.definition.block.ts }
|
||||
end: \}
|
||||
|
|
|
@ -2581,7 +2581,7 @@
|
|||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?<!:)((?=$)|(?=[{};,]|//))</string>
|
||||
<string>(?<![:|&])((?=$)|(?=[{};,]|//))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -2592,7 +2592,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.ts</string>
|
||||
<key>begin</key>
|
||||
<string>(?<=:)\s*(\{)</string>
|
||||
<string>(?<=[:|&])\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
@ -2936,7 +2936,7 @@
|
|||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?<!=>)(?=[,\]\)\{\}=;>]|//|$)</string>
|
||||
<string>(?<!=>)(?<![|&])(?=[,\]\)\{\}=;>]|//|$)</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -2947,7 +2947,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.ts</string>
|
||||
<key>begin</key>
|
||||
<string>(?<==>)\s*(\{)</string>
|
||||
<string>(?:(?<==>)|(?<=[|&]))\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
@ -4549,7 +4549,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.ts</string>
|
||||
<key>begin</key>
|
||||
<string>(?<=:)\s*(\{)</string>
|
||||
<string>(?<=[:|&])\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
|
|
@ -2585,7 +2585,7 @@
|
|||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?<!:)((?=$)|(?=[{};,]|//))</string>
|
||||
<string>(?<![:|&])((?=$)|(?=[{};,]|//))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -2596,7 +2596,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.tsx</string>
|
||||
<key>begin</key>
|
||||
<string>(?<=:)\s*(\{)</string>
|
||||
<string>(?<=[:|&])\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
@ -2940,7 +2940,7 @@
|
|||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?<!=>)(?=[,\]\)\{\}=;>]|//|$)</string>
|
||||
<string>(?<!=>)(?<![|&])(?=[,\]\)\{\}=;>]|//|$)</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -2951,7 +2951,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.tsx</string>
|
||||
<key>begin</key>
|
||||
<string>(?<==>)\s*(\{)</string>
|
||||
<string>(?:(?<==>)|(?<=[|&]))\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
@ -4495,7 +4495,7 @@
|
|||
<key>name</key>
|
||||
<string>meta.object.type.tsx</string>
|
||||
<key>begin</key>
|
||||
<string>(?<=:)\s*(\{)</string>
|
||||
<string>(?<=[:|&])\s*(\{)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
function a(): { [key: string]: number } | { [key: string]: number } { throw 1 }
|
||||
|
||||
function b(a: { [key: string]: number } | { [key: string]: number }): void { }
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>function a(): { [key: string]: number } | { [key: string]: number } { throw 1 }
|
||||
^^^^^^^^
|
||||
source.ts meta.function.ts storage.type.function.ts
|
||||
^
|
||||
source.ts meta.function.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts keyword.operator.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts
|
||||
^^^^^
|
||||
source.ts meta.function.ts meta.block.ts keyword.control.trycatch.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
|
||||
^^
|
||||
source.ts
|
||||
>
|
||||
^^
|
||||
source.ts
|
||||
>function b(a: { [key: string]: number } | { [key: string]: number }): void { }
|
||||
^^^^^^^^
|
||||
source.ts meta.function.ts storage.type.function.ts
|
||||
^
|
||||
source.ts meta.function.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.indexer.declaration.ts meta.brace.square.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.object.type.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts
|
||||
^^^^
|
||||
source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.return.type.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts
|
||||
^
|
||||
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
|
|
@ -0,0 +1,3 @@
|
|||
function a(): { [key: string]: number } | { [key: string]: number } { throw 1 }
|
||||
|
||||
function b(a: { [key: string]: number } | { [key: string]: number }): void { }
|
Загрузка…
Ссылка в новой задаче