tsdjs / tsd

Check TypeScript type definitions
MIT License
2.4k stars 67 forks source link

expectType does not work for same enums from two different namespaces #219

Open maximzavadskiy opened 3 months ago

maximzavadskiy commented 3 months ago

Suppose we have the same enum type in our core code and in our lib - one lib(main.ts) and one in (lib.ts). expectType does not work as expected here.

// main.ts
export enum Foo {
  "A" = "A"
}

// lib.ts
export enum Foo {
  "A" = "A"
}

// test.test-d.ts
import {Foo} from "./main"
import {Foo as Foo2} from "./lib"

const aFoo: Foo = Foo.A
const _aFoo2: Foo2 = aFoo // Assignment - OK

expectType<Foo2>(aFoo) // Expected to pass, but gives error `Parameter type Foo is not identical to argument type Foo.