Skip to content

Commit 695efa9

Browse files
committed
Merge pull request #2766 from Microsoft/addTestforAsContextualKeyword
Add test to make sure that we don't use "as" as keyword
2 parents 2861fc2 + a15fcf6 commit 695efa9

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [strictModeUseContextualKeyword.ts]
2+
"use strict"
3+
var as = 0;
4+
function foo(as: string) { }
5+
class C {
6+
public as() { }
7+
}
8+
function F() {
9+
function as() { }
10+
}
11+
function H() {
12+
let {as} = { as: 1 };
13+
}
14+
15+
16+
//// [strictModeUseContextualKeyword.js]
17+
"use strict";
18+
var as = 0;
19+
function foo(as) { }
20+
var C = (function () {
21+
function C() {
22+
}
23+
C.prototype.as = function () { };
24+
return C;
25+
})();
26+
function F() {
27+
function as() { }
28+
}
29+
function H() {
30+
var as = ({ as: 1 }).as;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/compiler/strictModeUseContextualKeyword.ts ===
2+
"use strict"
3+
>"use strict" : string
4+
5+
var as = 0;
6+
>as : number, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 1, 3))
7+
>0 : number
8+
9+
function foo(as: string) { }
10+
>foo : (as: string) => void, Symbol(foo, Decl(strictModeUseContextualKeyword.ts, 1, 11))
11+
>as : string, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 2, 13))
12+
13+
class C {
14+
>C : C, Symbol(C, Decl(strictModeUseContextualKeyword.ts, 2, 28))
15+
16+
public as() { }
17+
>as : () => void, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 3, 9))
18+
}
19+
function F() {
20+
>F : () => void, Symbol(F, Decl(strictModeUseContextualKeyword.ts, 5, 1))
21+
22+
function as() { }
23+
>as : () => void, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 6, 14))
24+
}
25+
function H() {
26+
>H : () => void, Symbol(H, Decl(strictModeUseContextualKeyword.ts, 8, 1))
27+
28+
let {as} = { as: 1 };
29+
>as : number, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 10, 9))
30+
>{ as: 1 } : { as: number; }
31+
>as : number, Symbol(as, Decl(strictModeUseContextualKeyword.ts, 10, 16))
32+
>1 : number
33+
}
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict"
2+
var as = 0;
3+
function foo(as: string) { }
4+
class C {
5+
public as() { }
6+
}
7+
function F() {
8+
function as() { }
9+
}
10+
function H() {
11+
let {as} = { as: 1 };
12+
}

0 commit comments

Comments
 (0)