Give suggestion for @types/bun when Bun global is not found (#56795)

This commit is contained in:
Jake Bailey
2023-12-15 14:48:23 -08:00
committed by GitHub
parent a36d04fc63
commit 0e5927d5d3
12 changed files with 94 additions and 0 deletions

View File

@@ -26192,6 +26192,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
case "Bun":
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun;
case "Map":
case "Set":
case "Promise":

View File

@@ -3735,6 +3735,14 @@
"category": "Error",
"code": 2866
},
"Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`.": {
"category": "Error",
"code": 2867
},
"Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig.": {
"category": "Error",
"code": 2868
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",

View File

@@ -0,0 +1,11 @@
a.ts(1,14): error TS2868: Cannot find name 'Bun'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig.
==== tsconfig.json (0 errors) ====
{ "compilerOptions": {"types": []} }
==== a.ts (1 errors) ====
const file = Bun.file("/a.ts");
~~~
!!! error TS2868: Cannot find name 'Bun'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig.

View File

@@ -0,0 +1,8 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun1.ts] ////
//// [a.ts]
const file = Bun.file("/a.ts");
//// [a.js]
var file = Bun.file("/a.ts");

View File

@@ -0,0 +1,6 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun1.ts] ////
=== a.ts ===
const file = Bun.file("/a.ts");
>file : Symbol(file, Decl(a.ts, 0, 5))

View File

@@ -0,0 +1,11 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun1.ts] ////
=== a.ts ===
const file = Bun.file("/a.ts");
>file : any
>Bun.file("/a.ts") : any
>Bun.file : any
>Bun : any
>file : any
>"/a.ts" : "/a.ts"

View File

@@ -0,0 +1,11 @@
a.ts(1,14): error TS2867: Cannot find name 'Bun'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`.
==== tsconfig.json (0 errors) ====
{ "compilerOptions": {} }
==== a.ts (1 errors) ====
const file = Bun.file("/a.ts");
~~~
!!! error TS2867: Cannot find name 'Bun'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`.

View File

@@ -0,0 +1,8 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun2.ts] ////
//// [a.ts]
const file = Bun.file("/a.ts");
//// [a.js]
var file = Bun.file("/a.ts");

View File

@@ -0,0 +1,6 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun2.ts] ////
=== a.ts ===
const file = Bun.file("/a.ts");
>file : Symbol(file, Decl(a.ts, 0, 5))

View File

@@ -0,0 +1,11 @@
//// [tests/cases/conformance/typings/typingsSuggestionBun2.ts] ////
=== a.ts ===
const file = Bun.file("/a.ts");
>file : any
>Bun.file("/a.ts") : any
>Bun.file : any
>Bun : any
>file : any
>"/a.ts" : "/a.ts"

View File

@@ -0,0 +1,5 @@
// @filename: tsconfig.json
{ "compilerOptions": {"types": []} }
// @filename: a.ts
const file = Bun.file("/a.ts");

View File

@@ -0,0 +1,5 @@
// @filename: tsconfig.json
{ "compilerOptions": {} }
// @filename: a.ts
const file = Bun.file("/a.ts");