Skip to content

Commit 8e49611

Browse files
authored
fix: run type tests under TypeScript 6 and add missing response fields (#1780)
## CLA - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required). - [x] Code changes are tested ## Description of the changes, What, Why and How? Two related changes, both driven by getting `yarn test-types` healthy again. ### 1. Run the API type-definition tests under TypeScript 6 **What / Why.** TypeScript was bumped to `^6.0.3` in #1742. TS6 makes it a **hard error (TS5112)** to specify files on the command line while a `tsconfig.json` is in scope: ``` error TS5112: tsconfig.json is present but will not be loaded if files are specified on commandline. Use '--ignoreConfig' to skip this error. ``` `run-types-gen` did exactly that (`tsc … test/typescript/*.ts`), so every `yarn test-types` run failed. (It only ever surfaced in the weekly **Scheduled tests** job — `type.yml` is disabled — and the 3× retry can't help a deterministic error.) **How.** - `run-types-gen` now runs `tsc -p test/typescript/tsconfig.json` (project mode — no files on the command line, so no TS5112). - That config now **extends the root `tsconfig.json`** so module resolution (`moduleResolution: bundler`) and `skipLibCheck` match what `yarn build` emits — without it, `tsc`'s bare CLI defaults fail on `TS1340` for the emitted `import("ws")` type in `dist/types/insights.d.ts`. - Added `noEmit: true` (the old config had none, so on error `tsc` emitted stray `.js` files). 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` → `ConnectionOpen` - `is_confusable_folding_enabled` → `BlockList` / `BlockListResponse` - `feed_audit_logs_enabled` → `AppSettingsAPIResponse.app` ### Verification - **Local (TS 6.0.3):** TS5112 gone; `run-types-gen` confirmed to still catch drift; all three new fields recognized after rebuild; `yarn types`, `yarn build`, `yarn lint`, `yarn vitest run` green. - **End-to-end:** ran the real `yarn test-types` against 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 - Add optional `received_at` (`ConnectionOpen`), `is_confusable_folding_enabled` (`BlockList`/`BlockListResponse`) and `feed_audit_logs_enabled` (app settings) to the response types. - Internal: the API type-definition tests (`yarn test-types`) now run under TypeScript 6.
1 parent ae1c97e commit 8e49611

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"test": "yarn test-unit",
9999
"test-types": "yarn run-test-types && yarn run-types-gen",
100100
"run-test-types": "node test/typescript/index.js",
101-
"run-types-gen": "tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
101+
"run-types-gen": "tsc -p test/typescript/tsconfig.json",
102102
"test-unit": "vitest",
103103
"test-coverage": "vitest run --coverage",
104104
"fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export type AppSettingsAPIResponse = APIResponse & {
8383
app?: {
8484
id?: string | number;
8585
allow_multi_user_devices?: boolean;
86+
feed_audit_logs_enabled?: boolean;
87+
moderation_onboarding_complete?: boolean | null;
8688
// TODO
8789
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8890
call_types: any;
@@ -2533,6 +2535,7 @@ export type BlockList = {
25332535
team?: string;
25342536
type?: string;
25352537
validate?: boolean;
2538+
is_confusable_folding_enabled?: boolean;
25362539
is_leet_check_enabled?: boolean;
25372540
is_plural_check_enabled?: boolean;
25382541
};
@@ -2692,6 +2695,7 @@ export type ConnectionOpen = {
26922695
connection_id: string;
26932696
cid?: string;
26942697
created_at?: string;
2698+
received_at?: string;
26952699
me?: OwnUserResponse;
26962700
type?: string;
26972701
};

test/typescript/tsconfig.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
{
2+
// Type-checks the generated API response fixtures (data.ts) and the
3+
// hand-written unit-test.ts against the built declarations in dist/types.
4+
//
5+
// Extends the root config so module resolution, lib and strictness (notably
6+
// moduleResolution "bundler" and skipLibCheck) match what `yarn build`
7+
// emits. Invoked via `tsc -p` (see the run-types-gen script): passing the
8+
// files on the command line instead trips TypeScript 6's error TS5112
9+
// ("tsconfig.json is present but will not be loaded if files are specified
10+
// on commandline").
11+
"extends": "../../tsconfig.json",
212
"compilerOptions": {
3-
"esModuleInterop": true,
4-
"noImplicitAny": true,
5-
"strict": true,
6-
"strictNullChecks": true
7-
}
13+
"noEmit": true,
14+
"rootDir": "."
15+
},
16+
"include": ["./*.ts"]
817
}

0 commit comments

Comments
 (0)