Skip to content

Commit f26d03b

Browse files
committed
fix: add dot alias test case
1 parent da3c6dd commit f26d03b

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'bar'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "index";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./tsconfigs/tsconfig.dev"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "../src",
4+
"paths": {
5+
".": ["."]
6+
}
7+
}
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./tsconfig.base"
3+
}

src/tests/tsconfig_paths.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ fn test_paths_nested_base() {
297297
}
298298
}
299299

300+
#[test]
301+
fn test_paths_dot_alias() {
302+
let f = super::fixture_root().join("tsconfig");
303+
let f2 = f.join("cases").join("dot-alias");
304+
305+
#[rustfmt::skip]
306+
let pass = [
307+
(f2.join("test"), "tsconfig.json", "index", f2.join("src/index.ts")),
308+
];
309+
310+
for (dir, tsconfig, request, expected) in pass {
311+
let resolver = Resolver::new(ResolveOptions {
312+
tsconfig: Some(TsconfigOptions {
313+
config_file: dir.parent().unwrap().join(tsconfig),
314+
references: TsconfigReferences::Auto,
315+
}),
316+
..ResolveOptions::default().with_extension(String::from(".ts"))
317+
});
318+
let resolved_path = resolver.resolve(&dir, request).map(|f| f.full_path());
319+
assert_eq!(resolved_path, Ok(expected), "{request} {tsconfig} {dir:?}");
320+
}
321+
}
322+
300323
#[cfg(not(target_os = "windows"))] // MemoryFS's path separator is always `/` so the test will not pass in windows.
301324
mod windows_test {
302325
use std::{

0 commit comments

Comments
 (0)