mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Add regression tests
This commit is contained in:
parent
2191b75fc7
commit
63f7029b9a
25
tests/baselines/reference/intersectionTypeInference3.js
Normal file
25
tests/baselines/reference/intersectionTypeInference3.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [intersectionTypeInference3.ts]
|
||||
// Repro from #19682
|
||||
|
||||
type Nominal<Kind extends string, Type> = Type & {
|
||||
[Symbol.species]: Kind;
|
||||
};
|
||||
|
||||
type A = Nominal<'A', string>;
|
||||
|
||||
declare const a: Set<A>;
|
||||
declare const b: Set<A>;
|
||||
|
||||
const c1 = Array.from(a).concat(Array.from(b));
|
||||
|
||||
// Simpler repro
|
||||
|
||||
declare function from<T>(): T[];
|
||||
const c2: ReadonlyArray<A> = from();
|
||||
|
||||
|
||||
//// [intersectionTypeInference3.js]
|
||||
"use strict";
|
||||
// Repro from #19682
|
||||
const c1 = Array.from(a).concat(Array.from(b));
|
||||
const c2 = from();
|
||||
57
tests/baselines/reference/intersectionTypeInference3.symbols
Normal file
57
tests/baselines/reference/intersectionTypeInference3.symbols
Normal file
@ -0,0 +1,57 @@
|
||||
=== tests/cases/conformance/types/intersection/intersectionTypeInference3.ts ===
|
||||
// Repro from #19682
|
||||
|
||||
type Nominal<Kind extends string, Type> = Type & {
|
||||
>Nominal : Symbol(Nominal, Decl(intersectionTypeInference3.ts, 0, 0))
|
||||
>Kind : Symbol(Kind, Decl(intersectionTypeInference3.ts, 2, 13))
|
||||
>Type : Symbol(Type, Decl(intersectionTypeInference3.ts, 2, 33))
|
||||
>Type : Symbol(Type, Decl(intersectionTypeInference3.ts, 2, 33))
|
||||
|
||||
[Symbol.species]: Kind;
|
||||
>Symbol.species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
>species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Kind : Symbol(Kind, Decl(intersectionTypeInference3.ts, 2, 13))
|
||||
|
||||
};
|
||||
|
||||
type A = Nominal<'A', string>;
|
||||
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
|
||||
>Nominal : Symbol(Nominal, Decl(intersectionTypeInference3.ts, 0, 0))
|
||||
|
||||
declare const a: Set<A>;
|
||||
>a : Symbol(a, Decl(intersectionTypeInference3.ts, 8, 13))
|
||||
>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --))
|
||||
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
|
||||
|
||||
declare const b: Set<A>;
|
||||
>b : Symbol(b, Decl(intersectionTypeInference3.ts, 9, 13))
|
||||
>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --))
|
||||
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
|
||||
|
||||
const c1 = Array.from(a).concat(Array.from(b));
|
||||
>c1 : Symbol(c1, Decl(intersectionTypeInference3.ts, 11, 5))
|
||||
>Array.from(a).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>a : Symbol(a, Decl(intersectionTypeInference3.ts, 8, 13))
|
||||
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(intersectionTypeInference3.ts, 9, 13))
|
||||
|
||||
// Simpler repro
|
||||
|
||||
declare function from<T>(): T[];
|
||||
>from : Symbol(from, Decl(intersectionTypeInference3.ts, 11, 47))
|
||||
>T : Symbol(T, Decl(intersectionTypeInference3.ts, 15, 22))
|
||||
>T : Symbol(T, Decl(intersectionTypeInference3.ts, 15, 22))
|
||||
|
||||
const c2: ReadonlyArray<A> = from();
|
||||
>c2 : Symbol(c2, Decl(intersectionTypeInference3.ts, 16, 5))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
|
||||
>from : Symbol(from, Decl(intersectionTypeInference3.ts, 11, 47))
|
||||
|
||||
61
tests/baselines/reference/intersectionTypeInference3.types
Normal file
61
tests/baselines/reference/intersectionTypeInference3.types
Normal file
@ -0,0 +1,61 @@
|
||||
=== tests/cases/conformance/types/intersection/intersectionTypeInference3.ts ===
|
||||
// Repro from #19682
|
||||
|
||||
type Nominal<Kind extends string, Type> = Type & {
|
||||
>Nominal : Nominal<Kind, Type>
|
||||
>Kind : Kind
|
||||
>Type : Type
|
||||
>Type : Type
|
||||
|
||||
[Symbol.species]: Kind;
|
||||
>Symbol.species : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>species : symbol
|
||||
>Kind : Kind
|
||||
|
||||
};
|
||||
|
||||
type A = Nominal<'A', string>;
|
||||
>A : Nominal<"A", string>
|
||||
>Nominal : Nominal<Kind, Type>
|
||||
|
||||
declare const a: Set<A>;
|
||||
>a : Set<Nominal<"A", string>>
|
||||
>Set : Set<T>
|
||||
>A : Nominal<"A", string>
|
||||
|
||||
declare const b: Set<A>;
|
||||
>b : Set<Nominal<"A", string>>
|
||||
>Set : Set<T>
|
||||
>A : Nominal<"A", string>
|
||||
|
||||
const c1 = Array.from(a).concat(Array.from(b));
|
||||
>c1 : Nominal<"A", string>[]
|
||||
>Array.from(a).concat(Array.from(b)) : Nominal<"A", string>[]
|
||||
>Array.from(a).concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
|
||||
>Array.from(a) : Nominal<"A", string>[]
|
||||
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; }
|
||||
>Array : ArrayConstructor
|
||||
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; }
|
||||
>a : Set<Nominal<"A", string>>
|
||||
>concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
|
||||
>Array.from(b) : Nominal<"A", string>[]
|
||||
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; }
|
||||
>Array : ArrayConstructor
|
||||
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: ((v: T, k: number) => U) | undefined, thisArg?: any): U[]; }
|
||||
>b : Set<Nominal<"A", string>>
|
||||
|
||||
// Simpler repro
|
||||
|
||||
declare function from<T>(): T[];
|
||||
>from : <T>() => T[]
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
const c2: ReadonlyArray<A> = from();
|
||||
>c2 : ReadonlyArray<Nominal<"A", string>>
|
||||
>ReadonlyArray : ReadonlyArray<T>
|
||||
>A : Nominal<"A", string>
|
||||
>from() : Nominal<"A", string>[]
|
||||
>from : <T>() => T[]
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
// @strict: true
|
||||
// @target: es2015
|
||||
|
||||
// Repro from #19682
|
||||
|
||||
type Nominal<Kind extends string, Type> = Type & {
|
||||
[Symbol.species]: Kind;
|
||||
};
|
||||
|
||||
type A = Nominal<'A', string>;
|
||||
|
||||
declare const a: Set<A>;
|
||||
declare const b: Set<A>;
|
||||
|
||||
const c1 = Array.from(a).concat(Array.from(b));
|
||||
|
||||
// Simpler repro
|
||||
|
||||
declare function from<T>(): T[];
|
||||
const c2: ReadonlyArray<A> = from();
|
||||
Loading…
x
Reference in New Issue
Block a user