From 0488618fc7cf08f2bf6af066d4870688c3fffb7e Mon Sep 17 00:00:00 2001 From: sunrabbit123 Date: Tue, 10 Oct 2023 23:09:12 +0900 Subject: [PATCH] resolve --- .../stc_ts_file_analyzer/src/analyzer/import.rs | 14 ++++++++++++-- .../tests/conformance.pass.txt | 17 +++++++++++++++++ ...OfExportNamespaceWithDefault.error-diff.json | 12 ------------ ...fExportNamespaceWithDefault.stats.rust-debug | 2 +- .../library-reference-1.error-diff.json | 12 ------------ .../library-reference-1.stats.rust-debug | 2 +- .../library-reference-3.error-diff.json | 12 ------------ .../library-reference-3.stats.rust-debug | 2 +- .../library-reference-4.error-diff.json | 14 -------------- .../library-reference-4.stats.rust-debug | 2 +- .../library-reference-5.error-diff.json | 12 ++---------- .../library-reference-5.stats.rust-debug | 2 +- .../library-reference-7.error-diff.json | 12 ------------ .../library-reference-7.stats.rust-debug | 2 +- .../library-reference-8.error-diff.json | 14 -------------- .../library-reference-8.stats.rust-debug | 2 +- ...ry-reference-scoped-packages.error-diff.json | 12 ------------ ...y-reference-scoped-packages.stats.rust-debug | 2 +- .../import/importTypeAmbient.error-diff.json | 6 ------ .../import/importTypeAmbient.stats.rust-debug | 2 +- .../importTypeAmbientMissing.error-diff.json | 12 ++++++++++++ .../importTypeAmbientMissing.stats.rust-debug | 4 ++-- .../tests/tsc-stats.rust-debug | 6 +++--- 23 files changed, 57 insertions(+), 120 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/import.rs b/crates/stc_ts_file_analyzer/src/analyzer/import.rs index 4053cad760..735ae42646 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/import.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/import.rs @@ -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())); @@ -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())); @@ -79,6 +82,11 @@ 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); @@ -86,12 +94,14 @@ impl Analyzer<'_, '_> { 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; } diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index e438f4eba6..0c48a767ae 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json deleted file mode 100644 index e38ae59eac..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 11 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json deleted file mode 100644 index 70141c5123..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 2, - 4, - 1 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug index 7d12ad5c64..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json index 3a1b51456c..d96d78547f 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json @@ -7,14 +7,6 @@ 1 ] }, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 2, - 4, - 1 - ] - } + "extra_errors": {}, + "extra_error_lines": {} } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug index efea2c0329..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json deleted file mode 100644 index 9df5d88278..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 3, - 4, - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug index 7d12ad5c64..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json deleted file mode 100644 index dba7272865..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 1 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json index 03d5257c1e..d8db441db2 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json @@ -2,15 +2,9 @@ "required_errors": {}, "required_error_lines": {}, "extra_errors": { - "TS2307": 3, "TS0": 1 }, "extra_error_lines": { - "TS2307": [ - 10, - 33, - 40 - ], "TS0": [ 28 ] diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug index f8c5b3550b..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 4, + extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json new file mode 100644 index 0000000000..5e7c93b207 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS2307": 1 + }, + "required_error_lines": { + "TS2307": [ + 10 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug index f3e39f53bd..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 0, - matched_error: 1, + required_error: 1, + matched_error: 0, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 83979399ee..3bad9ce15d 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -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, } \ No newline at end of file