@@ -213,7 +213,16 @@ const bindingsConfigMock: Omit<
213213describe ( "generate types" , ( ) => {
214214 let spy : MockInstance ;
215215 const std = mockConsoleMethods ( ) ;
216+ const originalColumns = process . stdout . columns ;
216217 runInTempDir ( ) ;
218+
219+ beforeAll ( ( ) => {
220+ process . stdout . columns = 60 ;
221+ } ) ;
222+
223+ afterAll ( ( ) => {
224+ process . stdout . columns = originalColumns ;
225+ } ) ;
217226 beforeEach ( ( ) => {
218227 spy = vi
219228 . spyOn ( generateRuntime , "generateRuntimeTypes" )
@@ -322,6 +331,7 @@ describe("generate types", () => {
322331 📖 Read about runtime types
323332 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
324333 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
334+
325335 Generating project types...
326336
327337 interface Env {
@@ -338,6 +348,7 @@ describe("generate types", () => {
338348 📖 Read about runtime types
339349 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
340350 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
351+
341352 Generating project types...
342353
343354 interface Env {
@@ -353,7 +364,8 @@ describe("generate types", () => {
353364
354365 📖 Read about runtime types
355366 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
356- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
367+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
368+ "
357369 ` ) ;
358370 } ) ;
359371
@@ -430,7 +442,8 @@ describe("generate types", () => {
430442 ────────────────────────────────────────────────────────────
431443 ✨ Types written to worker-configuration.d.ts
432444
433- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
445+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
446+ "
434447 ` ) ;
435448 } ) ;
436449
@@ -451,7 +464,7 @@ describe("generate types", () => {
451464 expect ( fs . existsSync ( "./worker-configuration.d.ts" ) ) . toBe ( true ) ;
452465 expect ( fs . readFileSync ( "./worker-configuration.d.ts" , "utf-8" ) )
453466 . toMatchInlineSnapshot ( `
454- "// Generated by Wrangler by running \`wrangler\` (hash: 1baaf305bc7d12c97f589487a5ecfafb )
467+ "// Generated by Wrangler by running \`wrangler\` (hash: e0442e27e492fd2b5e8bb36627f0213c )
455468 // Runtime types generated with workerd@
456469 interface Env {
457470 SOMETHING: \\"asdasdfasdf\\";
@@ -489,7 +502,8 @@ describe("generate types", () => {
489502 No project types to add.
490503
491504 ────────────────────────────────────────────────────────────
492- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
505+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
506+ "
493507 ` ) ;
494508 } ) ;
495509
@@ -529,7 +543,8 @@ describe("generate types", () => {
529543
530544 📖 Read about runtime types
531545 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
532- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
546+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
547+ "
533548 ` ) ;
534549 } ) ;
535550
@@ -559,7 +574,8 @@ describe("generate types", () => {
559574 ────────────────────────────────────────────────────────────
560575 ✨ Types written to worker-configuration.d.ts
561576
562- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
577+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
578+ "
563579 ` ) ;
564580 } ) ;
565581 } ) ;
@@ -622,7 +638,8 @@ describe("generate types", () => {
622638 ────────────────────────────────────────────────────────────
623639 ✨ Types written to worker-configuration.d.ts
624640
625- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
641+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
642+ "
626643 ` ) ;
627644 } ) ;
628645
@@ -656,7 +673,8 @@ describe("generate types", () => {
656673
657674 📖 Read about runtime types
658675 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
659- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
676+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
677+ "
660678 ` ) ;
661679 } ) ;
662680
@@ -685,7 +703,8 @@ describe("generate types", () => {
685703 ────────────────────────────────────────────────────────────
686704 ✨ Types written to worker-configuration.d.ts
687705
688- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
706+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
707+ "
689708 ` ) ;
690709 } ) ;
691710
@@ -726,7 +745,8 @@ describe("generate types", () => {
726745 ────────────────────────────────────────────────────────────
727746 ✨ Types written to worker-configuration.d.ts
728747
729- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
748+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
749+ "
730750 ` ) ;
731751 } ) ;
732752
@@ -759,7 +779,8 @@ describe("generate types", () => {
759779 ────────────────────────────────────────────────────────────
760780 ✨ Types written to worker-configuration.d.ts
761781
762- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
782+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
783+ "
763784 ` ) ;
764785 } ) ;
765786
@@ -795,7 +816,8 @@ describe("generate types", () => {
795816 ────────────────────────────────────────────────────────────
796817 ✨ Types written to worker-configuration.d.ts
797818
798- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
819+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
820+ "
799821 ` ) ;
800822 } ) ;
801823
@@ -839,7 +861,8 @@ describe("generate types", () => {
839861 ────────────────────────────────────────────────────────────
840862 ✨ Types written to worker-configuration.d.ts
841863
842- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
864+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
865+ "
843866 ` ) ;
844867 } ) ;
845868
@@ -890,7 +913,8 @@ describe("generate types", () => {
890913 ────────────────────────────────────────────────────────────
891914 ✨ Types written to worker-configuration.d.ts
892915
893- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
916+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
917+ "
894918 ` ) ;
895919 } ) ;
896920
@@ -910,7 +934,8 @@ describe("generate types", () => {
910934 ────────────────────────────────────────────────────────────
911935 ✨ Types written to worker-configuration.d.ts
912936
913- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
937+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
938+ "
914939 ` ) ;
915940 } ) ;
916941 } ) ;
@@ -942,7 +967,8 @@ describe("generate types", () => {
942967 ────────────────────────────────────────────────────────────
943968 ✨ Types written to worker-configuration.d.ts
944969
945- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
970+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
971+ "
946972 ` ) ;
947973 } ) ;
948974
@@ -1028,7 +1054,7 @@ describe("generate types", () => {
10281054
10291055 expect ( fs . readFileSync ( "./cloudflare-env.d.ts" , "utf-8" ) )
10301056 . toMatchInlineSnapshot ( `
1031- "// Generated by Wrangler by running \`wrangler\` (hash: 1baaf305bc7d12c97f589487a5ecfafb )
1057+ "// Generated by Wrangler by running \`wrangler\` (hash: e0442e27e492fd2b5e8bb36627f0213c )
10321058 // Runtime types generated with workerd@
10331059 interface Env {
10341060 SOMETHING: \\"asdasdfasdf\\";
@@ -1082,7 +1108,7 @@ describe("generate types", () => {
10821108
10831109 expect ( fs . readFileSync ( "./my-cloudflare-env-interface.d.ts" , "utf-8" ) )
10841110 . toMatchInlineSnapshot ( `
1085- "// Generated by Wrangler by running \`wrangler\` (hash: 6b0c21549436b64a143346d5df73ba4d )
1111+ "// Generated by Wrangler by running \`wrangler\` (hash: 15fe0821fea3c43df1b7e2b020b0fb7b )
10861112 // Runtime types generated with workerd@
10871113 interface MyCloudflareEnvInterface {
10881114 SOMETHING: \\"asdasdfasdf\\";
@@ -1139,16 +1165,10 @@ describe("generate types", () => {
11391165 \`wrangler types\` now generates runtime types and supersedes @cloudflare/workers-types.
11401166 You should now uninstall @cloudflare/workers-types and remove it from your tsconfig.json.
11411167
1142- Action required Update your tsconfig.json to include the generated types
1143- {
1144- \\"compilerOptions\\": {
1145- \\"types\\": [\\"worker-configuration.d.ts\\"]
1146- }
1147- }
1148-
11491168 📖 Read about runtime types
11501169 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
1151- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
1170+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
1171+ "
11521172 ` ) ;
11531173 } ) ;
11541174 it ( "prints something helpful if you have a runtime file at the old default location" , async ( ) => {
@@ -1180,7 +1200,8 @@ describe("generate types", () => {
11801200
11811201 📖 Read about runtime types
11821202 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
1183- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
1203+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
1204+ "
11841205 ` ) ;
11851206 } ) ;
11861207 it ( "prints something helpful about node compat" , async ( ) => {
@@ -1212,54 +1233,13 @@ describe("generate types", () => {
12121233 ────────────────────────────────────────────────────────────
12131234 ✨ Types written to worker-configuration.d.ts
12141235
1215- Action required Install types@ node
1236+ Action required Install @types/ node
12161237 Since you have the \`nodejs_compat\` flag, you should install Node.js types by running \\"npm i --save-dev @types/node\\".
12171238
12181239 📖 Read about runtime types
12191240 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
1220- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
1221- ` ) ;
1222- } ) ;
1223- it ( "prints specific node version if you have node compat and workers types" , async ( ) => {
1224- fs . writeFileSync (
1225- "./wrangler.toml" ,
1226- TOML . stringify ( {
1227- compatibility_date : "2022-12-12" ,
1228- compatibility_flags : [ "nodejs_compat" ] ,
1229- vars : {
1230- "var-a" : "a" ,
1231- } ,
1232- } as TOML . JsonMap ) ,
1233- "utf-8"
1234- ) ;
1235- fs . writeFileSync (
1236- "./tsconfig.json" ,
1237- JSON . stringify ( {
1238- compilerOptions : {
1239- types : [ "worker-configuration.d.ts" , "@cloudflare/workers-types" ] ,
1240- } ,
1241- } )
1242- ) ;
1243- await runWrangler ( "types --include-env=false" ) ;
1244- expect ( std . out ) . toMatchInlineSnapshot ( `
1245- "Generating runtime types...
1246-
1247- Runtime types generated.
1248-
1249- ────────────────────────────────────────────────────────────
1250- ✨ Types written to worker-configuration.d.ts
1251-
1252- Action required Migrate from @cloudflare/workers-types to generated runtime types
1253- \`wrangler types\` now generates runtime types and supersedes @cloudflare/workers-types.
1254- You should now uninstall @cloudflare/workers-types and remove it from your tsconfig.json.
1255-
1256- Action required Install types@node
1257- Since you have the \`nodejs_compat\` flag, you should install Node.js types by running \\"npm i --save-dev @types/[email protected] \\". 1258- For more details: https://developers.cloudflare.com/workers/languages/typescript/#known-issues
1259-
1260- 📖 Read about runtime types
1261- https://developers.cloudflare.com/workers/languages/typescript/#generate-types
1262- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
1241+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
1242+ "
12631243 ` ) ;
12641244 } ) ;
12651245 it ( "prints all the relevant stuff if you having nothing set up" , async ( ) => {
@@ -1291,19 +1271,13 @@ describe("generate types", () => {
12911271 ────────────────────────────────────────────────────────────
12921272 ✨ Types written to custom.d.ts
12931273
1294- Action required Update your tsconfig.json to include the generated types
1295- {
1296- \\"compilerOptions\\": {
1297- \\"types\\": [\\"irrelevant.d.ts\\",\\"custom.d.ts\\"]
1298- }
1299- }
1300-
1301- Action required Install types@node
1274+ Action required Install @types/node
13021275 Since you have the \`nodejs_compat\` flag, you should install Node.js types by running \\"npm i --save-dev @types/node\\".
13031276
13041277 📖 Read about runtime types
13051278 https://developers.cloudflare.com/workers/languages/typescript/#generate-types
1306- 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file."
1279+ 📣 Remember to rerun 'wrangler types' after you change your wrangler.toml file.
1280+ "
13071281 ` ) ;
13081282 } ) ;
13091283 it ( "should not recommend to install @types/node if 'node' exists in types array" , async ( ) => {
0 commit comments