-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
reservedNames.ts
73 lines (69 loc) · 1.55 KB
/
reservedNames.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { INTEROP_DEFAULT_VARIABLE } from './variableNames';
export interface NameCollection {
[name: string]: true;
}
export const RESERVED_NAMES: NameCollection = Object.assign(Object.create(null), {
await: true,
break: true,
case: true,
catch: true,
class: true,
const: true,
continue: true,
debugger: true,
default: true,
delete: true,
do: true,
else: true,
enum: true,
eval: true,
export: true,
extends: true,
finally: true,
for: true,
function: true,
if: true,
implements: true,
import: true,
in: true,
instanceof: true,
interface: true,
let: true,
new: true,
null: true,
package: true,
private: true,
protected: true,
public: true,
return: true,
static: true,
super: true,
switch: true,
throw: true,
try: true,
typeof: true,
undefined: true,
var: true,
void: true,
while: true,
with: true,
yield: true
});
const NONE: NameCollection = {};
const EXPORTS: NameCollection = { exports: true };
export const RESERVED_NAMES_BY_FORMAT: {
[format: string]: { forbiddenNames: NameCollection; formatGlobals: NameCollection };
} = {
amd: { formatGlobals: EXPORTS, forbiddenNames: RESERVED_NAMES },
cjs: {
forbiddenNames: RESERVED_NAMES,
formatGlobals: { exports: true, module: true, [INTEROP_DEFAULT_VARIABLE]: true }
},
es: { formatGlobals: NONE, forbiddenNames: RESERVED_NAMES },
iife: { formatGlobals: EXPORTS, forbiddenNames: RESERVED_NAMES },
system: {
forbiddenNames: Object.assign(Object.create(null), RESERVED_NAMES, EXPORTS),
formatGlobals: NONE
},
umd: { formatGlobals: EXPORTS, forbiddenNames: RESERVED_NAMES }
};