Skip to content

Commit

Permalink
test: Handle . in conformance test resolver (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
togami2864 authored Aug 13, 2023
1 parent 0130bbe commit e6e4c63
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions crates/stc_ts_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,8 @@ impl ErrorKind {

ErrorKind::RestParamMustBeLast { .. } => 1014,

ErrorKind::ImportFailed { .. } => 2305,

_ => 0,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/stc_ts_type_checker/tests/conformance.pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,7 @@ jsdoc/parseThrowsTag.ts
jsdoc/seeTag1.ts
jsdoc/seeTag2.ts
jsx/tsxEmitSpreadAttribute.ts
moduleResolution/importFromDot.ts
moduleResolution/packageJsonImportsExportsOptionCompat.ts
nonjsExtensions/declarationFileForJsonImport.ts
override/override10.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
]
},
"extra_errors": {
"TS0": 1
"TS2305": 1
},
"extra_error_lines": {
"TS0": [
"TS2305": [
1
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 1,
matched_error: 0,
required_error: 0,
matched_error: 1,
extra_error: 0,
panic: 1,
panic: 0,
}
6 changes: 3 additions & 3 deletions crates/stc_ts_type_checker/tests/tsc-stats.rust-debug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 3502,
matched_error: 6533,
required_error: 3501,
matched_error: 6534,
extra_error: 766,
panic: 74,
panic: 73,
}
20 changes: 20 additions & 0 deletions crates/stc_ts_type_checker/tests/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,26 @@ impl Resolve for TestFileSystem {
return Ok(FileName::Real(filename.into()));
}

if module_specifier == "." {
let path = PathBuf::from(base.to_string());
match path.parent() {
Some(cur_dir) => {
for (name, _) in self.files.iter() {
if format!("{}/index.ts", cur_dir.display()) == *name || format!("{}/index.tsx", cur_dir.display()) == *name {
return Ok(FileName::Real(name.into()));
}
}
}
None => {
for (name, _) in self.files.iter() {
if "index.ts" == *name || "index.tsx" == *name {
return Ok(FileName::Real(name.into()));
}
}
}
}
}

todo!("resolve: current = {:?}; target ={:?}", base, module_specifier);
}
}
Expand Down

0 comments on commit e6e4c63

Please sign in to comment.