microsoft / microsoft/TypeScript

Invalid synthesized import specifiers on infered types in declarations

Aperta
#56,260 3 commenti 2 reazioni 1 assegnatario Vedi su GitHub

@weswigham ci sta già lavorando.

Dal 30/10/2023.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.