JoshuaKGoldberg / JoshuaKGoldberg/create-typescript-app

🐛 Bug: Crash on "keyValidator._parse is not a function" when installed with pnpm

Open
#2,437 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.4k
Forks
89
Avg merge
1m
Merged PRs (30d)
3

Description

### Bug Report Checklist

- [x] I have tried restarting my IDE and the issue persists.
- [x] I have pulled in the newest version of the project.
- [x] I have [searched for related issues](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aissue) and found none that matched my issue.

### Expected

Running `create-typescript-app` in a repo that has it installed as a `devDependency` should transition the repo, the way it does when run through `npx` without a local install.

### Actual

It crashes before producing anything:

```plaintext
◇ Detected --preset everything from existing files on disk
◇ Detected existing remote origin repository
■ Error running create-typescript-app:
■ TypeError: keyValidator._parse is not a function
at ZodObject._parse (.../zod@3.25.76/node_modules/zod/v3/types.js:1961:37)
at ZodObject.safeParse (.../zod@3.25.76/node_modules/zod/v3/types.js:129:29)
at applyZodDefaults (.../bingo-stratum@0.5.13/node_modules/bingo-stratum/lib/creators/utils.js:3:28)
at block.produce (.../bingo-stratum@0.5.13/node_modules/bingo-stratum/lib/creators/createBlock.js:17:21)
at produceBlock (.../bingo-stratum@0.5.13/node_modules/bingo-stratum/lib/producers/produceBlock.js:9:26)
```

Reproduced on `create-typescript-app@2.64.0`, pnpm 10.30.1, Node 24.13.1, macOS.
It happens with or without a `create-typescript-app.config.mjs` present, and via both `pnpm exec create-typescript-app` and `npx create-typescript-app` once the local install exists.

```shell
pnpm add -D create-typescript-app
pnpm exec create-typescript-app
```

### Additional Info

It looks like a zod v3/v4 split. `pnpm why zod` in the affected repo:

```plaintext
create-typescript-app 2.64.0
├── zod 3.25.76
├─┬ bingo-stratum 0.5.13
│ └── zod 3.25.76 peer
└─┬ zod-tsconfig 0.2.0
└── zod 4.4.3
```

CTA declares `zod: ^3.25.76`, but [`blockTypeScript`](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/src/blocks/blockTypeScript.ts#L2) imports `CompilerOptionsSchema` from `zod-tsconfig@0.2.0`, which is built against zod v4.
So a v4 schema reaches `bingo-stratum`'s v3 `applyZodDefaults`, and v4 schemas have no `_parse`.

npm's flatter install seems to mask it, which is why plain `npx create-typescript-app` in a repo with no local install still works.
That also makes it invisible to anyone who never installs CTA locally, but it blocks the config-file transition workflow, since that requires the local install to import blocks from.

🎁

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the pnpm add -D and pnpm exec commands, then inspect src/blocks/blockTypeScript.ts and the package dependency declarations around zod-tsconfig and bingo-stratum. Confirm the fix by running the local create-typescript-app transition with and without a config file, ensuring it no longer crashes on keyValidator._parse.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.