Skip to content

Invalid synthesized import specifiers on infered types in declarations #56260

Description

🔎 Search Terms

"import specifiers in declarations", "import nested files"

🕗 Version & Regression Information

Can reproduce on version 5.2.2 and "next" (5.3.0-dev.20231030).

⏯ Playground Link

No response

💻 Code

// @file a.tsimport{forwardRef,typePropsWithChildren}from"react";import{typeExportedType}from"@ts-bug/b";exporttypeProps=PropsWithChildren<{// Tile props.active?: ExportedType;}>;exportconstComponent=forwardRef<HTMLLIElement,Props>(()=>{returnnull;});// @file@ts-bug/src/index.tsimport{typeExportedTypeasNaturalExportedType}from'./type'exporttypeExportedType=NaturalExportedType;// @file@ts-bug/src/type.tsexporttypeExportedType='overlay'|'rearrange'|'origin'|'destination';

🙁 Actual behavior

The generated declarations for a.ts contain an invalid import into one of the nested declaration files instead of using the main package export.

// @file a.d.tsimport{typePropsWithChildren}from"react";import{typeExportedType}from"@ts-bug/b";exporttypeProps=PropsWithChildren<{active?: ExportedType;}>;exportdeclareconstComponent: import("react").ForwardRefExoticComponent<{active?: import("b/dist/types/src/type").ExportedType|undefined;}&{children?: import("react").ReactNode;}&import("react").RefAttributes<HTMLLIElement>>;//# sourceMappingURL=index.d.ts.map

🙂 Expected behavior

The declarations should use the main package export.

 active?: import("@ts-bug/b").ExportedType|undefined;

Additional information about the issue

Repoduction repo:
https://github.com/dmaretskyi/ts-bug

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions