Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test for redeclaration of NoInfer<T>
  • Loading branch information
ahejlsberg committed Jan 9, 2024
commit 79f851315d6bfddc5f5ef703ec7df71b4adff52f
24 changes: 24 additions & 0 deletions tests/baselines/reference/noInferRedeclaration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] ////

//// [a.ts]
export const f = <T>(x: T, y: NoInfer<T>) => x;

//// [b.ts]
import { f } from "./a";

type NoInfer<T> = T & number;

export const g = f;


//// [a.js]
export const f = (x, y) => x;
//// [b.js]
import { f } from "./a";
export const g = f;


//// [a.d.ts]
export declare const f: <T>(x: T, y: NoInfer<T>) => T;
//// [b.d.ts]
export declare const g: <T>(x: T, y: globalThis.NoInfer<T>) => T;
26 changes: 26 additions & 0 deletions tests/baselines/reference/noInferRedeclaration.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] ////

=== a.ts ===
export const f = <T>(x: T, y: NoInfer<T>) => x;
>f : Symbol(f, Decl(a.ts, 0, 12))
>T : Symbol(T, Decl(a.ts, 0, 18))
>x : Symbol(x, Decl(a.ts, 0, 21))
>T : Symbol(T, Decl(a.ts, 0, 18))
>y : Symbol(y, Decl(a.ts, 0, 26))
>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(a.ts, 0, 18))
>x : Symbol(x, Decl(a.ts, 0, 21))

=== b.ts ===
import { f } from "./a";
>f : Symbol(f, Decl(b.ts, 0, 8))

type NoInfer<T> = T & number;
>NoInfer : Symbol(NoInfer, Decl(b.ts, 0, 24))
>T : Symbol(T, Decl(b.ts, 2, 13))
>T : Symbol(T, Decl(b.ts, 2, 13))

export const g = f;
>g : Symbol(g, Decl(b.ts, 4, 12))
>f : Symbol(f, Decl(b.ts, 0, 8))

21 changes: 21 additions & 0 deletions tests/baselines/reference/noInferRedeclaration.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] ////

=== a.ts ===
export const f = <T>(x: T, y: NoInfer<T>) => x;
>f : <T>(x: T, y: NoInfer<T>) => T
><T>(x: T, y: NoInfer<T>) => x : <T>(x: T, y: NoInfer<T>) => T
>x : T
>y : NoInfer<T>
>x : T

=== b.ts ===
import { f } from "./a";
>f : <T>(x: T, y: globalThis.NoInfer<T>) => T

type NoInfer<T> = T & number;
>NoInfer : NoInfer<T>

export const g = f;
>g : <T>(x: T, y: globalThis.NoInfer<T>) => T
>f : <T>(x: T, y: globalThis.NoInfer<T>) => T

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @strict: true
// @declaration: true
// @target: esnext

// @filename: a.ts
export const f = <T>(x: T, y: NoInfer<T>) => x;

// @filename: b.ts
import { f } from "./a";

type NoInfer<T> = T & number;

export const g = f;