From 49f97d5f85b3be9b698a39ac3f16b0e9c77efeb8 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 27 Mar 2024 11:58:36 -0400 Subject: [PATCH] fix(check): do not suggest running with `--unstable` (#23092) Closes #23079 --- cli/tsc/99_main_compiler.js | 4 ++-- tests/specs/check/unstable_suggestion/__test__.jsonc | 11 +++++++++++ tests/specs/check/unstable_suggestion/main.out | 10 ++++++++++ tests/specs/check/unstable_suggestion/main.ts | 5 +++++ .../check/unstable_suggestion/no_default_lib.out | 5 +++++ .../specs/check/unstable_suggestion/no_default_lib.ts | 5 +++++ 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/specs/check/unstable_suggestion/__test__.jsonc create mode 100644 tests/specs/check/unstable_suggestion/main.out create mode 100644 tests/specs/check/unstable_suggestion/main.ts create mode 100644 tests/specs/check/unstable_suggestion/no_default_lib.out create mode 100644 tests/specs/check/unstable_suggestion/no_default_lib.ts diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index e6123d25ed..e473004918 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -354,7 +354,7 @@ delete Object.prototype.__proto__; case 2339: { const property = getProperty(); if (property && unstableDenoProps.has(property)) { - return `${msg} 'Deno.${property}' is an unstable API. Did you forget to run with the '--unstable' flag? ${unstableMsgSuggestion}`; + return `${msg} 'Deno.${property}' is an unstable API. ${unstableMsgSuggestion}`; } return msg; } @@ -363,7 +363,7 @@ delete Object.prototype.__proto__; if (property && unstableDenoProps.has(property)) { const suggestion = getMsgSuggestion(); if (suggestion) { - return `${msg} 'Deno.${property}' is an unstable API. Did you forget to run with the '--unstable' flag, or did you mean '${suggestion}'? ${unstableMsgSuggestion}`; + return `${msg} 'Deno.${property}' is an unstable API. Did you mean '${suggestion}'? ${unstableMsgSuggestion}`; } } return msg; diff --git a/tests/specs/check/unstable_suggestion/__test__.jsonc b/tests/specs/check/unstable_suggestion/__test__.jsonc new file mode 100644 index 0000000000..28fe022be2 --- /dev/null +++ b/tests/specs/check/unstable_suggestion/__test__.jsonc @@ -0,0 +1,11 @@ +{ + "steps": [{ + "args": "check main.ts", + "output": "main.out", + "exitCode": 1 + }, { + "args": "check no_default_lib.ts", + "output": "no_default_lib.out", + "exitCode": 1 + }] +} diff --git a/tests/specs/check/unstable_suggestion/main.out b/tests/specs/check/unstable_suggestion/main.out new file mode 100644 index 0000000000..ba8b2800c5 --- /dev/null +++ b/tests/specs/check/unstable_suggestion/main.out @@ -0,0 +1,10 @@ +Check file:///[WILDLINE]main.ts +error: TS2551 [ERROR]: Property 'dlopen' does not exist on type 'typeof Deno'. Did you mean 'open'? 'Deno.dlopen' is an unstable API. Did you mean 'open'? If not, try changing the 'lib' compiler option to include 'deno.unstable' or add a triple-slash directive to the top of your entrypoint (main file): /// +Deno.dlopen("path/to/lib", {}); + ~~~~~~ + at file:///[WILDLINE]/main.ts:5:6 + + 'open' is declared here. + export function open( + ~~~~ + at asset:///lib.deno.ns.d.ts:[WILDLINE] diff --git a/tests/specs/check/unstable_suggestion/main.ts b/tests/specs/check/unstable_suggestion/main.ts new file mode 100644 index 0000000000..02a5cfbdf4 --- /dev/null +++ b/tests/specs/check/unstable_suggestion/main.ts @@ -0,0 +1,5 @@ +/// +/// + +// unstable apis removed here, so should error +Deno.dlopen("path/to/lib", {}); diff --git a/tests/specs/check/unstable_suggestion/no_default_lib.out b/tests/specs/check/unstable_suggestion/no_default_lib.out new file mode 100644 index 0000000000..1ec2ae3e5d --- /dev/null +++ b/tests/specs/check/unstable_suggestion/no_default_lib.out @@ -0,0 +1,5 @@ +Check file:///[WILDLINE]/no_default_lib.ts +error: TS2304 [ERROR]: Cannot find name 'Deno'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'deno.ns' or add a triple-slash directive to the top of your entrypoint (main file): /// +console.log(Deno); + ~~~~ + at file:///[WILDLINE]/no_default_lib.ts:5:13 diff --git a/tests/specs/check/unstable_suggestion/no_default_lib.ts b/tests/specs/check/unstable_suggestion/no_default_lib.ts new file mode 100644 index 0000000000..2b3aa6dfc5 --- /dev/null +++ b/tests/specs/check/unstable_suggestion/no_default_lib.ts @@ -0,0 +1,5 @@ +/// +/// +/// + +console.log(Deno);