fix: run type tests under TypeScript 6 and add missing response fields#1780
Conversation
TypeScript 6 makes it a hard error (TS5112) to pass files on the command line while a tsconfig.json is in scope, which broke `yarn test-types`: its run-types-gen step ran `tsc … test/typescript/*.ts`. Switch run-types-gen to project mode (`tsc -p test/typescript/tsconfig.json`) and have that config extend the root tsconfig so module resolution and skipLibCheck match `yarn build` (otherwise the emitted `ws` type trips TS1340). Add noEmit so the type-check never writes stray .js files next to the sources. The SDK source itself already type-checks and builds clean under TS 6.0.
|
Size Change: 0 B Total Size: 408 kB ℹ️ View Unchanged
|
End-to-end verificationDispatched the Scheduled tests workflow against this branch to run the real
|
Running the type tests end-to-end under TypeScript 6 surfaced three fields the backend returns that the SDK response types did not declare: - received_at on ConnectionOpen - is_confusable_folding_enabled on BlockList (and BlockListResponse) - feed_audit_logs_enabled on AppSettingsAPIResponse.app All added as optional fields.
Found by running the type tests against the live API; value is null, so typed boolean | null.
Confirmed green end-to-end ✅Re-ran the Scheduled tests workflow on this branch after adding all the response fields — it passes ( All four previously-undeclared fields are resolved. The app-settings object was diffed against the real API response (53 keys) to confirm |
|
🎉 This PR is included in version 9.47.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
CLA
Description of the changes, What, Why and How?
Two related changes, both driven by getting
yarn test-typeshealthy again.1. Run the API type-definition tests under TypeScript 6
What / Why. TypeScript was bumped to
^6.0.3in #1742. TS6 makes it a hard error (TS5112) to specify files on the command line while atsconfig.jsonis in scope:run-types-gendid exactly that (tsc … test/typescript/*.ts), so everyyarn test-typesrun failed. (It only ever surfaced in the weekly Scheduled tests job —type.ymlis disabled — and the 3× retry can't help a deterministic error.)How.
run-types-gennow runstsc -p test/typescript/tsconfig.json(project mode — no files on the command line, so no TS5112).tsconfig.jsonso module resolution (moduleResolution: bundler) andskipLibCheckmatch whatyarn buildemits — without it,tsc's bare CLI defaults fail onTS1340for the emittedimport("ws")type indist/types/insights.d.ts.noEmit: true(the old config had none, so on errortscemitted stray.jsfiles).The SDK source itself was already TS6-clean (
yarn types/build/lint/unit tests all pass under TS 6.0.3).2. Add missing fields to API response types
With the type tests running again, they surfaced three fields the live API returns that the SDK response types didn't declare (the same drift already failing the scheduled job back in May). Added as optional fields:
received_at→ConnectionOpenis_confusable_folding_enabled→BlockList/BlockListResponsefeed_audit_logs_enabled→AppSettingsAPIResponse.appVerification
run-types-genconfirmed to still catch drift; all three new fields recognized after rebuild;yarn types,yarn build,yarn lint,yarn vitest rungreen.yarn test-typesagainst the live API by dispatching the Scheduled tests workflow on this branch. The first run proved TS5112 was gone and failed only on the three drift fields above; a follow-up run after adding the fields confirms the result (see comments).Changelog
received_at(ConnectionOpen),is_confusable_folding_enabled(BlockList/BlockListResponse) andfeed_audit_logs_enabled(app settings) to the response types.yarn test-types) now run under TypeScript 6.