Description
openedon Mar 20, 2024
π 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".