Skip to content

Commit

Permalink
Fix the function expression overload
Browse files Browse the repository at this point in the history
Fixes #663
  • Loading branch information
sheetalkamat committed Sep 4, 2018
1 parent 06edc77 commit 0aea7e0
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ repository:
'2': { name: storage.type.function.ts }
'3': { name: keyword.generator.asterisk.ts }
'4': { name: meta.definition.function.ts entity.name.function.ts }
end: (?<=\})
end: (?=;)|(?<=\})
patterns:
- include: '#function-name'
- include: '#single-line-comment-consuming-line-ending'
Expand Down
2 changes: 1 addition & 1 deletion TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;=\})</string>
<string>(?=;)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;=\})</string>
<string>(?=;)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
Expand Down
114 changes: 114 additions & 0 deletions tests/baselines/Issue663.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
original file
-----------------------------------
export default function foo(): void;
export default function foo(bar: string): void;
export default function foo(bar?: string): void
{ }
-----------------------------------

Grammar: TypeScript.tmLanguage
-----------------------------------
>export default function foo(): void;
^^^^^^
source.ts meta.export.default.ts keyword.control.export.ts
^
source.ts meta.export.default.ts
^^^^^^^
source.ts meta.export.default.ts keyword.control.default.ts
^
source.ts meta.export.default.ts
^^^^^^^^
source.ts meta.export.default.ts meta.function.expression.ts storage.type.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts
^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.definition.function.ts entity.name.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts keyword.operator.type.annotation.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts
^^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts support.type.primitive.ts
^
source.ts punctuation.terminator.statement.ts
>export default function foo(bar: string): void;
^^^^^^
source.ts meta.export.default.ts keyword.control.export.ts
^
source.ts meta.export.default.ts
^^^^^^^
source.ts meta.export.default.ts keyword.control.default.ts
^
source.ts meta.export.default.ts
^^^^^^^^
source.ts meta.export.default.ts meta.function.expression.ts storage.type.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts
^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.definition.function.ts entity.name.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts keyword.operator.type.annotation.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts
^^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts support.type.primitive.ts
^
source.ts punctuation.terminator.statement.ts
>export default function foo(bar?: string): void
^^^^^^
source.ts meta.export.default.ts keyword.control.export.ts
^
source.ts meta.export.default.ts
^^^^^^^
source.ts meta.export.default.ts keyword.control.default.ts
^
source.ts meta.export.default.ts
^^^^^^^^
source.ts meta.export.default.ts meta.function.expression.ts storage.type.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts
^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.definition.function.ts entity.name.function.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts keyword.operator.optional.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts
^^^^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts keyword.operator.type.annotation.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts
^^^^
source.ts meta.export.default.ts meta.function.expression.ts meta.return.type.ts support.type.primitive.ts
>{ }
^
source.ts meta.export.default.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.export.default.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts
4 changes: 4 additions & 0 deletions tests/cases/Issue663.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function foo(): void;
export default function foo(bar: string): void;
export default function foo(bar?: string): void
{ }

0 comments on commit 0aea7e0

Please sign in to comment.