0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-04 09:57:11 -05:00

fix: add hint to run with --no-check when type checking fails (#28091)

This commit is contained in:
David Sherret 2025-02-13 11:54:52 +01:00 committed by GitHub
parent 4921411bb2
commit 7946906ac5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 131 additions and 5 deletions

View file

@ -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 <y>info:</y> The program failed type-checking, but it still might work correctly.\n <c>hint:</c> Re-run with <u>--no-check</u> 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())
}

View file

@ -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.

View file

@ -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.

View file

@ -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",

View file

@ -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.

View file

@ -7,7 +7,7 @@
},
"run": {
"args": "run --check --allow-import main.ts",
"output": "main.out",
"output": "main_run.out",
"exitCode": 1
},
"missing_local_root": {

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -6,3 +6,6 @@ const foo: Foo = new Map<string, string>();
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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.