Skip to content

5.4 omits certain import * as ... statements from .d.tsΒ #57861

Closed

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

https://www.typescriptlang.org/play?target=99&moduleResolution=99&module=199&ts=5.4.2&useDefineForClassFields=true&noUnusedLocals=true&noUnusedParameters=true&preserveConstEnums=true&importHelpers=true&experimentalDecorators=true&emitDecoratorMetadata=true&jsx=0&isolatedModules=true&verbatimModuleSyntax=true&pretty=true&noErrorTruncation=true&noFallthroughCasesInSwitch=true&noImplicitOverride=true&noPropertyAccessFromIndexSignature=true&useUnknownInCatchVariables=true#code/JYWwDg9gTgLgBAKjgQwM5wIJjgMyhEOAchzAFoZUB6LMAGwE8iBuAKFElkRXQFFd8hEuUpVewGAAsAplBbtw0eEjRwAkgHkBBYqQrVN8jku6rN07UL2jN4qbKOKuMBmAsr0miJd0iDGjTAYYAgAO0dOeABvOABjMNQYADFkOlRpABo4hJgAFSgAV0zcOggAdyywYDc4AF8fYX0qHALQ2OCwiJMXGpiAGWQALwY6hutqFraO8LZWaQAPSO48HUabDTsZOVmFpfjQxMsAOQK6OmQAIzppAC44AB5eAD4AClu4AeHHp4BKOABeJ4PDCvc53DB-QHqDTSAB0tgkW0eWSOYROZ0u13uIKB-1YcDgb0hQJe52JhOJ+IJcF4sJWIHR5yu0jeLx+P1JyB+O0WJn2h3pmkC0zu3xeVLRYXenwY3wyrHJ2NeOGQdy88ICQRCoSV5PMGs2smRmFxhMloWkeo0sJAyDAL1p9OF2pe5st3NYc15XH58EKoQBD14WRBL2AaphBsRRuDJp+d1phqgxpBAKBwDZPL2OTg-oAqqFtaLYxgsgAhV5UnB3N4J8ll+UEgDmNdVmHr8vJLxVEbhCPsyZLvzTcDLge7WSb5JwpTKL31F1AdoncCnWX1MAgBe1WReMHJMDZHq92YO8HSAEcim1pABlQNYWGX6+xO-zyO0OjAWLIYIAN2kAAFZAoGPXY+RzJtpBgDQoFySR8DKAEqTFTd4MQzF3lrGlyV4KB8FAtMUNDHtoT7DZo0HENfnBIjqTgKo3HFeiCX9bsuUbFjaSgmCoF4NJpBTV4iRHKIqRYuApEQySIHQ8pMKJNgJNqH5OIJMDvXgX04AWYBElQYtqO7VtwXJC4IAga5kFCLtSP1fskSHMyLKsgN-kJHBKVY1ptzCF5fRSASsk8rMILPOA9L6aQcBgQyTXY3sowHITnMs6RrMDfNCz8318iKLIAtSdINNPQ49IAJWAJtJFioMjLsyMHJjajUtczKfOy0J-JyQL0gKnI8stUKfRzGA7SimK4tDKsa3eXhyT-CBgAAE07EcErIpLHJakd7Io5Kh3HTy6M220wAmw8XnmckxPonAro9eioGggooADeYlLqD0gA

πŸ’» 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions