Skip to content

Commit

Permalink
fix: set default baseUrl, support correct paths resolution (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Feb 18, 2024
1 parent 0317580 commit 583b2e4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/twoslash/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function createTwoslasher(createOptions: CreateTwoslashOptions = {}): Two
extension: typesToExtension(extension),
compilerOptions: {
...defaultCompilerOptions,
baseUrl: fsRoot,
...createOptions.compilerOptions,
...options.compilerOptions,
},
Expand Down
9 changes: 9 additions & 0 deletions packages/twoslash/test/fixtures/tests/custom-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @paths: {"@foo": ["./foo"]}
// @filename: foo.ts
export const a = 1

// @filename: bar.ts
import { a } from "@foo"

const b = a + 1
// ^?
63 changes: 63 additions & 0 deletions packages/twoslash/test/results/tests/custom-paths.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 583b2e4

Please sign in to comment.