Skip to content

fix(tsconfig): put scripts/ in a project so editors stop flagging it - #13

Merged
crisner1978 merged 3 commits into
mainfrom
fix/tsconfig-covers-scripts-and-tests
Aug 19, 2026
Merged

fix(tsconfig): put scripts/ in a project so editors stop flagging it#13
crisner1978 merged 3 commits into
mainfrom
fix/tsconfig-covers-scripts-and-tests

Conversation

@crisner1978

Copy link
Copy Markdown
Collaborator

The problem you hit

tsconfig.json included only ["src"], so nothing under scripts/ belonged to any project. An editor opening scripts/build-docs.ts falls back to inferred defaults — no types: ["node"], different module resolution — and reports node:fs, process and __dirname as unresolved.

Nothing was wrong with the file. It just wasn't part of a project.

Fix

Split the two configs by the job each actually does:

FileJobinclude
tsconfig.jsoneditor + typecheck["src", "scripts"]
tsconfig.build.jsonwhat tsup emits["src"] — now stated, not inherited

Stating it in the build config matters: it was inheriting ["src"] from the base, so widening the base would silently have widened the build too.

Safe either waytsup.config.ts lists its entry points explicitly and all of them are under src/.

What typechecking scripts/ found

Four errors, all regex capture groups being string | undefined under noUncheckedIndexedAccess. Three are type nits. One is a latent runtime bug:

constprops=entry[2]// string | undefinedconstdesc=props.match(...)// throws if the group didn't capture

Both sites now handle the undefined case.

test/ left excluded, on purpose

Including it surfaces 31 more of the same class. Worth doing — but it's its own change, not something to bundle into a config fix. Happy to follow up.

Verification

  • tsc --noEmit0 errors
  • tsup build — succeeds
  • 144/144 tests pass
  • Generator runs both ways: DOCS_REF=main and the local .env path

`findDocsPath()` resolved five ways, all filesystem — so regenerating
src/docs/data.ts meant having a docs.auto.dev checkout and pointing .env at
a path on one person's machine. Nobody else could reproduce the output, and
the committed result could drift from the docs it claims to mirror with
nothing to catch it.
Adds DOCS_REF as one more resolution strategy in the same function:
DOCS_REF=main pnpm build:docs && pnpm build:docs-data
DOCS_REF=feat/no-trials-copy pnpm build:docs
It shallow-clones at that ref and returns the path, so everything
downstream is untouched — the rest of the script only ever needed a
directory. DOCS_REPO overrides the repo if it ever moves.
Precedence: a CLI arg still wins, then DOCS_REF, then DOCS_PATH. A ref is a
more specific request than a path, so it takes priority over one; an
explicit argument beats both.
Uses ambient git credentials rather than plumbing a token: a developer's
existing auth locally, a token-backed remote in CI. docs.auto.dev is
private and this SDK is public, so a workflow using this needs a cross-org
read token. That is stated in the code rather than worked around, because
there is no way around it.
Verified against drivly/docs.auto.dev@feat/no-trials-copy: fetched,
converted all 12 product docs, and the regenerated data.ts dropped from 12
"Starter" availability lines to 0 with 12 "**Free**:" in their place —
matching drivly/docs.auto.dev#27.
data.ts itself is deliberately NOT in this commit. Generating committed
content from an unmerged branch pins it to a state that can still change;
regenerate from main once #27 lands.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@crisner1978
crisner1978 changed the base branch from main to feat/docs-ref-from-githubAugust 18, 2026 18:11
crisner1978and others added 2 commits August 18, 2026 14:23
`pnpm build:docs DOCS_REF=main` is the natural thing to type, and it
failed with:
Product docs not found at: DOCS_REF=main/content/docs/v2/products
which reports the symptom rather than the mistake. An env var placed after
the command arrives as a positional, and the CLI-arg branch is checked
first, so it was taken as a path.
Now it says what to do instead:
"DOCS_REF=main" looks like an environment variable, not a path.
Put it before the command:
DOCS_REF=main pnpm build:docs
Matches on SCREAMING_CASE followed by `=`, so real paths are unaffected —
verified all three forms still behave: bare path, DOCS_REF env var, and
the mistyped version.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tsconfig.json included only ["src"], so nothing under scripts/ belonged to
any project. An editor opening scripts/build-docs.ts fell back to inferred
defaults — no types:["node"], different module resolution — and reported
node:fs, process and __dirname as unresolved. Nothing was actually wrong
with the file; it just was not part of a project.
Split the two configs by their real jobs:
- tsconfig.json is the editor and `typecheck` project: src + scripts.
- tsconfig.build.json states include:["src"] itself rather than inheriting
it, so what tsup emits stays narrow no matter how the base widens.
Safe for the build either way — tsup lists its entry points explicitly and
all of them are under src/.
Typechecking scripts/ for the first time surfaced four real errors, all
regex capture groups being string|undefined under noUncheckedIndexedAccess.
One is a latent runtime bug rather than a type nit: in the TypeTable
parser, `props.match(...)` on a group that failed to capture would have
thrown. Both sites now handle the undefined case.
test/ is deliberately still excluded. Including it surfaces 31 more of the
same class, which is worth doing but is its own change — not something to
bundle into a config fix.
typecheck 0 errors, build succeeds, 144/144 tests pass, and the generator
runs both ways: DOCS_REF=main and the local .env path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@crisner1978
crisner1978force-pushed the fix/tsconfig-covers-scripts-and-tests branch from eb9f1e1 to 6d3c654CompareAugust 18, 2026 18:23
@crisner1978
crisner1978 changed the base branch from feat/docs-ref-from-github to mainAugust 19, 2026 15:11
@crisner1978
crisner1978 merged commit 9e91e62 into mainAug 19, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@crisner1978