Skip to content

Commit 4c808c4

Browse files
committed
Add more test cases for some other related issues this fixes
1 parent bd49b81 commit 4c808c4

12 files changed

+227
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [indirectGlobalSymbolPartOfObjectType.ts]
2+
export { }
3+
const Symbol = globalThis.Symbol;
4+
[][Symbol.iterator];
5+
6+
//// [indirectGlobalSymbolPartOfObjectType.js]
7+
const Symbol = globalThis.Symbol;
8+
[][Symbol.iterator];
9+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/indirectGlobalSymbolPartOfObjectType.ts ===
2+
export { }
3+
const Symbol = globalThis.Symbol;
4+
>Symbol : Symbol(Symbol, Decl(indirectGlobalSymbolPartOfObjectType.ts, 1, 5))
5+
>globalThis.Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
6+
>globalThis : Symbol(globalThis)
7+
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
8+
9+
[][Symbol.iterator];
10+
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
11+
>Symbol : Symbol(Symbol, Decl(indirectGlobalSymbolPartOfObjectType.ts, 1, 5))
12+
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/indirectGlobalSymbolPartOfObjectType.ts ===
2+
export { }
3+
const Symbol = globalThis.Symbol;
4+
>Symbol : SymbolConstructor
5+
>globalThis.Symbol : SymbolConstructor
6+
>globalThis : typeof globalThis
7+
>Symbol : SymbolConstructor
8+
9+
[][Symbol.iterator];
10+
>[][Symbol.iterator] : () => IterableIterator<undefined>
11+
>[] : undefined[]
12+
>Symbol.iterator : unique symbol
13+
>Symbol : SymbolConstructor
14+
>iterator : unique symbol
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [keyofObjectWithGlobalSymbolIncluded.ts]
2+
const obj = {
3+
[Symbol.species]: Array
4+
};
5+
6+
type Q = keyof typeof obj;
7+
8+
9+
//// [keyofObjectWithGlobalSymbolIncluded.js]
10+
"use strict";
11+
const obj = {
12+
[Symbol.species]: Array
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/compiler/keyofObjectWithGlobalSymbolIncluded.ts ===
2+
const obj = {
3+
>obj : Symbol(obj, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 5))
4+
5+
[Symbol.species]: Array
6+
>[Symbol.species] : Symbol([Symbol.species], Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 13))
7+
>Symbol.species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
8+
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
9+
>species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
10+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
11+
12+
};
13+
14+
type Q = keyof typeof obj;
15+
>Q : Symbol(Q, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 2, 2))
16+
>obj : Symbol(obj, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 5))
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/compiler/keyofObjectWithGlobalSymbolIncluded.ts ===
2+
const obj = {
3+
>obj : { [Symbol.species]: ArrayConstructor; }
4+
>{ [Symbol.species]: Array} : { [Symbol.species]: ArrayConstructor; }
5+
6+
[Symbol.species]: Array
7+
>[Symbol.species] : ArrayConstructor
8+
>Symbol.species : unique symbol
9+
>Symbol : SymbolConstructor
10+
>species : unique symbol
11+
>Array : ArrayConstructor
12+
13+
};
14+
15+
type Q = keyof typeof obj;
16+
>Q : unique symbol
17+
>obj : { [Symbol.species]: ArrayConstructor; }
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [readonlyFloat32ArrayAssignableWithFloat32Array.ts]
2+
function update(b: Readonly<Float32Array>) {
3+
const c = copy(b);
4+
add(c, c);
5+
}
6+
7+
function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
8+
c[0] = a[0] + b[0];
9+
}
10+
11+
function copy(a: Float32Array) {
12+
return new Float32Array(a);
13+
}
14+
15+
//// [readonlyFloat32ArrayAssignableWithFloat32Array.js]
16+
"use strict";
17+
function update(b) {
18+
var c = copy(b);
19+
add(c, c);
20+
}
21+
function add(a, b, c) {
22+
if (c === void 0) { c = a; }
23+
c[0] = a[0] + b[0];
24+
}
25+
function copy(a) {
26+
return new Float32Array(a);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=== tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts ===
2+
function update(b: Readonly<Float32Array>) {
3+
>update : Symbol(update, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 0))
4+
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 16))
5+
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
6+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
7+
8+
const c = copy(b);
9+
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
10+
>copy : Symbol(copy, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 7, 1))
11+
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 16))
12+
13+
add(c, c);
14+
>add : Symbol(add, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 3, 1))
15+
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
16+
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
17+
}
18+
19+
function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
20+
>add : Symbol(add, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 3, 1))
21+
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))
22+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
23+
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 29))
24+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
25+
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 46))
26+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
27+
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))
28+
29+
c[0] = a[0] + b[0];
30+
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 46))
31+
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))
32+
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 29))
33+
}
34+
35+
function copy(a: Float32Array) {
36+
>copy : Symbol(copy, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 7, 1))
37+
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 9, 14))
38+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
39+
40+
return new Float32Array(a);
41+
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
42+
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 9, 14))
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
=== tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts ===
2+
function update(b: Readonly<Float32Array>) {
3+
>update : (b: Readonly<Float32Array>) => void
4+
>b : Readonly<Float32Array>
5+
6+
const c = copy(b);
7+
>c : Float32Array
8+
>copy(b) : Float32Array
9+
>copy : (a: Float32Array) => Float32Array
10+
>b : Readonly<Float32Array>
11+
12+
add(c, c);
13+
>add(c, c) : void
14+
>add : (a: Float32Array, b: Float32Array, c?: Float32Array) => void
15+
>c : Float32Array
16+
>c : Float32Array
17+
}
18+
19+
function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
20+
>add : (a: Float32Array, b: Float32Array, c?: Float32Array) => void
21+
>a : Float32Array
22+
>b : Float32Array
23+
>c : Float32Array
24+
>a : Float32Array
25+
26+
c[0] = a[0] + b[0];
27+
>c[0] = a[0] + b[0] : number
28+
>c[0] : number
29+
>c : Float32Array
30+
>0 : 0
31+
>a[0] + b[0] : number
32+
>a[0] : number
33+
>a : Float32Array
34+
>0 : 0
35+
>b[0] : number
36+
>b : Float32Array
37+
>0 : 0
38+
}
39+
40+
function copy(a: Float32Array) {
41+
>copy : (a: Float32Array) => Float32Array
42+
>a : Float32Array
43+
44+
return new Float32Array(a);
45+
>new Float32Array(a) : Float32Array
46+
>Float32Array : Float32ArrayConstructor
47+
>a : Float32Array
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @target: es6
2+
export { }
3+
const Symbol = globalThis.Symbol;
4+
[][Symbol.iterator];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @target: es6
2+
// @strict: true
3+
const obj = {
4+
[Symbol.species]: Array
5+
};
6+
7+
type Q = keyof typeof obj;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @strict: true
2+
function update(b: Readonly<Float32Array>) {
3+
const c = copy(b);
4+
add(c, c);
5+
}
6+
7+
function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
8+
c[0] = a[0] + b[0];
9+
}
10+
11+
function copy(a: Float32Array) {
12+
return new Float32Array(a);
13+
}

0 commit comments

Comments
 (0)