Skip to content

Commit 47e42b5

Browse files
Allow disabling any global with --use (#1300)
1 parent 2937480 commit 47e42b5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/program.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,10 @@ export class Program extends DiagnosticEmitter {
12651265
let alias = unchecked(_keys[i]);
12661266
let name = changetype<string>(globalAliases.get(alias));
12671267
assert(name != null);
1268-
if (!name.length) continue; // explicitly disabled
1268+
if (!name.length) {
1269+
this.elementsByName.delete(alias);
1270+
continue;
1271+
}
12691272
let firstChar = name.charCodeAt(0);
12701273
if (firstChar >= CharCode._0 && firstChar <= CharCode._9) {
12711274
this.registerConstantInteger(alias, Type.i32, i64_new(<i32>parseInt(name, 10)));

tests/compiler/empty-use.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"asc_flags": [
3+
"--runtime none",
4+
"--use Date="
5+
],
6+
"stderr": [
7+
"TS2304: Cannot find name 'Date'.",
8+
"EOF"
9+
]
10+
}

tests/compiler/empty-use.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Date.now();
2+
3+
ERROR("EOF");

0 commit comments

Comments
 (0)