microsoft / microsoft/TypeScript
Invalid synthesized import specifiers on infered types in declarations
Open
@weswigham is already working on this.
Since Oct 30, 2023.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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.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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.