Repository navigation
5.4 omits certain import * as ... statements from .d.tsΒ #57861
Description
π Search Terms
omit, emit, 5.4, import, import *
π Version & Regression Information
- This emits incorrect .d.ts
- This changed between versions 5.3 and 5.4
- This still breaks in typescript@next
β― Playground Link
π» Code
// io-either.ts
import * as E from 'fp-ts/Either';
import * as IOe from 'fp-ts/IOEither';
export declare const run: <E, A>(i: IOe.IOEither<E, A>) => E.Either<E, A>;π Actual behavior
// io-either.d.ts
import * as IOe from 'fp-ts/IOEither';
export declare const run: <E, A>(i: IOe.IOEither<E, A>) => E.Either<E, A>;The import * as E from 'fp-ts/Either' statement is missing in the .d.ts, leading to run having a return type of effectively any.
π Expected behavior
// io-either.d.ts
import * as E from 'fp-ts/Either';
import * as IOe from 'fp-ts/IOEither';
export declare const run: <E, A>(i: IOe.IOEither<E, A>) => E.Either<E, A>;The import * as E ... statement should be in the emitted .d.ts, otherwise E.Either<E, A> cannot possibly be resolved.
Additional information about the issue
Locally I was able to produce a working .d.ts using 5.3.3, but not using 5.4.2. Unfortunately I wasn't able to produce a correct .d.ts in the playground, but at least there the output is consistently incorrect.
I am aware that in the scope of => E.Either<E, A> there are two symbols called E, one referring to the type parameter, the other referring to the module import. when importing and using this .ts directly, everything works as expected, so TS seems to be able to differentiate between these two just fine.
However, I was able to workaround this issue by renaming either of the two symbols, so they don't "clash".
Activity
jakebailey commentedon Mar 20, 2024
This isn't a super minimal repro; can you try https://www.npmjs.com/package/every-ts to bisect this down between the two releases?
ammut commentedon Mar 21, 2024
I tried it, but every-ts kept crashing on my machine. Will try again.
ammut commentedon Mar 21, 2024
every-tsfound:ammut commentedon Mar 21, 2024
I made a smaller example here.
the '.D.TS' output is clearly missing an import statement - that's the gist of the Bug I'm reporting here. The missing import statement immediately appears, when either
Eis renamed.However, I'm not able to create a Playground project where the '.D.TS' output is correct despite the name conflict. I've only been able to achieve that when working locally, using TS v5.3.3 (or any commit before the abovementioned First Bad Commit, really).