Skip to content

Commit 89a9151

Browse files
committed
fix: expand reserved keywords with more globals
1 parent 6e7765f commit 89a9151

3 files changed

Lines changed: 177 additions & 2 deletions

File tree

.changeset/busy-plums-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**dsl(reserved)**: expand reserved keywords with more globals

packages/openapi-ts/src/ts-dsl/utils/__tests__/name.test.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ describe('safeRuntimeName', () => {
99
name: 'document',
1010
output: 'document_',
1111
},
12+
{
13+
name: 'fetch',
14+
output: 'fetch_',
15+
},
1216
{
1317
name: 'history',
1418
output: 'history_',
@@ -25,6 +29,74 @@ describe('safeRuntimeName', () => {
2529
name: 'window',
2630
output: 'window_',
2731
},
32+
{
33+
name: 'AbortController',
34+
output: 'AbortController_',
35+
},
36+
{
37+
name: 'AbortSignal',
38+
output: 'AbortSignal_',
39+
},
40+
{
41+
name: 'Blob',
42+
output: 'Blob_',
43+
},
44+
{
45+
name: 'CustomEvent',
46+
output: 'CustomEvent_',
47+
},
48+
{
49+
name: 'Event',
50+
output: 'Event_',
51+
},
52+
{
53+
name: 'EventTarget',
54+
output: 'EventTarget_',
55+
},
56+
{
57+
name: 'File',
58+
output: 'File_',
59+
},
60+
{
61+
name: 'FileList',
62+
output: 'FileList_',
63+
},
64+
{
65+
name: 'FileReader',
66+
output: 'FileReader_',
67+
},
68+
{
69+
name: 'FormData',
70+
output: 'FormData_',
71+
},
72+
{
73+
name: 'Headers',
74+
output: 'Headers_',
75+
},
76+
{
77+
name: 'Request',
78+
output: 'Request_',
79+
},
80+
{
81+
name: 'Response',
82+
output: 'Response_',
83+
},
84+
{
85+
name: 'TextDecoder',
86+
output: 'TextDecoder_',
87+
},
88+
{
89+
name: 'TextEncoder',
90+
output: 'TextEncoder_',
91+
},
92+
{
93+
name: 'URL',
94+
output: 'URL_',
95+
},
96+
{
97+
name: 'URLSearchParams',
98+
output: 'URLSearchParams_',
99+
},
28100
{
29101
name: 'console',
30102
output: 'console_',
@@ -33,6 +105,22 @@ describe('safeRuntimeName', () => {
33105
name: 'Array',
34106
output: 'Array_',
35107
},
108+
{
109+
name: 'ArrayBuffer',
110+
output: 'ArrayBuffer_',
111+
},
112+
{
113+
name: 'BigInt',
114+
output: 'BigInt_',
115+
},
116+
{
117+
name: 'Boolean',
118+
output: 'Boolean_',
119+
},
120+
{
121+
name: 'DataView',
122+
output: 'DataView_',
123+
},
36124
{
37125
name: 'Date',
38126
output: 'Date_',
@@ -57,6 +145,10 @@ describe('safeRuntimeName', () => {
57145
name: 'Math',
58146
output: 'Math_',
59147
},
148+
{
149+
name: 'Number',
150+
output: 'Number_',
151+
},
60152
{
61153
name: 'Object',
62154
output: 'Object_',
@@ -65,6 +157,14 @@ describe('safeRuntimeName', () => {
65157
name: 'Promise',
66158
output: 'Promise_',
67159
},
160+
{
161+
name: 'Proxy',
162+
output: 'Proxy_',
163+
},
164+
{
165+
name: 'Reflect',
166+
output: 'Reflect_',
167+
},
68168
{
69169
name: 'RegExp',
70170
output: 'RegExp_',
@@ -73,6 +173,14 @@ describe('safeRuntimeName', () => {
73173
name: 'Set',
74174
output: 'Set_',
75175
},
176+
{
177+
name: 'String',
178+
output: 'String_',
179+
},
180+
{
181+
name: 'Symbol',
182+
output: 'Symbol_',
183+
},
76184
{
77185
name: 'WeakMap',
78186
output: 'WeakMap_',
@@ -281,14 +389,34 @@ describe('safeRuntimeName', () => {
281389
name: 'yield',
282390
output: 'yield_',
283391
},
392+
{
393+
name: '__dirname',
394+
output: '__dirname_',
395+
},
396+
{
397+
name: '__filename',
398+
output: '__filename_',
399+
},
400+
{
401+
name: 'exports',
402+
output: 'exports_',
403+
},
284404
{
285405
name: 'global',
286406
output: 'global_',
287407
},
408+
{
409+
name: 'module',
410+
output: 'module_',
411+
},
288412
{
289413
name: 'process',
290414
output: 'process_',
291415
},
416+
{
417+
name: 'require',
418+
output: 'require_',
419+
},
292420
{
293421
name: 'Buffer',
294422
output: 'Buffer_',

packages/openapi-ts/src/ts-dsl/utils/keywords.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
const browserGlobals = ['document', 'history', 'location', 'navigator', 'window'];
1+
const browserGlobals = [
2+
'document',
3+
'fetch',
4+
'history',
5+
'location',
6+
'navigator',
7+
'window',
8+
'AbortController',
9+
'AbortSignal',
10+
'Blob',
11+
'CustomEvent',
12+
'Event',
13+
'EventTarget',
14+
'File',
15+
'FileList',
16+
'FileReader',
17+
'FormData',
18+
'Headers',
19+
'Request',
20+
'Response',
21+
'TextDecoder',
22+
'TextEncoder',
23+
'URL',
24+
'URLSearchParams',
25+
];
226

327
const javaScriptGlobals = [
428
'console',
529
'Array',
30+
'ArrayBuffer',
31+
'BigInt',
32+
'Boolean',
33+
'DataView',
634
'Date',
735
'Error',
836
'Function',
937
'JSON',
1038
'Map',
1139
'Math',
40+
'Number',
1241
'Object',
1342
'Promise',
43+
'Proxy',
44+
'Reflect',
1445
'RegExp',
1546
'Set',
47+
'String',
48+
'Symbol',
1649
'WeakMap',
1750
'WeakSet',
1851
];
@@ -70,7 +103,16 @@ const javaScriptKeywords = [
70103
'yield',
71104
];
72105

73-
const nodeGlobals = ['global', 'process', 'Buffer'];
106+
const nodeGlobals = [
107+
'__dirname',
108+
'__filename',
109+
'exports',
110+
'global',
111+
'module',
112+
'process',
113+
'require',
114+
'Buffer',
115+
];
74116

75117
const typeScriptKeywords = [
76118
'any',

0 commit comments

Comments
 (0)