Skip to content

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
sunrabbit123 committed Oct 10, 2023
1 parent aa82b6d commit 0488618
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 120 deletions.
14 changes: 12 additions & 2 deletions crates/stc_ts_file_analyzer/src/analyzer/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Analyzer<'_, '_> {
let dep_id = match dep_id {
Some(v) => v,
None => {
dbg!(&base, dst);
self.storage.report(ErrorKind::ModuleNotFound { span }.into());

return (ctxt, Type::any(span, Default::default()));
Expand All @@ -40,6 +41,8 @@ impl Analyzer<'_, '_> {
let data = match self.data.imports.get(&(ctxt, dep_id)).cloned() {
Some(v) => v,
None => {
dbg!(&base, dst);

self.storage.report(ErrorKind::ModuleNotFound { span }.into());

return (ctxt, Type::any(span, Default::default()));
Expand Down Expand Up @@ -79,19 +82,26 @@ impl Analyzer<'_, '_> {
if self.config.is_builtin {
return;
}

#[inline]
fn is_relative_path(path: &str) -> bool {
path.starts_with("./") || path.starts_with("../")
}
// We first load non-circular imports.
let imports = ImportFinder::find_imports(&self.comments, module_spans, &self.storage, items);

let loader = self.loader;
let mut normal_imports = vec![];
for (ctxt, import) in imports {
let span = import.span;

let base = self.storage.path(ctxt);
let dep_id = self.loader.module_id(&base, &import.src);
let dep_id = match dep_id {
Some(v) => v,
None => {
_ if !is_relative_path(&import.src) => {
continue;
}
_ => {
self.storage.report(ErrorKind::ModuleNotFound { span }.into());
continue;
}
Expand Down
17 changes: 17 additions & 0 deletions crates/stc_ts_type_checker/tests/conformance.pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Symbols/ES5SymbolProperty6.ts
Symbols/ES5SymbolProperty7.ts
Symbols/ES5SymbolType1.ts
ambient/ambientDeclarations.ts
ambient/ambientDeclarationsExternal.ts
ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts
ambient/ambientEnumDeclaration1.ts
ambient/ambientEnumDeclaration2.ts
Expand Down Expand Up @@ -1016,10 +1017,14 @@ es6/spread/iteratorSpreadInCall2.ts
es6/spread/iteratorSpreadInCall3.ts
es6/spread/iteratorSpreadInCall4.ts
es6/spread/iteratorSpreadInCall5.ts
es6/tedirectives/ts-expect-error-nocheck.ts
es6/templates/taggedTemplateStrindirectives/ts-expect-error-nocheck.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01_ES6.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.tsdirectives/ts-expect-error-nocheck.ts
es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02directives/ts-expect-error-nocheck.ts
es6/templates/taggedTemplateStringsPldirectives/ts-expect-error-nocheck.ts
es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts
es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts
Expand Down Expand Up @@ -1123,6 +1128,8 @@ es6/templates/templateStringWhitespaceEscapes2_ES6.ts
es6/templates/templateStringWithBackslashEscapes01.ts
es6/templates/templateStringWithBackslashEscapes01_ES6.ts
es6/templates/templateStringWithCommentsInArrowFunction.ts
es6/templates/templateStringWithE
es6/templates/templateStringWithEdirectives/ts-expect-error-nocheck.ts
es6/templates/templateStringWithEmbeddedAddition.ts
es6/templates/templateStringWithEmbeddedAdditionES6.ts
es6/templates/templateStringWithEmbeddedArray.ts
Expand Down Expand Up @@ -1163,6 +1170,7 @@ es6/templates/templateStringWithEmptyLiteralPortions.ts
es6/templates/templateStringWithEmptyLiteralPortionsES6.ts
es6/templates/templateStringWithOpenCommentInStringPortion.ts
es6/templates/templateStringWithOpenCommentInStringPortionES6.ts
es6/templates/templateStringWithPdirectives/ts-expect-error-nocheck.ts
es6/templates/templateStringWithPropertyAccess.ts
es6/templates/templateStringWithPropertyAccessES6.ts
es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts
Expand Down Expand Up @@ -1683,6 +1691,7 @@ externalModules/exportAssignImportedIdentifier.ts
externalModules/exportAssignTypes.ts
externalModules/exportAssignmentAndDeclaration.ts
externalModules/exportAssignmentGenericType.ts
externalModules/exportAssignmentOfExportNamespaceWithDefault.ts
externalModules/exportAssignmentTopLevelIdentifier.ts
externalModules/exportClassNameWithObjectAMD.ts
externalModules/exportClassNameWithObjectCommonJS.ts
Expand Down Expand Up @@ -1814,6 +1823,7 @@ jsdoc/seeTag1.ts
jsdoc/seeTag2.ts
jsdoc/typeParameterExtendsUnionConstraintDistributed.ts
jsx/tsxEmitSpreadAttribute.ts
jsx/tsxReactEmitSpreadAttribute.ts
moduleResolution/importFromDot.ts
moduleResolution/packageJsonImportsExportsOptionCompat.ts
nonjsExtensions/declarationFileForJsonImport.ts
Expand Down Expand Up @@ -2031,6 +2041,7 @@ parser/ecmascript5/Protected/Protected3.ts
parser/ecmascript5/Protected/Protected5.ts
parser/ecmascript5/Protected/Protected8.ts
parser/ecmascript5/Protected/Protected9.ts
parser/ecmascript5/RegressionTests/parser509534.ts
parser/ecmascript5/RegressionTests/parser509546.ts
parser/ecmascript5/RegressionTests/parser509546_1.ts
parser/ecmascript5/RegressionTests/parser509546_2.ts
Expand Down Expand Up @@ -2199,8 +2210,14 @@ parser/ecmascript6/Symbols/parserSymbolProperty6.ts
parser/ecmascript6/Symbols/parserSymbolProperty7.ts
parser/ecmascript6/Symbols/parserSymbolProperty8.ts
parser/ecmascript6/Symbols/parserSymbolProperty9.ts
references/library-reference-1.ts
references/library-reference-14.ts
references/library-reference-3.ts
references/library-reference-4.ts
references/library-reference-6.ts
references/library-reference-7.ts
references/library-reference-8.ts
references/library-reference-scoped-packages.ts
salsa/constructorNameInObjectLiteralAccessor.ts
salsa/inferringClassMembersFromAssignments8.ts
salsa/mixedPropertyElementAccessAssignmentDeclaration.ts
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 3,
extra_error: 0,
panic: 0,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
1
]
},
"extra_errors": {
"TS2307": 3
},
"extra_error_lines": {
"TS2307": [
2,
4,
1
]
}
"extra_errors": {},
"extra_error_lines": {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 1,
matched_error: 0,
extra_error: 3,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 3,
extra_error: 0,
panic: 0,
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 1,
extra_error: 0,
panic: 0,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"required_errors": {},
"required_error_lines": {},
"extra_errors": {
"TS2307": 3,
"TS0": 1
},
"extra_error_lines": {
"TS2307": [
10,
33,
40
],
"TS0": [
28
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 0,
extra_error: 4,
extra_error: 1,
panic: 0,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required_errors": {
"TS2307": 1
},
"required_error_lines": {
"TS2307": [
10
]
},
"extra_errors": {},
"extra_error_lines": {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 0,
matched_error: 1,
required_error: 1,
matched_error: 0,
extra_error: 0,
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: 2860,
matched_error: 7175,
extra_error: 1107,
required_error: 2861,
matched_error: 7174,
extra_error: 1090,
panic: 3,
}

0 comments on commit 0488618

Please sign in to comment.