Repository navigation
fix: don't blank out generated types on sst remove - #7045
AliAladraj wants to merge 1 commit into
Conversation
After a successful `sst remove` the stage no longer has any links, so the unconditional `types.Generate` call at the end of the run rewrote every `sst-env.d.ts` (and `sst.pyi`) with an empty `Resource` interface. The files were not deleted, but they were emptied, which breaks typechecking in an editor or CI for anyone who removes one stage while still working against another. Skip type generation for the `remove` command, matching the neighbouring post-run steps that already guard on `input.Command`. `dev` and `deploy` still regenerate types, so there is no staleness regression.
|
@AliAladraj, thanks for the fix. Your commits are carried, with your authorship, in the community fork, as sst-community/sst#201 (tracked in sst-community/sst#199), and released in v4.23.1: https://github.com/sst-community/sst/releases/tag/v4.23.1 One change on top of yours: the type files are skipped only when the remove leaves no links in the stage, and regenerated from what remains otherwise. That keeps To try it: The community fork accepts pull requests and issues, so you are welcome to send them there as well. |
Fixes #6907
Root cause
sst removedoes not delete the generated type files — it regenerates them empty.pkg/project/run.go:633callstypes.Generate(...)unconditionally after every stack command,removeincluded. After a successful remove,complete.Linksis empty, so:typescript.Generaterewritessst-env.d.tsin everypackage.jsondirectory with an emptyResourceinterface (pkg/types/typescript/typescript.go:92-104)python.Generatetruncatessst.pyithe same wayThe result is that removing one stage breaks typechecking in the editor and in CI for anyone still working against another stage.
This looks incidental rather than deliberate — every neighbouring post-run step in the same function guards on
input.Command(lines 636, 646, 652, 668, 673), and there is no comment or commit message justifying running generation on remove.Fix
Skip type generation for the
removecommand, matching the surrounding convention.devanddeploystill regenerate types, so there is no staleness regression. A removed stage simply leaves the last generated types on disk, which is what the issue asks for.Verification
go build ./cmd/sst— succeeds.go vet ./pkg/project/— clean.gofmt— clean.go test ./pkg/project/... ./pkg/types/...— all pass exceptTestEnvForIncludesWranglerPath, which fails identically on an unmodifieddevcheckout (env_test.go:53: unexpected end of JSON input) and is unrelated to this change.Related
#6418 reports
directory not empty, rmdir '<path>/.sst/types'. I looked for it while in this code and could not reproduce or locate it: there is no.sst/typespath anywhere in the current source (pkg/project/path/path.godefines only.sst,.sst/platform,.sst/log,.sst/provider-lock.json), and the message is formatted the way Node reportsENOTEMPTY, not the way Go does. It most likely originates from SST v2 or from user tooling, so I have not touched it here.