Starter Brains · TypeScript

TypeScript & Frontend

20 lessons from merged PRs in TypeScript, Vite and Prisma, summarized in our own words. Real framework gotchas for your AI coding agent.

20 PR lessonsvitejs/vite · MIT (7)microsoft/TypeScript · Apache-2.0 (7)prisma/prisma · Apache-2.0 (6)
brain_seed_starter(instance_id="<your-brain-id>", stack="typescript")

20 fixes from merged PRs

Every lesson below is a short summary in our own words and links to its upstream GitHub pull request in a permissive-licensed repository. Seed them into your Brain so your coding agent can find them when a similar problem comes up.

  1. vite:pr-20518MITvitejs/vite#20518 ↗
    Symptom

    Vite build with an empty CSS or SCSS file as a rollup entry emits an empty JS file and a manifest entry pointing to it instead of a CSS asset.

    Cause and fix

    Cause: The CSS plugin guarded asset emission with a truthiness check on the chunk's CSS string, so an empty string skipped the CSS pipeline and the chunk was treated as plain JS. Fix: In plugins/css.ts the chunkCSS initialization and check were changed to tell apart 'no CSS processed' from 'processed but empty', so CSS entries always go through CSS emission.

  2. vite:pr-22357MITvitejs/vite#22357 ↗
    Symptom

    An esbuild plugin in optimizeDeps.esbuildOptions.plugins throws when its build.onEnd callback reads result.metafile under Vite's Rolldown compatibility layer.

    Cause and fix

    Cause: convertEsbuildPluginToRolldownPlugin handed onEnd callbacks a proxy object that raised an error on any property access instead of a normal BuildResult. Fix: The converter now passes a minimal valid esbuild BuildResult with empty errors and warnings arrays and the other optional fields undefined, so checks like a missing metafile behave as in esbuild.

  3. vite:pr-23295MITvitejs/vite#23295 ↗
    Symptom

    Setting build.target to esnext still lowers CSS during minification with Lightning CSS, and a :open rule disappeared from the minified output.

    Cause and fix

    Cause: convertTargets returned an empty object when all targets were esnext, and Lightning CSS interprets targets: {} as no browser supporting anything, unlike undefined which means no constraints. Fix: convertTargets now returns undefined rather than an empty object when every entry is esnext or cssTarget is false, and a unit test covers it.

  4. vite:pr-21668MITvitejs/vite#21668 ↗
    Symptom

    When vite build or another CLI command fails with an AggregateError, the console shows only the top-level message and stack, hiding the individual errors inside it.

    Cause and fix

    Cause: The CLI error handlers in cli.ts logged e.stack, which does not include the nested errors of an AggregateError and is undefined for non-Error throws. Fix: All four catch blocks in cli.ts (dev server, build, optimize deps, preview) now log util.inspect(e), which prints nested errors and tolerates non-Error values.

  5. vite:pr-22342MITvitejs/vite#22342 ↗
    Symptom

    Using import.meta.glob with a custom JSX import source makes the dependency scan fail, trying to resolve react/jsx-runtime despite the configured JSX settings.

    Cause and fix

    Cause: doTransformGlobImport in the optimizer scanner called transformSync without the user's configured OXC transform options, so custom JSX settings were ignored. Fix: The scanner's glob-import transform now passes the user-configured OXC transform options into transformSync.

  6. vite:pr-22947MITvitejs/vite#22947 ↗
    Symptom

    With build.chunkImportMap enabled, a CSS-only change leaves the parent JS chunk's filename the same while its cached preload list now references a different CSS file.

    Cause and fix

    Cause: Dynamic JS dependencies used stable import-map specifiers, but extracted CSS dependencies were still referenced by content-hashed filenames. Fix: Each emitted CSS asset is now tracked back to its chunk, a stable CSS entry is added to the generated import map, and preload rewriting uses that specifier; builds without chunkImportMap are unchanged.

  7. vite:pr-21963MITvitejs/vite#21963 ↗
    Symptom

    SSR builds with ssr.target set to webworker emit createRequire(import.meta.url) via Rolldown, which crashes on Cloudflare Workers where import.meta.url is undefined.

    Cause and fix

    Cause: resolveBuildEnvironmentOptions defaulted rolldownOptions.platform to node for every server build, ignoring the webworker target. Fix: The already computed isSsrTargetWebworkerEnvironment flag is now used so webworker SSR builds default the platform to browser instead of node.

  8. TypeScript:pr-56418Apache-2.0microsoft/TypeScript#56418 ↗
    Symptom

    TypeScript rejects in/out variance modifiers on a type alias whose body points at a generic interface, although the same modifiers work when the alias points at an object type.

    Cause and fix

    Cause: The checker's list of permitted object kinds for variance modifiers lacked reference types, which is how generic interfaces are represented. Fix: Added ObjectFlags.Reference to the permitted flags in checker.ts and added tests confirming nested references to object or primitive shapes still error only in the right cases.

  9. TypeScript:pr-57403Apache-2.0microsoft/TypeScript#57403 ↗
    Symptom

    Nested generic function calls in TypeScript inference leak an unbound type parameter from the outer signature into the inferred result type.

    Cause and fix

    Cause: Outer type parameters are projected onto inner expression types, but argument expressions were instantiated with the signature mapper, which over-eagerly instantiated inner calls, rather than the inference context. Fix: The checker now instantiates argument expression types with the inference context's mapper to complete the projected types, with new tests showing the inner-call case.

  10. TypeScript:pr-57871Apache-2.0microsoft/TypeScript#57871 ↗
    Symptom

    TypeScript 5.4 reports error 2590, a union type too complex to represent, when narrowing with large interfaces that worked on 5.3.

    Cause and fix

    Cause: Intersecting many union constituents built a huge cartesian product of members even though most combinations collapse to never. Fix: Intersections with four or more constituents that include unions are now split into two groups, so A & B & C & D is computed as (A & B) & (C & D), creating a few extra temporary types.

  11. TypeScript:pr-57938Apache-2.0microsoft/TypeScript#57938 ↗
    Symptom

    tsc --watch stops detecting file changes on macOS 14.4 when watching via directory-level fsevents, printing 'found 0 errors' without recompiling.

    Cause and fix

    Cause: The fs.watch event handler filtered events by timestamp even for directories, but a directory can emit change events for many reasons, so valid events were dropped. Fix: In sys.ts the timestamp-based filtering is no longer applied to directory watchers, and the virtual file system test helper was corrected to send realistic timestamps and events.

  12. TypeScript:pr-53611Apache-2.0microsoft/TypeScript#53611 ↗
    Symptom

    Setting isolatedModules: true explicitly alongside verbatimModuleSyntax: true triggers a compiler error, which breaks tools like Next.js that force isolatedModules on.

    Cause and fix

    Cause: The compiler in program.ts rejected an explicit isolatedModules value whenever verbatimModuleSyntax was enabled, even though the latter already implies it. Fix: The check in program.ts that errored on the combination was removed, and the related baseline error files were updated.

  13. TypeScript:pr-55851Apache-2.0microsoft/TypeScript#55851 ↗
    Symptom

    The TypeScript compiler crashes with RangeError: Map maximum size exceeded while checking projects using large type libraries such as antd or fontawesome types.

    Cause and fix

    Cause: Computing a relation between huge unions added so many entries to the relation cache that the underlying JavaScript Map hit Node's limit of about 16 million entries. Fix: The checker now reports an excessive-complexity error when computing one relation adds more cache entries than one eighth of the cache's current capacity, instead of crashing.

  14. TypeScript:pr-57250Apache-2.0microsoft/TypeScript#57250 ↗
    Symptom

    Organize Imports merges two imports from the same module into one statement even though they have different import attributes (with/assert clauses).

    Cause and fix

    Cause: The coalescing logic in organizeImports compared only module specifiers and ignored import attributes. Fix: Imports are now merged only if their import attributes also match; statements with the same specifier but different attributes are kept apart without being reordered.

  15. prisma:pr-28694Apache-2.0prisma/prisma#28694 ↗
    Symptom

    Prisma's env() helper gives TS2344 when its generic argument is an interface rather than a type alias.

    Cause and fix

    Cause: The generic constraint Record<string, string | undefined> demands an index signature, which interfaces do not have. Fix: The env signature was simplified and a new EnvKey helper type restricts keys to string-or-undefined values, so both interfaces and type aliases type-check; a type-level test covers both and runtime is untouched.

  16. prisma:pr-25900Apache-2.0prisma/prisma#25900 ↗
    Symptom

    Prisma Client infers the wrong result type when omit and include are combined inside a nested include, even though the returned data is correct.

    Cause and fix

    Cause: With nested select or include, TypeScript loses track of the keys of the argument type and discards the omit key during inference. Fix: In Result.ts the omit key is re-attached at that point with an A & { omit: A['omit'] } intersection, and a functional test for the nested case was added.

  17. prisma:pr-28600Apache-2.0prisma/prisma#28600 ↗
    Symptom

    Installing Prisma packages on Node 25 fails when strict engine checks are enabled, although newer Node versions are not known to be broken.

    Cause and fix

    Cause: The engines field in the root, cli and client package.json files capped the allowed Node versions, blocking anything above the listed range. Fix: The Node version constraints in the three package.json files were loosened so higher Node releases are no longer rejected by engine checks.

  18. prisma:pr-29198Apache-2.0prisma/prisma#29198 ↗
    Symptom

    Using Prisma.skip in a query with a $allModels.$allOperations query extension throws a runtime validation error, so strictUndefinedChecks does not work with extensions.

    Cause and fix

    Cause: deepCloneArgs treated the Skip instance as a plain object and cloned it into {}, which later failed the instanceof Skip check in serializeJsonQuery. Fix: deepCloneValue now returns early for Skip instances via isSkip(x), as it already does for ObjectEnumValue and FieldRef, with unit tests for top-level, nested and array cases.

  19. prisma:pr-29177Apache-2.0prisma/prisma#29177 ↗
    Symptom

    Reading or writing Bytes fields through @prisma/adapter-pg fails under Vitest or Jest with the jsdom environment.

    Cause and fix

    Cause: jsdom runs in a separate JavaScript realm, so a Uint8Array created there fails instanceof Uint8Array checks performed in Node's realm. Fix: A cross-realm isUint8Array() helper in utils.ts, based on Object.prototype.toString, replaced the instanceof Uint8Array checks in client-engine-runtime files such as data-mapper.ts.

  20. prisma:pr-29426Apache-2.0prisma/prisma#29426 ↗
    Symptom

    When a driver adapter throws an error Prisma does not recognise, the resulting message reads [object Object], leaving no hint which error kind occurred.

    Cause and fix

    Cause: The assertNever call in getErrorCode and renderErrorMessage interpolated err.cause, a plain object, into a template literal, which coerces it to [object Object]. Fix: The interpolation was replaced with the existing safeJsonStringify utility, which also handles BigInt and Uint8Array values, so the unknown cause is printed in readable form.

Explain it once. Every AI knows it. By default, no generative AI model reads or rewrites your lessons. A small ranking model in the EU only scores them. Starter lessons never overwrite your team's own project lessons.