mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
33 lines
784 B
TypeScript
33 lines
784 B
TypeScript
// @lib: es2015
|
|
// @strict: true
|
|
// @target: es2015
|
|
|
|
declare function f1<T>(x: T[]): T;
|
|
|
|
let neverArray: never[] = [];
|
|
|
|
let a1 = f1([]); // never
|
|
let a2 = f1(neverArray); // never
|
|
|
|
// Repro from #19576
|
|
|
|
type Comparator<T> = (x: T, y: T) => number;
|
|
|
|
interface LinkedList<T> {
|
|
comparator: Comparator<T>,
|
|
nodes: Node<T>
|
|
}
|
|
|
|
type Node<T> = { value: T, next: Node<T> } | null
|
|
|
|
declare function compareNumbers(x: number, y: number): number;
|
|
declare function mkList<T>(items: T[], comparator: Comparator<T>): LinkedList<T>;
|
|
|
|
const list: LinkedList<number> = mkList([], compareNumbers);
|
|
|
|
// Repro from #19858
|
|
|
|
declare function f2<a>(as1: a[], as2: a[], cmp: (a1: a, a2: a) => number): void;
|
|
f2(Array.from([0]), [], (a1, a2) => a1 - a2);
|
|
f2(Array.from([]), [0], (a1, a2) => a1 - a2);
|