Hi, im getting TS error code (4060) in the following playground example.
// @strict: true
// @target: ES2024
// @module: NodeNext
// @moduleResolution: NodeNext
// @filename: a.ts
export interface A {
readonly prop: number
}
export function isInstance(v: unknown): v is A {
return !!v && typeof v === "object" && "prop" in v;
}
export * as A from "./a.js"
// @filename: entry.ts
import { A } from "./a.js"
// using A as a type works as expected
function f(a: A): number {
return a.prop;
}
// using A as a namespace also works as expected
console.log(A.isInstance(13));
Could someone please help me in understanding why the error happens?
Interestingly, if I try this in my codebase and run tsc, the code does what i want: VSCode complains about the same error, but doesn't let me "ts-ignore" it
Create reproductions of issues with TypeScript