Closed
Description
Bug Report
π Search Terms
- import omit
- invalid typedef
π Version & Regression Information
Not sure when does it start but I discovered with 4.8.4 and still seems to occur with 4.9.3 and 5.0.0-dev.20221116
β― Playground Link
This can not be reproduced on playground as it requires multiple files. Instead I've created a repo with all the files
https://github.com/Gozala/ts-import-omit-bug
π» Code
bug.js
import * as B from "./box.js"
import * as W from "./wrap.js"
/**
* @template C
* @param {C} source
* @returns {W.Wrap<C>}
*/
const wrap = source => {
throw source
}
/**
* @returns {B.Box<number>}
*/
const box = (n = 0) => ({ unbox: () => n })
export const bug = wrap({ n: box(1) })
box.ts
export interface Box<T> {
unbox(): T
}
wrap.ts
export type Wrap<C> = {
[K in keyof C]: { wrapped: C[K] }
}
π Actual behavior
On incremental build TS generates invalid bug.d.ts
file, which seems to omit B
import.
export const bug: W.Wrap<{
n: B.Box<number>;
}>;
import * as W from "./wrap.js";
E.g you could trigger incremental build by running npm test
in linked repo or by running following command
tsc --build && echo \"\\nexport let a = 1\" >> ./src/bug.js && tsc --bulid
π Expected behavior
It should always produce correct typedefs like
export const bug: W.Wrap<{
n: B.Box<number>;
}>;
import * as B from "./box.js";
import * as W from "./wrap.js";