Skip to content

Invalid synthesized import specifiers on infered types in declarationsΒ #56260

Open
@dmaretskyi

Description

@dmaretskyi

πŸ”Ž 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.ts

import { forwardRef, type PropsWithChildren } from "react";

import { type ExportedType } from "@ts-bug/b";

export type Props = PropsWithChildren<{
  // Tile props.
  active?: ExportedType;
}>;

export const Component = forwardRef<HTMLLIElement, Props>(() => {
  return null;
});

// @file @ts-bug/src/index.ts

import { type ExportedType as NaturalExportedType } from './type'

export type ExportedType = NaturalExportedType;

// @file @ts-bug/src/type.ts

export type ExportedType = '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.ts

import { type PropsWithChildren } from "react";
import { type ExportedType } from "@ts-bug/b";
export type Props = PropsWithChildren<{
    active?: ExportedType;
}>;
export declare const Component: 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

Assignees

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