Skip to content

Commit 98a72f5

Browse files
authored
chore: check in types (#9863)
To ensure that changes to code/types doesn't result in unwanted changes in type generation, or that bumps to dts-buddy don't cause unwanted regressions, we're checking in the generated types. Types should be committed as-is (don't format it with prettier!). CI is enhanced to check that git sees no changed files after generating the types, which would mean types have changed.
1 parent abc1266 commit 98a72f5

File tree

8 files changed

+2598
-11
lines changed

8 files changed

+2598
-11
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,11 @@ jobs:
5050
with:
5151
node-version: 18
5252
cache: pnpm
53-
- run: 'pnpm i && pnpm check && pnpm lint'
53+
- name: install
54+
run: pnpm install --frozen-lockfile
55+
- name: type check
56+
run: pnpm check
57+
- name: lint
58+
run: pnpm lint
59+
- name: build and check generated types
60+
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally and commit the changes after you have reviewed them"; git diff; exit 1); }

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ jobs:
2828
node-version: 18.x
2929
cache: pnpm
3030

31-
- run: pnpm install --frozen-lockfile
31+
- name: Install
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Build
35+
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally and commit the changes after you have reviewed them"; git diff; exit 1); }
3236

3337
- name: Create Release Pull Request or Publish to npm
3438
id: changesets

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ To typecheck the codebase, run `pnpm check` inside `packages/svelte`. To typeche
133133
- `snake_case` for internal variable names and methods.
134134
- `camelCase` for public variable names and methods.
135135

136+
### Generating types
137+
138+
Types are auto-generated from the source, but the result is checked in to ensure no accidental changes slip through. Run `pnpm generate:types` to regenerate the types.
139+
136140
### Sending your pull request
137141

138142
Please make sure the following is done when submitting a pull request:
@@ -141,7 +145,7 @@ Please make sure the following is done when submitting a pull request:
141145
1. Make sure your code lints (`pnpm lint`).
142146
1. Make sure your tests pass (`pnpm test`).
143147

144-
All pull requests should be opened against the `main` branch. Make sure the PR does only one thing, otherwise please split it.
148+
All pull requests should be opened against the `main` branch. Make sure the PR does only one thing, otherwise please split it. If this change should contribute to a version bump, run `npx changeset` at the root of the repository after a code change and select the appropriate packages.
145149

146150
#### Breaking changes
147151

packages/svelte/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/types
1+
/types/*.map
2+
/types/compiler
23
/compiler.cjs
34

45
/action.d.ts

packages/svelte/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@
9090
"templating"
9191
],
9292
"scripts": {
93-
"build": "rollup -c && node scripts/build.js && node scripts/check-treeshakeability.js",
93+
"build": "rollup -c && pnpm generate:types && node scripts/check-treeshakeability.js",
9494
"dev": "rollup -cw",
9595
"check": "tsc && cd ./tests/types && tsc",
9696
"check:watch": "tsc --watch",
9797
"generate:version": "node ./scripts/generate-version.js",
98+
"generate:types": "node ./scripts/generate-types.js",
9899
"prepublishOnly": "pnpm build"
99100
},
100101
"devDependencies": {
@@ -106,7 +107,7 @@
106107
"@rollup/plugin-virtual": "^3.0.2",
107108
"@types/aria-query": "^5.0.3",
108109
"@types/estree": "^1.0.5",
109-
"dts-buddy": "^0.4.0",
110+
"dts-buddy": "^0.4.3",
110111
"esbuild": "^0.19.2",
111112
"rollup": "^4.1.5",
112113
"source-map": "^0.7.4",

0 commit comments

Comments
 (0)