From 90f7c040c49ea49cca0fc44d2fb54f168797418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:43:49 +0900 Subject: [PATCH] feat: Implement error emission about existing file (#1076) **Related issue:** - Part of #705 --- .../tests/conformance.pass.txt | 1 + ...uleResolutionWithExtensions.error-diff.json | 12 ++++++++++++ ...leResolutionWithExtensions.stats.rust-debug | 4 ++-- .../relativePathMustResolve.stats.rust-debug | 6 +++--- ...lativePathToDeclarationFile.error-diff.json | 14 ++++++++++++++ ...ativePathToDeclarationFile.stats.rust-debug | 4 ++-- .../allowImportingTsExtensions.error-diff.json | 12 ++++++++++++ ...allowImportingTsExtensions.stats.rust-debug | 4 ++-- ...mlFileWithinDeclarationFile.error-diff.json | 13 +++++++++++++ ...lFileWithinDeclarationFile.stats.rust-debug | 4 ++-- ...eclarationFileForHtmlImport.error-diff.json | 12 ++++++++++++ ...clarationFileForHtmlImport.stats.rust-debug | 4 ++-- .../importTypeLocalMissing.error-diff.json | 18 ++++++++++++++++++ .../importTypeLocalMissing.stats.rust-debug | 8 ++++---- .../tests/tsc-stats.rust-debug | 8 ++++---- crates/stc_ts_type_checker/tests/tsc.rs | 4 ++-- 16 files changed, 105 insertions(+), 23 deletions(-) create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 58892e1825..70a0fba1ff 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -1699,6 +1699,7 @@ externalModules/multipleExportDefault6.ts externalModules/nameDelimitedBySlashes.ts externalModules/nameWithFileExtension.ts externalModules/reexportClassDefinition.ts +externalModules/relativePathMustResolve.ts externalModules/topLevelAwait.3.ts externalModules/topLevelFileModule.ts externalModules/topLevelFileModuleMissing.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json @@ -0,0 +1,12 @@ +{ + "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/externalModules/moduleResolutionWithExtensions.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug index f79107e8ee..f3e39f53bd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 0, + required_error: 0, + matched_error: 1, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json new file mode 100644 index 0000000000..6ba22cb597 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json @@ -0,0 +1,14 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 3 + }, + "extra_error_lines": { + "TS2307": [ + 1, + 2, + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json @@ -0,0 +1,12 @@ +{ + "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/moduleResolution/allowImportingTsExtensions.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json new file mode 100644 index 0000000000..c2d072b17f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json @@ -0,0 +1,13 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2 + }, + "extra_error_lines": { + "TS2307": [ + 1, + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json @@ -0,0 +1,12 @@ +{ + "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/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json new file mode 100644 index 0000000000..77be6774be --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json @@ -0,0 +1,18 @@ +{ + "required_errors": { + "TS2694": 1 + }, + "required_error_lines": { + "TS2694": [ + 3 + ] + }, + "extra_errors": { + "TS0": 1 + }, + "extra_error_lines": { + "TS0": [ + 16 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug index 9a5e5f9eba..c28efdd8e5 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 4, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 1, + matched_error: 3, + extra_error: 1, + 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 26769c1753..dd1f1169c0 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: 3493, - matched_error: 6542, - extra_error: 764, - panic: 73, + required_error: 3489, + matched_error: 6546, + extra_error: 773, + panic: 66, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index 5666522e23..8dae2f3ea5 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -16,7 +16,7 @@ use std::{ sync::Arc, }; -use anyhow::{Context, Error}; +use anyhow::{bail, Context, Error}; use indexmap::IndexMap; use once_cell::sync::Lazy; use parking_lot::Mutex; @@ -662,7 +662,7 @@ impl LoadFile for TestFileSystem { } } - todo!("load_file: {:?} ", filename); + bail!("not found module"); } }