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

Allow method return types to end with a digit #199

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ repository:
type-annotation:
name: meta.type.annotation.ts
begin: ":"
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z_$])\s*(?=\{)
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z0-9_$])\s*(?=\{)
patterns:
- include: '#expression-operator'
- include: '#type'
Expand Down
2 changes: 1 addition & 1 deletion TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@
<key>begin</key>
<string>:</string>
<key>end</key>
<string>(?=$|[,);\}\]]|//)|(?==[^&gt;])|(?&lt;=[\}&gt;\]\)]|[a-zA-Z_$])\s*(?=\{)</string>
<string>(?=$|[,);\}\]]|//)|(?==[^&gt;])|(?&lt;=[\}&gt;\]\)]|[a-zA-Z0-9_$])\s*(?=\{)</string>
<key>name</key>
<string>meta.type.annotation.ts</string>
<key>patterns</key>
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ repository:
type-annotation:
name: meta.type.annotation.tsx
begin: ":"
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z_$])\s*(?=\{)
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z0-9_$])\s*(?=\{)
patterns:
- include: '#expression-operator'
- include: '#type'
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@
<key>begin</key>
<string>:</string>
<key>end</key>
<string>(?=$|[,);\}\]]|//)|(?==[^&gt;])|(?&lt;=[\}&gt;\]\)]|[a-zA-Z_$])\s*(?=\{)</string>
<string>(?=$|[,);\}\]]|//)|(?==[^&gt;])|(?&lt;=[\}&gt;\]\)]|[a-zA-Z0-9_$])\s*(?=\{)</string>
<key>name</key>
<string>meta.type.annotation.tsx</string>
<key>patterns</key>
Expand Down
5 changes: 4 additions & 1 deletion tests/baselines/FunctionMethodReturnTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@
[29, 59]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts keyword.control.ts
[30, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts storage.modifier.ts
[30, 12]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
[30, 69]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts keyword.control.ts
[30, 69]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts keyword.control.ts
[31, 5]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts storage.modifier.ts
[31, 12]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts entity.name.function.ts
[31, 55]: source.ts meta.declaration.object.ts meta.object.body.ts meta.method.declaration.ts meta.decl.block.ts keyword.control.ts
5 changes: 4 additions & 1 deletion tests/cases/FunctionMethodReturnTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ class TestClass {
^^public ^^testMethodReturnType11(): number | string { ^^return 1 }
^^public ^^testMethodReturnType12(): number | string [] { ^^return }
^^public ^^testMethodReturnType13(): [number, number] | string [] { ^^return [""] }
}
^^public ^^testMethodReturnType14(): EndsWithDigit1 { ^^return 123 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a check to scope of 123 and after 123, like --

^^return ^^123 ^^} 

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

type EndsWithDigit1 = number;