Skip to content

Unexpected behavior in import a local package. #182

@zongc1001

Description

@zongc1001

Reproduce repo

https://github.com/zongc1001/exposes-dts-poc.git

  • tsconfig.json:
{
  ...,
  "compilerOptions": {
     ...,
    "baseUrl": ".",
    "paths": {
      "@monospace/openapp": ["packages/openapp"],
      "@monospace/openapp/*": ["packages/openapp/*"],
      "@monospace/*": ["packages/*"],
    },
    "plugins": [
      {
        "transform": "typescript-transform-paths",
        "afterDeclarations": true,
      },
    ]
  },
  "include": [
    "expose/expose.ts",
  ],
}

Reproduce step

  1. pnpm install
  2. pnpm build:alias
  3. Check the output file types/packages/openapp/src/deep/import-other-mono.d.ts:
import { ModalProps } from "../../../../../packages/components";  // Wrong. Point to the source ts file.
import { PopoverProps } from "../../../components/src/Popover"; // Correct. Point to the output d.ts file.
export type SomeComp = {
    modalProps: ModalProps;
    popoverProps: PopoverProps;
};
  1. And the source file:
import { Modal, ModalProps } from "@monospace/components";
import { Popover, PopoverProps } from "@monospace/components/src/Popover";

console.log(Modal, Popover);

export type SomeComp = {
  modalProps: ModalProps,
  popoverProps: PopoverProps,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions