From b563746885f8548676953536987012012b08646d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 1 Aug 2023 11:27:25 -0400 Subject: [PATCH] fix: deno diagnostic - clarify where to put triple-slash directive (#20009) Some people might not know what "entrypoint" means or where to put the triple-slash directive. --- cli/tests/testdata/check/deno_not_found/main.out | 2 +- cli/tests/testdata/check/deno_unstable_not_found/main.out | 4 ++-- cli/tests/testdata/run/unstable_disabled.out | 2 +- cli/tsc/99_main_compiler.js | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cli/tests/testdata/check/deno_not_found/main.out b/cli/tests/testdata/check/deno_not_found/main.out index 39852ab952..dc4a682c75 100644 --- a/cli/tests/testdata/check/deno_not_found/main.out +++ b/cli/tests/testdata/check/deno_not_found/main.out @@ -1,4 +1,4 @@ -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 your entrypoint: /// +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): /// Deno; ~~~~ at file:///[WILDCARD]/check/deno_not_found/main.ts:4:1 diff --git a/cli/tests/testdata/check/deno_unstable_not_found/main.out b/cli/tests/testdata/check/deno_unstable_not_found/main.out index dcc6466224..98e4372672 100644 --- a/cli/tests/testdata/check/deno_unstable_not_found/main.out +++ b/cli/tests/testdata/check/deno_unstable_not_found/main.out @@ -1,4 +1,4 @@ -error: TS2551 [ERROR]: Property 'openKv' does not exist on type 'typeof Deno'. Did you mean 'open'? 'Deno.openKv' is an unstable API. Did you forget to run with the '--unstable' flag, or did you mean 'open'? If not, try changing the 'lib' compiler option to include 'deno.unstable' or add a triple-slash directive to your entrypoint: /// +error: TS2551 [ERROR]: Property 'openKv' does not exist on type 'typeof Deno'. Did you mean 'open'? 'Deno.openKv' is an unstable API. Did you forget to run with the '--unstable' flag, or 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.openKv; ~~~~~~ at file:///[WILDCARD]/deno_unstable_not_found/main.ts:1:6 @@ -8,7 +8,7 @@ Deno.openKv; ~~~~ at asset:///lib.deno.ns.d.ts:[WILDCARD]:19 -TS2339 [ERROR]: Property 'createHttpClient' does not exist on type 'typeof Deno'. 'Deno.createHttpClient' is an unstable API. Did you forget to run with the '--unstable' flag? If not, try changing the 'lib' compiler option to include 'deno.unstable' or add a triple-slash directive to your entrypoint: /// +TS2339 [ERROR]: Property 'createHttpClient' does not exist on type 'typeof Deno'. 'Deno.createHttpClient' is an unstable API. Did you forget to run with the '--unstable' flag? 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.createHttpClient; ~~~~~~~~~~~~~~~~ at file:///[WILDCARD]/deno_unstable_not_found/main.ts:2:6 diff --git a/cli/tests/testdata/run/unstable_disabled.out b/cli/tests/testdata/run/unstable_disabled.out index fb8d3ee05c..cf78e8ffc8 100644 --- a/cli/tests/testdata/run/unstable_disabled.out +++ b/cli/tests/testdata/run/unstable_disabled.out @@ -1,5 +1,5 @@ [WILDCARD] -error: TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag? If not, try changing the 'lib' compiler option to include 'deno.unstable' or add a triple-slash directive to your entrypoint: /// +error: TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag? 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): /// console.log(Deno.umask); ~~~~~ at [WILDCARD]/unstable.ts:1:18 diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 2190dda994..43a3c3bcf6 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -58,7 +58,8 @@ delete Object.prototype.__proto__; ]); const unstableMsgSuggestion = "If not, try changing the 'lib' compiler option to include 'deno.unstable' " + - 'or add a triple-slash directive to your entrypoint: /// '; + "or add a triple-slash directive to the top of your entrypoint (main file): " + + '/// '; /** * @param {unknown} value @@ -344,7 +345,8 @@ delete Object.prototype.__proto__; if (msg === "Cannot find name 'Deno'.") { msg += " 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 your entrypoint: /// '; + "or add a triple-slash directive to the top of your entrypoint " + + '(main file): /// '; } return msg; }