@ericrisco/rsc 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/manifest.json +1 -1
  2. package/package.json +1 -1
  3. package/scripts/lib/review-ledger.js +14 -3
  4. package/scripts/rsc.js +4 -2
  5. package/skills/gcp-essentials/SKILL.md +11 -8
  6. package/skills/gcp-essentials/references/networking-and-sql.md +4 -4
  7. package/skills/github-actions/SKILL.md +12 -12
  8. package/skills/github-actions/evals/cases.yaml +1 -1
  9. package/skills/github-actions/references/caching-and-matrix.md +5 -5
  10. package/skills/github-actions/references/oidc-deploys.md +4 -4
  11. package/skills/google-workspace/SKILL.md +15 -11
  12. package/skills/google-workspace/references/api-recipes.md +2 -2
  13. package/skills/google-workspace/references/auth-setup.md +1 -1
  14. package/skills/hetzner/SKILL.md +13 -12
  15. package/skills/hetzner/references/cloud-init.md +4 -2
  16. package/skills/hetzner/references/plans-and-locations.md +15 -14
  17. package/skills/huggingface/SKILL.md +15 -15
  18. package/skills/huggingface/evals/cases.yaml +1 -1
  19. package/skills/huggingface/references/endpoints-and-spaces.md +5 -3
  20. package/skills/huggingface/references/hub-and-cli.md +4 -4
  21. package/skills/huggingface/references/inference-providers.md +1 -1
  22. package/skills/huggingface/scripts/verify.sh +3 -2
  23. package/skills/instagram-api/SKILL.md +9 -9
  24. package/skills/instagram-api/evals/cases.yaml +1 -1
  25. package/skills/instagram-api/references/insights-metrics.md +1 -1
  26. package/skills/instagram-api/references/publish-reel.md +8 -7
  27. package/skills/linkedin-api/SKILL.md +3 -3
  28. package/skills/linkedin-api/evals/cases.yaml +1 -1
  29. package/skills/linkedin-api/references/api-reference.md +3 -3
  30. package/skills/review/SKILL.md +1 -1
  31. package/skills/typescript/SKILL.md +67 -20
  32. package/skills/typescript/evals/README.md +3 -3
  33. package/skills/typescript/evals/cases.yaml +4 -1
  34. package/skills/typescript/references/build-and-monorepo.md +82 -26
  35. package/skills/typescript/references/type-system.md +15 -4
  36. package/skills/typescript/scripts/verify.sh +20 -10
  37. package/targets/asdd-gate.mjs +9 -1
@@ -1,19 +1,24 @@
1
1
  # Build & monorepo config
2
2
 
3
- Field-by-field tsconfig, project references, resolution matrix, `tsgo`/TS7 adoption, and
4
- declaration publishing. All targets TypeScript 5.9. Read the section you need.
3
+ Field-by-field tsconfig, project references, resolution matrix, running TypeScript 7 next to
4
+ JS-API tools, and declaration publishing. All targets TypeScript 7 (`typescript` 7.0.2,
5
+ binary `tsc`). Read the section you need.
5
6
 
6
7
  ## tsconfig fields that earn their place
7
8
 
8
9
  | Field | Set to | Why |
9
10
  | --- | --- | --- |
10
- | `strict` | `true` | Turns on the whole family (`noImplicitAny`, `strictNullChecks`, `strictFunctionTypes`, …). Non-negotiable. |
11
+ | `strict` | `true` | Turns on the whole family (`noImplicitAny`, `strictNullChecks`, `strictFunctionTypes`, …). Default in TS 7; write it anyway. |
11
12
  | `noUncheckedIndexedAccess` | `true` | `arr[i]` / `rec[k]` become `T \| undefined` — the runtime truth. |
12
13
  | `verbatimModuleSyntax` | `true` | Forces explicit `import type`; never emits a type-only import as a runtime `require`; blocks `export default` in CJS-emitted modules. |
13
14
  | `isolatedModules` | `true` | Guarantees each file transpiles standalone, so esbuild/swc/babel are safe. |
14
15
  | `skipLibCheck` | `true` | Skips type-checking `node_modules` `.d.ts` — large build-time win, negligible risk. |
15
16
  | `resolveJsonModule` | `true` | Import `*.json` with inferred types. |
16
17
  | `moduleDetection` | `force` | Treats every file as a module (no accidental global scripts). |
18
+ | `rootDir` | `"./src"` | Defaults to the tsconfig's folder; without it, `outDir` mirrors `src/` as `dist/src/`. |
19
+ | `types` | `["node", …]` | Defaults to `[]`: no `@types/*` global is visible until listed. `["*"]` loads them all (slower, rarely right). |
20
+ | `noUncheckedSideEffectImports` | `true` (default) | `import "./x.css"` must resolve; declare the module (`declare module "*.css";`) when a bundler handles it. |
21
+ | `erasableSyntaxOnly` | `true` (Node type stripping) | Rejects `enum`, `namespace`, parameter properties — syntax that cannot be erased. |
17
22
  | `noEmit` | `true` (apps) | A bundler emits; `tsc` only type-checks. Libraries set it `false` to emit `.d.ts`. |
18
23
  | `composite` | `true` (referenced pkgs) | Required for project references; enables incremental `.tsbuildinfo`. |
19
24
 
@@ -21,7 +26,7 @@ declaration publishing. All targets TypeScript 5.9. Read the section you need.
21
26
 
22
27
  | | `moduleResolution: "bundler"` | `moduleResolution: "nodenext"` |
23
28
  | --- | --- | --- |
24
- | Pair `module` with | `"esnext"` or `"preserve"` | `"nodenext"` |
29
+ | Pair `module` with | `"preserve"` (also `"esnext"`, `"commonjs"`) | `"nodenext"` |
25
30
  | Who runs the output | a bundler (Vite, esbuild, webpack, Next) | Node directly |
26
31
  | Relative import extension | omit (`import "./util"`) | required (`import "./util.js"`) |
27
32
  | `package.json` `exports`/`imports` | resolved | resolved |
@@ -30,7 +35,9 @@ declaration publishing. All targets TypeScript 5.9. Read the section you need.
30
35
  | Choose when | app/library bundled before it ships | library/script Node executes as-is |
31
36
 
32
37
  Rule of thumb: if anything bundles the code before it runs, use `bundler`. If Node loads the
33
- `.js` directly, use `nodenext` and write the `.js` extension on relative imports.
38
+ `.js` directly, use `nodenext` and write the `.js` extension on relative imports. Under
39
+ `nodenext`, `package.json` `"type": "module"` makes `.ts` files ESM; without it they are CJS.
40
+ `node10`/`node` and `classic` resolution do not exist in TypeScript 7.
34
41
 
35
42
  ## Project references (the monorepo backbone)
36
43
 
@@ -50,7 +57,8 @@ Layout: one `tsconfig.base.json` at the root with the strict flags, then per-pac
50
57
  "moduleResolution": "nodenext",
51
58
  "declaration": true,
52
59
  "declarationMap": true,
53
- "composite": true
60
+ "composite": true,
61
+ "types": ["node"]
54
62
  }
55
63
  }
56
64
  ```
@@ -64,8 +72,10 @@ Layout: one `tsconfig.base.json` at the root with the strict flags, then per-pac
64
72
  }
65
73
  ```
66
74
 
67
- - Build the whole graph in dependency order: `tsc -b` (or `tsgo -b`). It caches per package via
68
- `.tsbuildinfo` and only rebuilds what changed.
75
+ - Build the whole graph in dependency order: `tsc -b`. It caches per package via
76
+ `.tsbuildinfo` and only rebuilds what changed. TypeScript 7 builds independent projects
77
+ concurrently (`--builders <n>`) and type-checks each with `--checkers <n>` (default 4);
78
+ `--singleThreaded` turns both off. Lower them when CI runners are short on memory.
69
79
  - Each referenced package needs `composite: true` and must emit declarations.
70
80
  - A package may only import from packages it lists under `references`; TS enforces the boundary,
71
81
  which kills accidental cross-package coupling.
@@ -75,35 +85,77 @@ Layout: one `tsconfig.base.json` at the root with the strict flags, then per-pac
75
85
  ```jsonc
76
86
  {
77
87
  "compilerOptions": {
78
- "baseUrl": ".",
79
- "paths": { "@core/*": ["packages/core/src/*"] }
88
+ "paths": { "@core/*": ["./packages/core/src/*"] }
80
89
  }
81
90
  }
82
91
  ```
83
92
 
93
+ `paths` entries resolve relative to the tsconfig that declares them; `baseUrl` does not exist
94
+ in TypeScript 7 (TS5102). A legacy catch-all `baseUrl: "./src"` becomes
95
+ `"paths": { "*": ["./src/*"] }`.
96
+
84
97
  `paths` only rewrites types for the **type-checker**. The runtime/bundler must mirror it:
85
98
  Vite (`resolve.alias`), Node (`package.json` `imports` with the `#`-prefix subpath convention),
86
99
  or a runtime resolver. Aliases that the bundler does not mirror compile fine and crash at
87
- runtime — prefer `package.json` `imports` (`"#core/*"`) when Node runs the code, since Node
88
- resolves those natively.
100
+ runtime — prefer `package.json` `imports` (`"#core/*"`, or `"#/*": "./dist/*"`) when Node runs
101
+ the code, since Node resolves those natively and TypeScript follows them under `nodenext` and
102
+ `bundler`.
89
103
 
90
- ## tsgo / TypeScript 7 adoption
104
+ ## TypeScript 7 in practice
91
105
 
92
- The native (Go) compiler is in preview as `@typescript/native-preview`, ships the `tsgo`
93
- binary, and type-checks ~10x faster (Microsoft's VS Code repo, 1.5M LOC: 89s -> 8.74s, 10.2x).
106
+ `npm i -D typescript` installs the native compiler; the binary is `tsc` and it takes the same
107
+ flags as before. Platform binaries arrive as optional dependencies
108
+ (`@typescript/typescript-<os>-<arch>`), so a lockfile generated on one OS must keep those
109
+ optional entries for CI on another.
94
110
 
95
111
  ```bash
96
- npm i -D @typescript/native-preview
97
- npx tsgo --noEmit # same flags as tsc
98
- npx tsgo -b # build a project-references graph
112
+ npm i -D typescript@^7
113
+ npx tsc -v # Version 7.x
114
+ npx tsc --noEmit # check one project
115
+ npx tsc -b # build a project-references graph
116
+ npx tsc -b --builders 2 --checkers 2 # cap parallelism on a small runner
117
+ ```
118
+
119
+ **What 7.0 does not have: a programmatic API.** Anything that does `require("typescript")` for
120
+ the compiler or language-service API keeps using 6.0. The compatibility package
121
+ `@typescript/typescript6` ships the 6.0 API and a `tsc6` binary. Two setups:
122
+
123
+ ```jsonc
124
+ // A. Tools import "typescript" (typescript-eslint, template tooling): alias it to 6.0,
125
+ // and install 7 under another name for the real `tsc`.
126
+ {
127
+ "devDependencies": {
128
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
129
+ "@typescript/native": "npm:typescript@^7.0.2"
130
+ }
131
+ }
99
132
  ```
100
133
 
101
- Adoption steps:
102
- 1. Add it as a dev dependency; keep `typescript` (`tsc`) installed as the stable fallback.
103
- 2. Run `tsgo --noEmit` in CI for the speed win; if a diagnostic differs, fall back to `tsc` for
104
- that check and report it — the preview does not yet cover 100% of `tsc` behavior.
105
- 3. On a project whose `typescript` is 7.x, `tsc` is already the native compiler and the preview
106
- package is unnecessary; check `npx tsc -v` before adding it.
134
+ ```jsonc
135
+ // B. Only the CLI matters: plain typescript 7, plus 6.0 for the one tool that needs it.
136
+ {
137
+ "devDependencies": {
138
+ "typescript": "^7.0.2",
139
+ "@typescript/typescript6": "^6.0.2"
140
+ }
141
+ }
142
+ ```
143
+
144
+ Check after install which `tsc` the scripts resolve (`npx tsc -v`); in setup A, `npx tsc`
145
+ must print 7.x and `npx tsc6 -v` 6.0.x.
146
+
147
+ **Editors.** The language service runs over LSP. In VS Code, the TypeScript Native Preview
148
+ extension (`TypeScriptTeam.native-preview`) provides it, with commands to enable or disable the
149
+ TypeScript 7 language server per workspace. Embedded-language tooling (Vue, Svelte, Astro,
150
+ MDX, Angular templates) still drives 6.0; Angular projects check with `tsc` 7 on the CLI and
151
+ keep 6.0 in the editor.
152
+
153
+ **Migrating a 5.x project.** Upgrade to 6.0 first and clear every deprecation without
154
+ `ignoreDeprecations`; turn on `stableTypeOrdering` to surface the type-ordering differences
155
+ (it slows 6.0 checks by up to 25%, so use it for the migration only). Then switch to 7: a
156
+ clean 6.0 build compiles identically. `ignoreDeprecations: "6.0"` does not rescue removed
157
+ options on 7. The experimental `ts5to6` codemod rewrites `baseUrl` and `rootDir`. Field-level
158
+ replacements are in the SKILL body's "Coming from 5.x" table.
107
159
 
108
160
  ## Declaration emit & publishing a library
109
161
 
@@ -132,10 +184,14 @@ Adoption steps:
132
184
  - `types`/`typesVersions` must point at the emitted `.d.ts`; put `types` **first** in each
133
185
  `exports` condition so resolvers find it.
134
186
  - For libraries, do not set `noEmit`; let `tsc -b` (or your bundler with dts plugin) emit.
187
+ - TypeScript 7 orders types deterministically
188
+ (`stableTypeOrdering` is always on), so emitted `.d.ts` stays stable across runs.
135
189
  - Validate the published surface with a tool like `@arethetypeswrong/cli` before release.
136
190
 
137
191
  ## Running TS without a build
138
192
 
139
193
  - `tsx file.ts` — fast esbuild-based runner for scripts and dev (replaces `ts-node`).
140
- - Node `--experimental-strip-types` (Node 22+) runs `.ts` by erasing types; no type-checking.
141
- - Both *execute*; neither *checks*. Always keep `tsc --noEmit` (or `tsgo --noEmit`) in CI.
194
+ - Node's built-in type stripping runs `.ts` by erasing types (`node file.ts` on current Node;
195
+ older lines need `--experimental-strip-types`); no type-checking. Pair it with
196
+ `erasableSyntaxOnly: true` and `verbatimModuleSyntax: true` so only erasable syntax compiles.
197
+ - Both *execute*; neither *checks*. Always keep `tsc --noEmit` (or `tsc -b`) in CI.
@@ -1,6 +1,6 @@
1
1
  # Type-system deep dives
2
2
 
3
- Recipes the SKILL body points to. All target TypeScript 5.9. Read the relevant section, not
3
+ Recipes the SKILL body points to. All target TypeScript 7. Read the relevant section, not
4
4
  the whole file.
5
5
 
6
6
  ## Conditional types + `infer`
@@ -48,6 +48,15 @@ type CSSVar = `--${string}`;
48
48
  type ParseId<T> = T extends `user_${infer N}` ? N : never; // ParseId<"user_42"> = "42"
49
49
  ```
50
50
 
51
+ `infer` over a template literal consumes whole code points:
52
+
53
+ ```ts
54
+ type HeadTail<S> = S extends `${infer H}${infer R}` ? [H, R] : never;
55
+ type T = HeadTail<"😀abc">; // ["😀", "abc"], not half a surrogate pair
56
+ ```
57
+
58
+ Character-counting utility types therefore count code points, not UTF-16 units (`"😀".length` is still `2` at runtime).
59
+
51
60
  ## Recursive types (with care)
52
61
 
53
62
  Recursion is allowed but the depth is bounded by the instantiation-depth limit; deep tuple
@@ -116,7 +125,9 @@ declare global {
116
125
  export {}; // make this file a module so `declare global` is allowed
117
126
  ```
118
127
 
119
- `type` aliases do **not** merge — only `interface` and `namespace` do.
128
+ `type` aliases do **not** merge — only `interface` and `namespace` do. Write internal
129
+ namespaces with the `namespace` keyword; `module Foo {}` is an error (TS1540), while
130
+ `declare module "pkg"` for module augmentation is unchanged.
120
131
 
121
132
  ## Function overloads
122
133
 
@@ -150,8 +161,8 @@ assertDefined(v);
150
161
  v.toUpperCase(); // v is string here
151
162
  ```
152
163
 
153
- TS 5.5+ infers type predicates for simple filter callbacks, so
154
- `arr.filter((x) => x != null)` now narrows to `T[]` without a hand-written predicate in many
164
+ TypeScript infers type predicates for simple filter callbacks, so
165
+ `arr.filter((x) => x != null)` narrows to `T[]` without a hand-written predicate in many
155
166
  cases — but an explicit predicate is still clearer for non-trivial checks.
156
167
 
157
168
  ## `const` type parameters & `NoInfer`
@@ -4,21 +4,25 @@
4
4
  # message when no TS/node is available (no false failure on a clean machine).
5
5
  set -euo pipefail
6
6
 
7
- # Resolve a type-checker: prefer tsgo (TS7 preview), else npx typescript's tsc.
8
- # Strict flags are passed on the CLI because naming files on the CLI bypasses tsconfig.
9
- FLAGS="--noEmit --strict --noUncheckedIndexedAccess --target esnext --module nodenext --moduleResolution nodenext"
10
- if command -v tsgo >/dev/null 2>&1; then
11
- CHECK="tsgo"
7
+ # Resolve a TypeScript 7 type-checker: a `tsc` on PATH that reports 7.x, else
8
+ # `npx` fetching typescript@^7 (the native compiler, binary `tsc`).
9
+ # Strict flags are passed on the CLI; --ignoreConfig keeps any tsconfig.json out of
10
+ # the way (TS 7 refuses CLI file names next to a tsconfig.json without it).
11
+ FLAGS="--ignoreConfig --noEmit --strict --noUncheckedIndexedAccess --target esnext --module nodenext --moduleResolution nodenext"
12
+ if command -v tsc >/dev/null 2>&1 && tsc -v 2>/dev/null | grep -Eq 'Version ([7-9]|[1-9][0-9])\.'; then
13
+ CHECK="tsc"
12
14
  elif command -v npx >/dev/null 2>&1; then
13
- CHECK="npx -y -p typescript tsc"
15
+ CHECK="npx -y -p typescript@^7 tsc"
14
16
  else
15
- echo "SKIP: no tsgo and no npx on PATH — cannot type-check. (exit 0)"
17
+ echo "SKIP: no TypeScript 7 tsc and no npx on PATH — cannot type-check. (exit 0)"
16
18
  exit 0
17
19
  fi
18
20
 
19
21
  TMP="$(mktemp -d)"
20
22
  trap 'rm -rf "$TMP"' EXIT
21
23
 
24
+ echo "checker: $( (cd "$TMP" && $CHECK -v) 2>/dev/null || echo unknown)"
25
+
22
26
  # good.ts: exhaustive never guard MUST pass.
23
27
  cat > "$TMP/good.ts" <<'TS'
24
28
  type S = { k: "a" } | { k: "b" };
@@ -42,11 +46,17 @@ export function f(s: S): number {
42
46
  }
43
47
  TS
44
48
 
49
+ # index.ts: noUncheckedIndexedAccess — arr[0] is number | undefined, MUST fail.
50
+ cat > "$TMP/index.ts" <<'TS'
51
+ export function first(arr: number[]): number { return arr[0]; }
52
+ TS
53
+
45
54
  run() { ( cd "$TMP" && $CHECK $FLAGS "$1" ) >/dev/null 2>&1; }
46
55
 
47
56
  fail=0
48
- if run good.ts; then echo "PASS: good.ts type-checks"; else echo "FAIL: good.ts should compile"; fail=1; fi
49
- if run bad.ts; then echo "FAIL: bad.ts should NOT compile (exhaustiveness)"; fail=1; else echo "PASS: bad.ts rejected"; fi
57
+ if run good.ts; then echo "PASS: good.ts type-checks"; else echo "FAIL: good.ts should compile"; fail=1; fi
58
+ if run bad.ts; then echo "FAIL: bad.ts should NOT compile (exhaustiveness)"; fail=1; else echo "PASS: bad.ts rejected"; fi
59
+ if run index.ts; then echo "FAIL: index.ts should NOT compile (noUncheckedIndexedAccess)"; fail=1; else echo "PASS: index.ts rejected"; fi
50
60
 
51
61
  if [ "$fail" -ne 0 ]; then echo "verify.sh: FAILED"; exit 1; fi
52
- echo "verify.sh: OK — strict + exhaustiveness enforced"
62
+ echo "verify.sh: OK — strict + exhaustiveness + indexed access enforced"
@@ -449,12 +449,20 @@ export function branchCheck(
449
449
  reviewedStill(repo, sha, trunk, sello, cfg, tip || 'HEAD'),
450
450
  );
451
451
  if (best >= required) return null;
452
+ // A child repo keeps its evidence in the workspace; the panel must name the child's commit.
453
+ // Forward slashes, and single quotes around anything unusual: the line is meant to be pasted
454
+ // into a shell, and a directory named after a branch may hold `$()`, `;` or a backtick.
455
+ const at = relative(evidence, repo).split('\\').join('/');
456
+ const repoFlag =
457
+ evidence === repo
458
+ ? ''
459
+ : ` --repo ${/^[\w./-]+$/.test(at) ? at : `'${at.replace(/'/g, "'\\''")}'`}`;
452
460
  return (
453
461
  `Branch "${branch}" is risk tier 2 and its spec passes, but no review panel of ${required} lens(es) is recorded for it` +
454
462
  `${best ? ` (largest still valid: ${best})` : ''}. Tier 2 is reviewed by the full panel, not by one reviewer, and a panel covers ` +
455
463
  'the commit it was recorded on: code committed after it needs the panel again (the record is self-attested, like the sello). ' +
456
464
  `Recover: run the ${required} fresh-context refuters (correctness, security, tests) on the branch, then record it — ` +
457
- `\`npx @ericrisco/rsc review ledger panel ${slugs[0]}/closing --lenses correctness,security,tests\` — and push again. ` +
465
+ `\`npx @ericrisco/rsc review ledger panel ${slugs[0]}/closing --lenses correctness,security,tests${repoFlag}\` (run from ${evidence === repo ? 'the repository' : 'the workspace root'}) — and push again. ` +
458
466
  'To turn this gate off for the project: create `.rsc/.no-asdd-gate`.'
459
467
  );
460
468
  }