justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
876 stars 63 forks source link

Alias resolution is invalid when using the emitDeclarationOnly option and the *.js extension. #124

Closed pfdgithub closed 2 years ago

pfdgithub commented 2 years ago
// tsconfig.json
{
  "include": ["src"],
  "compilerOptions": {
    "outDir": "dist",
    "baseUrl": "src",
    "paths": {
      "@/*": ["./*"]
    },
    "declaration": true
  }
}
// src/b.ts
const b = "b";
export default b;
// src/a.ts
import b from "@/b";
import bb from "@/b.js"; // <-- *.js extension
export type t = typeof b;
export type tt = typeof bb;
console.log(b, bb);

// cli
tsc && tsc-alias
// dist/a.d.ts
import b from "./b";
import bb from "./b.js"; // <-- relative path
export declare type t = typeof b;
export declare type tt = typeof bb;

// cli
tsc --emitDeclarationOnly && tsc-alias
// dist/a.d.ts
import b from "./b";
import bb from "@/b.js"; // <-- alias path
export declare type t = typeof b;
export declare type tt = typeof bb;
raouldeheer commented 2 years ago

This bug is probably fixed by #123

pfdgithub commented 2 years ago

any release plan?

raouldeheer commented 2 years ago

@pfdgithub Version 1.6.9 just released