diff --git a/cli/tools/check.rs b/cli/tools/check.rs index b41c340187..861aa87433 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -28,6 +28,7 @@ use regex::Regex; use crate::args::deno_json::TsConfigResolver; use crate::args::CheckFlags; use crate::args::CliOptions; +use crate::args::DenoSubcommand; use crate::args::Flags; use crate::args::TsConfig; use crate::args::TsTypeLib; @@ -94,8 +95,16 @@ pub async fn check( #[derive(Debug, thiserror::Error, deno_error::JsError)] #[class(type)] -#[error("Type checking failed.")] -pub struct FailedTypeCheckingError; +#[error("Type checking failed.{}", if self.can_skip { + color_print::cstr!( + "\n\n info: The program failed type-checking, but it still might work correctly.\n hint: Re-run with --no-check to skip type-checking.", + ) +} else { + "" +})] +pub struct FailedTypeCheckingError { + can_skip: bool, +} #[derive(Debug, thiserror::Error, deno_error::JsError)] pub enum CheckError { @@ -199,7 +208,15 @@ impl TypeChecker { } } if failed { - Err(FailedTypeCheckingError.into()) + Err( + FailedTypeCheckingError { + can_skip: !matches!( + self.cli_options.sub_command(), + DenoSubcommand::Check(_) + ), + } + .into(), + ) } else { Ok(diagnostics.into_graph()) } diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.out b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out index 7ebc39c48a..b049816607 100644 --- a/tests/specs/bench/check_local_by_default2/check_local_by_default2.out +++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out @@ -4,3 +4,6 @@ const b: "b" = 12; at [WILDCARD]/check_local_by_default2.ts:3:7 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/bench/no_run/no_run.out b/tests/specs/bench/no_run/no_run.out index c048f2b1d8..92bf50709b 100644 --- a/tests/specs/bench/no_run/no_run.out +++ b/tests/specs/bench/no_run/no_run.out @@ -5,3 +5,6 @@ const _value: string = 1; at [WILDCARD]/no_run.ts:1:7 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/check/css_import/__test__.jsonc b/tests/specs/check/css_import/__test__.jsonc index 4e16560ec2..997d815770 100644 --- a/tests/specs/check/css_import/__test__.jsonc +++ b/tests/specs/check/css_import/__test__.jsonc @@ -12,7 +12,7 @@ "exitCode": 1 }, { "args": "run --check not_exists.ts", - "output": "not_exists.out", + "output": "not_exists_run.out", "exitCode": 1 }, { "args": "check exists_and_try_uses.ts", diff --git a/tests/specs/check/css_import/not_exists_run.out b/tests/specs/check/css_import/not_exists_run.out new file mode 100644 index 0000000000..c7dd797457 --- /dev/null +++ b/tests/specs/check/css_import/not_exists_run.out @@ -0,0 +1,8 @@ +Check [WILDLINE]exists.ts +TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/not_exists.css'. + at file:///[WILDLINE]/not_exists.ts:1:8 + +error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/check/module_not_found/__test__.jsonc b/tests/specs/check/module_not_found/__test__.jsonc index 5e7cfa2e59..16783275cc 100644 --- a/tests/specs/check/module_not_found/__test__.jsonc +++ b/tests/specs/check/module_not_found/__test__.jsonc @@ -7,7 +7,7 @@ }, "run": { "args": "run --check --allow-import main.ts", - "output": "main.out", + "output": "main_run.out", "exitCode": 1 }, "missing_local_root": { diff --git a/tests/specs/check/module_not_found/main_run.out b/tests/specs/check/module_not_found/main_run.out new file mode 100644 index 0000000000..f3baff6109 --- /dev/null +++ b/tests/specs/check/module_not_found/main_run.out @@ -0,0 +1,14 @@ +Download http://localhost:4545/remote.ts +Check file:///[WILDLINE]/module_not_found/main.ts +TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/other.js'. + at file:///[WILDLINE]/main.ts:1:22 + +TS2307 [ERROR]: Cannot find module 'http://localhost:4545/remote.ts'. + at file:///[WILDLINE]/main.ts:2:24 + +Found 2 errors. + +error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out index b531c0e6e2..ffa0bf5a65 100644 --- a/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out +++ b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out @@ -3,3 +3,6 @@ TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/b'. Maybe specify path to at file:///[WILDLINE]/mod.ts:1:20 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/_038_checkjs/038_checkjs.js.out b/tests/specs/run/_038_checkjs/038_checkjs.js.out index 2601f27172..73c5d61489 100644 --- a/tests/specs/run/_038_checkjs/038_checkjs.js.out +++ b/tests/specs/run/_038_checkjs/038_checkjs.js.out @@ -22,3 +22,6 @@ const foo = new Foo(); Found 2 errors. error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out index ad9d41c8b4..df0068f75c 100644 --- a/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out +++ b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out @@ -4,3 +4,6 @@ TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. at [WILDCARD] error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/check_remote/no_check_remote.ts.disabled.out b/tests/specs/run/check_remote/no_check_remote.ts.disabled.out index 94bab0a59b..e85bf71595 100644 --- a/tests/specs/run/check_remote/no_check_remote.ts.disabled.out +++ b/tests/specs/run/check_remote/no_check_remote.ts.disabled.out @@ -4,3 +4,6 @@ export const a: "a" = 12; at [WILDCARD]/type_error.ts:1:14 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/error_003_typescript/error_003_typescript.ts.out b/tests/specs/run/error_003_typescript/error_003_typescript.ts.out index 58e88bbd28..1ce859a4ee 100644 --- a/tests/specs/run/error_003_typescript/error_003_typescript.ts.out +++ b/tests/specs/run/error_003_typescript/error_003_typescript.ts.out @@ -7,3 +7,6 @@ x = y; at [WILDCARD]/error_003_typescript.ts:20:1 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out b/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out index 58e88bbd28..1ce859a4ee 100644 --- a/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out +++ b/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out @@ -7,3 +7,6 @@ x = y; at [WILDCARD]/error_003_typescript.ts:20:1 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out b/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out index 714f654267..059b64cd84 100644 --- a/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out +++ b/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out @@ -3,3 +3,6 @@ TS2532 [ERROR]: Object is possibly 'undefined'. at [WILDCARD]/error_017_hide_long_source_ts.ts:3:1 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/error_for_await/error_for_await.ts.out b/tests/specs/run/error_for_await/error_for_await.ts.out index 0e7a3f5d18..48cd8bf04e 100644 --- a/tests/specs/run/error_for_await/error_for_await.ts.out +++ b/tests/specs/run/error_for_await/error_for_await.ts.out @@ -10,3 +10,6 @@ TS1356 [ERROR]: Did you mean to mark this function as 'async'? at [WILDCARD]error_for_await.ts:7:10 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/import_attributes_type_check/type_check.out b/tests/specs/run/import_attributes_type_check/type_check.out index 5d5c95ebb7..022f5ddc16 100644 --- a/tests/specs/run/import_attributes_type_check/type_check.out +++ b/tests/specs/run/import_attributes_type_check/type_check.out @@ -12,3 +12,6 @@ console.log(data2.foo); Found 2 errors. error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out b/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out index 09402bc381..d303c2ed83 100644 --- a/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out +++ b/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out @@ -4,3 +4,6 @@ const a = ""; at [WILDCARD] error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/jsx_import_source/jsx_import_source_error.out b/tests/specs/run/jsx_import_source/jsx_import_source_error.out index 0847f13ef2..3129b6744a 100644 --- a/tests/specs/run/jsx_import_source/jsx_import_source_error.out +++ b/tests/specs/run/jsx_import_source/jsx_import_source_error.out @@ -3,3 +3,6 @@ TS2307 [ERROR]: Cannot find module 'file:///[WILDCARD]/nonexistent/jsx-runtime'. at file:///[WILDLINE]/jsx_import_source_no_pragma.tsx:1:1 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out b/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out index dbfb3d8133..9065e2a11c 100644 --- a/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out +++ b/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out @@ -4,3 +4,6 @@ TS2584 [ERROR]: Cannot find name 'document'. Do you need to change your target l at [WILDCARD]frontend_work.ts:2:15 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/reference_types_error/reference_types_error.js.out b/tests/specs/run/reference_types_error/reference_types_error.js.out index 1c9e9a4b8a..7a1ceb841d 100644 --- a/tests/specs/run/reference_types_error/reference_types_error.js.out +++ b/tests/specs/run/reference_types_error/reference_types_error.js.out @@ -3,3 +3,6 @@ TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/nonexistent.d.ts'. at file:///[WILDLINE]/reference_types_error.js:1:22 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out index 1c9e9a4b8a..7a1ceb841d 100644 --- a/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out +++ b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out @@ -3,3 +3,6 @@ TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/nonexistent.d.ts'. at file:///[WILDLINE]/reference_types_error.js:1:22 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/sloppy_imports/no_sloppy.out b/tests/specs/run/sloppy_imports/no_sloppy.out index 1f88cab635..f3c1d2b496 100644 --- a/tests/specs/run/sloppy_imports/no_sloppy.out +++ b/tests/specs/run/sloppy_imports/no_sloppy.out @@ -26,3 +26,6 @@ TS2307 [ERROR]: Cannot find module 'file:///[WILDLINE]/dir'. Maybe specify path Found 8 errors. error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/ts_type_imports/ts_type_imports.ts.out b/tests/specs/run/ts_type_imports/ts_type_imports.ts.out index 54592beac1..7dfe46cfb3 100644 --- a/tests/specs/run/ts_type_imports/ts_type_imports.ts.out +++ b/tests/specs/run/ts_type_imports/ts_type_imports.ts.out @@ -6,3 +6,6 @@ const foo: Foo = new Map(); at [WILDCARD]ts_type_imports.ts:5:7 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out b/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out index 4138dbf823..ab81ecda0a 100644 --- a/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out +++ b/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out @@ -5,3 +5,6 @@ bar(foo); at [WILDCARD]type_definitions_for_export.ts:7:5 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/serve/type_check/main.out b/tests/specs/serve/type_check/main.out index b584c58985..f2463d3d67 100644 --- a/tests/specs/serve/type_check/main.out +++ b/tests/specs/serve/type_check/main.out @@ -5,3 +5,6 @@ TS2353 [ERROR]: Object literal may only specify known properties, and 'bad' does at [WILDCARD]main.ts:2:3 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/serve/type_check2/main.out b/tests/specs/serve/type_check2/main.out index bc72afd9a5..766af20125 100644 --- a/tests/specs/serve/type_check2/main.out +++ b/tests/specs/serve/type_check2/main.out @@ -5,3 +5,6 @@ TS2339 [ERROR]: Property 'doesnt_exist' does not exist on type 'Request'. at [WILDCARD]main.ts:3:25 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/check_local_by_default2/main.out b/tests/specs/test/check_local_by_default2/main.out index 92973d6919..1f73b5f00a 100644 --- a/tests/specs/test/check_local_by_default2/main.out +++ b/tests/specs/test/check_local_by_default2/main.out @@ -4,3 +4,6 @@ const b: "b" = 12; at [WILDCARD]/main.ts:3:7 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/doc/main.out b/tests/specs/test/doc/main.out index 8ffc033d14..3f2e013a06 100644 --- a/tests/specs/test/doc/main.out +++ b/tests/specs/test/doc/main.out @@ -9,3 +9,6 @@ TS2367 [ERROR]: This comparison appears to be unintentional because the types 's at [WILDCARD]/main.ts$30-35.ts:3:20 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/markdown/main.out b/tests/specs/test/markdown/main.out index 4536680651..c325c69435 100644 --- a/tests/specs/test/markdown/main.out +++ b/tests/specs/test/markdown/main.out @@ -7,3 +7,6 @@ TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. at [WILDCARD]/main.md$29-32.ts:2:11 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/markdown_full_block_names/main.out b/tests/specs/test/markdown_full_block_names/main.out index b270bfe047..adc66917ae 100644 --- a/tests/specs/test/markdown_full_block_names/main.out +++ b/tests/specs/test/markdown_full_block_names/main.out @@ -6,3 +6,6 @@ TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. at [WILDCARD]/main.md$17-20.ts:2:11 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/markdown_ignore_html_comment/main.out b/tests/specs/test/markdown_ignore_html_comment/main.out index cc52f5530f..de758b9bd3 100644 --- a/tests/specs/test/markdown_ignore_html_comment/main.out +++ b/tests/specs/test/markdown_ignore_html_comment/main.out @@ -5,3 +5,6 @@ TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. at [WILDCARD]/main.md$34-37.ts:2:11 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/markdown_windows/main.out b/tests/specs/test/markdown_windows/main.out index 4536680651..c325c69435 100644 --- a/tests/specs/test/markdown_windows/main.out +++ b/tests/specs/test/markdown_windows/main.out @@ -7,3 +7,6 @@ TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. at [WILDCARD]/main.md$29-32.ts:2:11 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/no_run/main.out b/tests/specs/test/no_run/main.out index 3124c7229b..e1cd887e40 100644 --- a/tests/specs/test/no_run/main.out +++ b/tests/specs/test/no_run/main.out @@ -5,3 +5,6 @@ const _value: string = 1; at [WILDCARD]/main.ts:1:7 error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking. diff --git a/tests/specs/test/type_check_with_doc/main.out b/tests/specs/test/type_check_with_doc/main.out index 54fcdade1d..21c4137fc4 100644 --- a/tests/specs/test/type_check_with_doc/main.out +++ b/tests/specs/test/type_check_with_doc/main.out @@ -13,3 +13,6 @@ TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. Found 2 errors. error: Type checking failed. + + info: The program failed type-checking, but it still might work correctly. + hint: Re-run with --no-check to skip type-checking.