Skip to content

Commit

Permalink
Add more test cases for some other related issues this fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jan 29, 2021
1 parent bd49b81 commit 4c808c4
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//// [indirectGlobalSymbolPartOfObjectType.ts]
export { }
const Symbol = globalThis.Symbol;
[][Symbol.iterator];

//// [indirectGlobalSymbolPartOfObjectType.js]
const Symbol = globalThis.Symbol;
[][Symbol.iterator];
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/indirectGlobalSymbolPartOfObjectType.ts ===
export { }
const Symbol = globalThis.Symbol;
>Symbol : Symbol(Symbol, Decl(indirectGlobalSymbolPartOfObjectType.ts, 1, 5))
>globalThis.Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>globalThis : Symbol(globalThis)
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))

[][Symbol.iterator];
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(indirectGlobalSymbolPartOfObjectType.ts, 1, 5))
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=== tests/cases/compiler/indirectGlobalSymbolPartOfObjectType.ts ===
export { }
const Symbol = globalThis.Symbol;
>Symbol : SymbolConstructor
>globalThis.Symbol : SymbolConstructor
>globalThis : typeof globalThis
>Symbol : SymbolConstructor

[][Symbol.iterator];
>[][Symbol.iterator] : () => IterableIterator<undefined>
>[] : undefined[]
>Symbol.iterator : unique symbol
>Symbol : SymbolConstructor
>iterator : unique symbol

13 changes: 13 additions & 0 deletions tests/baselines/reference/keyofObjectWithGlobalSymbolIncluded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [keyofObjectWithGlobalSymbolIncluded.ts]
const obj = {
[Symbol.species]: Array
};

type Q = keyof typeof obj;


//// [keyofObjectWithGlobalSymbolIncluded.js]
"use strict";
const obj = {
[Symbol.species]: Array
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/compiler/keyofObjectWithGlobalSymbolIncluded.ts ===
const obj = {
>obj : Symbol(obj, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 5))

[Symbol.species]: Array
>[Symbol.species] : Symbol([Symbol.species], Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 13))
>Symbol.species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>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, --, --))

};

type Q = keyof typeof obj;
>Q : Symbol(Q, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 2, 2))
>obj : Symbol(obj, Decl(keyofObjectWithGlobalSymbolIncluded.ts, 0, 5))

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=== tests/cases/compiler/keyofObjectWithGlobalSymbolIncluded.ts ===
const obj = {
>obj : { [Symbol.species]: ArrayConstructor; }
>{ [Symbol.species]: Array} : { [Symbol.species]: ArrayConstructor; }

[Symbol.species]: Array
>[Symbol.species] : ArrayConstructor
>Symbol.species : unique symbol
>Symbol : SymbolConstructor
>species : unique symbol
>Array : ArrayConstructor

};

type Q = keyof typeof obj;
>Q : unique symbol
>obj : { [Symbol.species]: ArrayConstructor; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//// [readonlyFloat32ArrayAssignableWithFloat32Array.ts]
function update(b: Readonly<Float32Array>) {
const c = copy(b);
add(c, c);
}

function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
c[0] = a[0] + b[0];
}

function copy(a: Float32Array) {
return new Float32Array(a);
}

//// [readonlyFloat32ArrayAssignableWithFloat32Array.js]
"use strict";
function update(b) {
var c = copy(b);
add(c, c);
}
function add(a, b, c) {
if (c === void 0) { c = a; }
c[0] = a[0] + b[0];
}
function copy(a) {
return new Float32Array(a);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
=== tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts ===
function update(b: Readonly<Float32Array>) {
>update : Symbol(update, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 0))
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 16))
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

const c = copy(b);
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
>copy : Symbol(copy, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 7, 1))
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 0, 16))

add(c, c);
>add : Symbol(add, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 3, 1))
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 1, 9))
}

function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
>add : Symbol(add, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 3, 1))
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 29))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 46))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))

c[0] = a[0] + b[0];
>c : Symbol(c, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 46))
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 13))
>b : Symbol(b, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 5, 29))
}

function copy(a: Float32Array) {
>copy : Symbol(copy, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 7, 1))
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 9, 14))
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

return new Float32Array(a);
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(readonlyFloat32ArrayAssignableWithFloat32Array.ts, 9, 14))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
=== tests/cases/compiler/readonlyFloat32ArrayAssignableWithFloat32Array.ts ===
function update(b: Readonly<Float32Array>) {
>update : (b: Readonly<Float32Array>) => void
>b : Readonly<Float32Array>

const c = copy(b);
>c : Float32Array
>copy(b) : Float32Array
>copy : (a: Float32Array) => Float32Array
>b : Readonly<Float32Array>

add(c, c);
>add(c, c) : void
>add : (a: Float32Array, b: Float32Array, c?: Float32Array) => void
>c : Float32Array
>c : Float32Array
}

function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
>add : (a: Float32Array, b: Float32Array, c?: Float32Array) => void
>a : Float32Array
>b : Float32Array
>c : Float32Array
>a : Float32Array

c[0] = a[0] + b[0];
>c[0] = a[0] + b[0] : number
>c[0] : number
>c : Float32Array
>0 : 0
>a[0] + b[0] : number
>a[0] : number
>a : Float32Array
>0 : 0
>b[0] : number
>b : Float32Array
>0 : 0
}

function copy(a: Float32Array) {
>copy : (a: Float32Array) => Float32Array
>a : Float32Array

return new Float32Array(a);
>new Float32Array(a) : Float32Array
>Float32Array : Float32ArrayConstructor
>a : Float32Array
}
4 changes: 4 additions & 0 deletions tests/cases/compiler/indirectGlobalSymbolPartOfObjectType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: es6
export { }
const Symbol = globalThis.Symbol;
[][Symbol.iterator];
7 changes: 7 additions & 0 deletions tests/cases/compiler/keyofObjectWithGlobalSymbolIncluded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: es6
// @strict: true
const obj = {
[Symbol.species]: Array
};

type Q = keyof typeof obj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @strict: true
function update(b: Readonly<Float32Array>) {
const c = copy(b);
add(c, c);
}

function add(a: Float32Array, b: Float32Array, c: Float32Array = a) {
c[0] = a[0] + b[0];
}

function copy(a: Float32Array) {
return new Float32Array(a);
}

0 comments on commit 4c808c4

Please sign in to comment.