Skip to content

Commit 3b1a0dc

Browse files
committed
added missing reserved keywords
1 parent 55b8dc7 commit 3b1a0dc

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/Langs/TypeScript.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class TypeScript
2121
protected static $safeImports = [];
2222

2323
public const RESERVED_KEYWORDS = [
24+
'await',
2425
'break',
2526
'case',
2627
'catch',
@@ -32,19 +33,28 @@ class TypeScript
3233
'delete',
3334
'do',
3435
'else',
36+
'enum',
3537
'export',
3638
'extends',
3739
'false',
3840
'finally',
3941
'for',
4042
'function',
4143
'if',
44+
'implements',
4245
'import',
4346
'in',
4447
'instanceof',
48+
'interface',
49+
'let',
4550
'new',
4651
'null',
52+
'package',
53+
'private',
54+
'protected',
55+
'public',
4756
'return',
57+
'static',
4858
'super',
4959
'switch',
5060
'this',
@@ -56,6 +66,7 @@ class TypeScript
5666
'void',
5767
'while',
5868
'with',
69+
'yield',
5970
];
6071

6172
public static function literalUnion(string $type, array|Collection $values): VariableBuilder

tests/DisallowedMethodNames.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import DisallowedMethodNameController, {
66
import method2fa from "../workbench/resources/js/wayfinder/routes/2fa";
77
import defaultMethod from "../workbench/resources/js/wayfinder/routes/default";
88
import disallowed from "../workbench/resources/js/wayfinder/routes/disallowed";
9+
import publicMethod from "../workbench/resources/js/wayfinder/routes/public";
10+
import staticMethod from "../workbench/resources/js/wayfinder/routes/static";
911

1012
test("will append `method` to invalid methods", () => {
1113
expect(method404.url()).toBe("/disallowed/404");
@@ -31,3 +33,15 @@ test("will properly handle reserved JS words", () => {
3133
"/disallowed/default"
3234
);
3335
});
36+
37+
test("will properly handle strict mode reserved JS words", () => {
38+
expect(publicMethod.assets.url()).toBe("/disallowed/public");
39+
expect(DisallowedMethodNameController["public"].url()).toBe(
40+
"/disallowed/public"
41+
);
42+
43+
expect(staticMethod.files.url()).toBe("/disallowed/static");
44+
expect(DisallowedMethodNameController["static"].url()).toBe(
45+
"/disallowed/static"
46+
);
47+
});

workbench/routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
Route::get('/disallowed/404', [DisallowedMethodNameController::class, '404'])->name('disallowed.404');
9595
Route::get('/disallowed/2fa', [DisallowedMethodNameController::class, '2fa'])->name('2fa.disallowed');
9696
Route::get('/disallowed/default', [DisallowedMethodNameController::class, 'default'])->name('default.login');
97+
Route::get('/disallowed/public', [DisallowedMethodNameController::class, 'public'])->name('public.assets');
98+
Route::get('/disallowed/static', [DisallowedMethodNameController::class, 'static'])->name('static.files');
9799
Route::get('/navigation-items/{item}/options', [NavigationItemController::class, 'options']);
98100

99101
Route::get('/anonymous-middleware', [AnonymousMiddlewareController::class, 'show']);

0 commit comments

Comments
 (0)