Skip to content

declaration emit uses absolute path when inferring type #54743

@eps1lon

Description

@eps1lon

Bug Report

🔎 Search Terms

emit declaration path
Similar to #38111 but #38111 uses the same source for import whereas the repro here uses different import sources.

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

⏯ Playground Link

Repro: https://github.com/eps1lon/ts-proj-references-abs-path-repro
Spans multiple files which is not suitable for Playground

💻 Code

useDialogNavigation.ts (emits expected package identifier import)

declare function useCallback<T extends Function>(callback: T): T;

import { navigateBack, close as _close } from "@klapp/navigation";

export const useDialogNavigation = () => {
  const close = useCallback(() => {
    return _close(null as any);
  });

  const back = useCallback(() => {
    return navigateBack(null as any);
  });

// expected
// back: () => import("@klapp/navigation").MightReturnComponentId
  return { back, close };
};

// useNavigationEvents.ts (emits unexpected path import)

import { useDialogNavigation } from "./useDialogNavigation";
export const useNavigationEvents = () => {
  const { back, close } = useDialogNavigation();

  return {
// unexpected
// back: () => import("packages/navigation").MightReturnComponentId
    back,
    close,
  };
};

// tsconfig.json

{
  "extends": "../../tsconfig.base.json",
  "include": ["./**/*"]
}

// tsconfig.base.json

{
  "compilerOptions": {
    "baseUrl": "./",
    "declaration": true,
    "moduleResolution": "NodeNext",
    "noEmit": false,
    "outDir": "./types/dist",
    "rootDir": ".",
    "strict": true
  }
}

🙁 Actual behavior

One file uses import("@klapp/navigation") while another uses import("packages/navigation")

🙂 Expected behavior

Both use import("@klapp/navigation")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions