Skip to content

Commit

Permalink
Try a TSConfig with absolute path mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Jun 16, 2024
1 parent 0d8fa22 commit ebacdc1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/specs/resolve-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,25 @@ test("With deprecated moduleResolution: node", () => {
),
).toBe("src/shared/ui/index.ts");
});

test("Alias to absolute paths (for whatever reason)", () => {
const tsCompilerOptions = {
paths: {
"@/*": ["/src/*"],
},
};

function fileExists(path: string) {
console.log(path);
return path === "/src/shared/ui/Button.ts";
}

expect(
resolveImport(
"@/shared/ui/Button",
"src/pages/home/ui/HomePage.tsx",
tsCompilerOptions,
fileExists,
),
).toBe("/src/shared/ui/Button.ts");
});

0 comments on commit ebacdc1

Please sign in to comment.