Skip to content

Commit

Permalink
Remove ambient vitest types from generated tsconfig.jsons (#2839)
Browse files Browse the repository at this point in the history
Previously, `wrangler init` generated a `tsconfig.json` with
`"types": [..., "vitest"]`, even if Vitest tests weren't generated.
Unlike Jest, Vitest doesn't provide global APIs by default
(https://vitest.dev/config/#globals), so there's no need for ambient
types.
  • Loading branch information
mrbbot committed Mar 6, 2023
1 parent e3c036d commit ad4b123
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/eight-eagles-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"wrangler": patch
---

fix: remove `vitest` from `wrangler init`'s generated `tsconfig.json` `types` array

Previously, `wrangler init` generated a `tsconfig.json` with `"types": ["@cloudflare/workers-types", "vitest"]`, even if Vitest tests weren't generated.
Unlike Jest, Vitest [doesn't provide global APIs by default](https://vitest.dev/config/#globals), so there's no need for ambient types.
2 changes: 1 addition & 1 deletion packages/wrangler/src/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ describe("init", () => {
contents: {
config: {
compilerOptions: expect.objectContaining({
types: ["@cloudflare/workers-types", "vitest"],
types: ["@cloudflare/workers-types"],
}),
},
error: undefined,
Expand Down
3 changes: 1 addition & 2 deletions packages/wrangler/templates/tsconfig.init.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
"types": [
"@cloudflare/workers-types",
"vitest"
"@cloudflare/workers-types"
] /* Specify type package names to be included without being referenced in a source file. */,
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true /* Enable importing .json files */,
Expand Down

0 comments on commit ad4b123

Please sign in to comment.