Skip to content

Negated Types: Constrain Promise<T> to forbid Thenable T - #65010

Closed
Wesley Wigham (weswigham) wants to merge 24 commits into
mainfrom
weswigham/negated-types-promise-constraint
Closed

Wesley Wigham (weswigham) wants to merge 24 commits into
mainfrom
weswigham/negated-types-promise-constraint

Conversation

@weswigham

@weswigham Wesley Wigham (weswigham) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

This is breaking like you would not believe. Not because an unconstrained and constrained Promise won't merge - we already allow that for interfaces - no - because Promise<string> isn't a valid instantiation because you can, pathologically, assign a string & {then(): number} to string, meaning string (and all primitives) is possibly thenable.

This is the kind of break that, while it looks really good for object type safety, actually falls apart in the primitives - and looks like it wants us to forbid primitive intersections (or at least intersected methods) to get it to work without being too bad.

Hypothetically, closed object types would also make this much less breaking.

Deduplicate fresh negations against their regular counterparts during union collection and intersection insertion. Preserve the first intersection position and ordered-set membership when replacing a fresh member, while leaving standalone fresh negations eligible for widening.

Add compiler coverage for explicit exclusions, generic array narrowing, both union operand orders, and fresh-only widening.
…ntial structures, broaden negation reduction applicability
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 29, 2026
@weswigham

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test this

There's gonna be a lot.

@typescript-automation

typescript-automation Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started 👀 Results
user test this ✅ Started 👀 Results
run dt ✅ Started
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@weswigham), something went wrong when publishing results from the DT run.

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are the results of running the user tests with tsc comparing baseline and pr:

Something interesting changed - please have a look.

Details

axios-src

tsconfig.json

effect

packages/tools/ai-docgen/tsconfig.json

formik

/mnt/vss/work/1/s/ts_downloads//m/formik/tsconfig.json

  • [NEW] error TS2344: Type '{ user: string; }' does not satisfy the constraint 'not { then(): any; }'.
    • /mnt/vss/work/1/s/ts_downloads//m/formik/index.tsx(6,54)

lodash

/mnt/vss/work/1/s/ts_downloads//m/lodash/tsconfig.json

  • [NEW] error TS2345: Argument of type 'symbol | (string & not "__proto__" & not "constructor" & not "prototype")' is not assignable to parameter of type 'string'.
    • /mnt/vss/work/1/s/ts_downloads//m/lodash/node_modules/lodash/_baseSet.js(45,25)
  • [MISSING] error TS2345: Argument of type 'string | symbol' is not assignable to parameter of type 'string'.
    • /mnt/vss/work/1/s/ts_downloads//m/lodash/node_modules/lodash/_baseSet.js(45,25)

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the user tests suite

Details

puppeteer

tools/mocha-runner/tsconfig.json

test/tsconfig.json

test/installation/tsconfig.json

packages/testserver/tsconfig.json

packages/puppeteer-core/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

refined-github/refined-github

tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

remix-run/react-router

35 of 41 projects failed to build with the old tsc and were ignored

scripts/tsconfig.json

packages/react-router/tsconfig.json

packages/create-react-router/tsconfig.json

resend/react-email

36 of 38 projects failed to build with the old tsc and were ignored

scripts/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

responsively-org/responsively-app

1 of 2 projects failed to build with the old tsc and were ignored

desktop-app/e2e/tsconfig.json

rohitg00/agentmemory

1 of 3 projects failed to build with the old tsc and were ignored

tsconfig.eval.json

website/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

RSSNext/Folo

2 of 21 projects failed to build with the old tsc and were ignored

store-assets/tsconfig.json

packages/readability/tsconfig.json

packages/internal/utils/tsconfig.json

packages/internal/tracker/tsconfig.json

packages/internal/store/tsconfig.json

packages/internal/shared/tsconfig.json

packages/internal/hooks/tsconfig.json

packages/internal/database/tsconfig.json

packages/internal/components/tsconfig.json

packages/internal/atoms/tsconfig.json

apps/ssr/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

SBoudrias/Inquirer.js

tsconfig.json

tools/setup-packages/tsconfig.json

tools/package/tsconfig.json

tools/isolate-monorepo-package/tsconfig.json

packages/type/tsconfig.json

packages/testing/tsconfig.json

packages/select/tsconfig.json

packages/search/tsconfig.json

packages/rawlist/tsconfig.json

packages/prompts/tsconfig.json

packages/password/tsconfig.json

packages/number/tsconfig.json

packages/inquirer/tsconfig.json

packages/input/tsconfig.json

packages/i18n/tsconfig.json

packages/external-editor/tsconfig.json

packages/expand/tsconfig.json

packages/editor/tsconfig.json

packages/demo/tsconfig.json

[packages/core/tsconfig.json](https://github.com/SBoudrias/Inquirer.js/blob/34d7d364bc1dc2c7a3c1684bee6b513447

:error: Truncated - see log for full output :error:

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

sequelize/sequelize

16 of 17 projects failed to build with the old tsc and were ignored

packages/utils/tsconfig.json

shadcn-ui/ui

40 of 51 projects failed to build with the old tsc and were ignored

packages/tests/tsconfig.json

slidevjs/slidev

4 of 6 projects failed to build with the old tsc and were ignored

cypress/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

stablyai/orca

6 of 29 projects failed to build with the old tsc and were ignored

src/packages/process-host/tsconfig.json

src/packages/process-host/tsconfig.test.json

config/tsconfig.build.cli.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

Stirling-Tools/Stirling-PDF

5 of 12 projects failed to build with the old tsc and were ignored

frontend/src/processor/proprietary/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

supabase/supabase

44 of 56 projects failed to build with the old tsc and were ignored

packages/ui-patterns/tsconfig.json

packages/ui/tsconfig.json

packages/pg-meta/tsconfig.json

packages/docs-search/tsconfig.json

packages/common/tsconfig.json

e2e/www/tsconfig.json

e2e/docs/tsconfig.json

blocks/vue/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

super-productivity/super-productivity

25 of 33 projects failed to build with the old tsc and were ignored

packages/plugin-api/tsconfig.json

packages/sync-providers/tsconfig.spec.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

TanStack/query

177 of 234 projects failed to build with the old tsc and were ignored

packages/vue-query/tsconfig.legacy.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

the1812/Bilibili-Evolved

4 of 9 projects failed to build with the old tsc and were ignored

dev-tools/dev-server/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

thedotmack/claude-mem

2 of 6 projects failed to build with the old tsc and were ignored

tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

THU-MAIC/OpenMAIC

13 of 14 projects failed to build with the old tsc and were ignored

packages/@openmaic/dsl/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

tldraw/tldraw

6 of 37 projects failed to build with the old tsc and were ignored

internal/apps-script/tsconfig.json

apps/dotcom/zero-cache/tsconfig.json

templates/socketio-server-example/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

tobi/qmd

tsconfig.build.json

tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

toon-format/toon

tsconfig.json

trpc/trpc

49 of 50 projects failed to build with the old tsc and were ignored

packages/tests/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

TryGhost/Ghost

82 of 100 projects failed to build with the old tsc and were ignored

packages/adapters/route-settings-base/tsconfig.json

packages/adapters/route-settings-base/test/tsconfig.json

packages/adapters/redirects-base/tsconfig.json

packages/adapters/redirects-base/test/tsconfig.json

packages/adapters/jobs-base/tsconfig.json

packages/adapters/jobs-base/test/tsconfig.json

packages/adapters/cache-base/tsconfig.json

packages/adapters/cache-base/test/tsconfig.json

umami-software/umami

4 of 5 projects failed to build with the old tsc and were ignored

tsconfig.tracker.types.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

upstash/context7

3 of 11 projects failed to build with the old tsc and were ignored

packages/sdk/tsconfig.json

packages/pi/tsconfig.json

packages/mcp/tsconfig.json

packages/cli/tsconfig.json

packages/admin-mcp/tsconfig.json

packages/admin-mcp/tsconfig.test.json

packages/admin-mcp/ui/tsconfig.json

vbenjs/vue-vben-admin

30 of 44 projects failed to build with the old tsc and were ignored

internal/node-utils/tsconfig.build.json

internal/node-utils/tsconfig.json

internal/lint-configs/eslint-config/tsconfig.json

apps/backend-mock/tsconfig.build.json

apps/backend-mock/tsconfig.json

vercel-labs/json-render

54 of 58 projects failed to build with the old tsc and were ignored

packages/core/tsconfig.check.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

vercel/ai

13 of 94 projects failed to build with the old tsc and were ignored

examples/next-langchain/langgraph-server/tsconfig.json

packages/zai/tsconfig.build.json

packages/xai/tsconfig.build.json

packages/workflow-harness/tsconfig.build.json

packages/workflow/tsconfig.build.json

packages/vue/tsconfig.build.json

packages/typesafe-ai/tsconfig.build.json

packages/tui/tsconfig.build.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

vercel/chatbot

tsconfig.json

vercel/swr

8 of 9 projects failed to build with the old tsc and were ignored

tsconfig.json

videojs/video.js

38 of 41 projects failed to build with the old tsc and were ignored

packages/utils/tsconfig.dts.json

webadderallorg/Recordly

1 of 2 projects failed to build with the old tsc and were ignored

services/recordly-share/worker/web/tsconfig.json

wg-easy/wg-easy

3 of 4 projects failed to build with the old tsc and were ignored

src/cli/tsconfig.json

winboat-org/winboat

src/renderer/tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

Yeachan-Heo/oh-my-claudecode

tsconfig.json

@typescript-automation

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham) Here are some more interesting changes from running the top 400 repos suite

Details

Yeachan-Heo/oh-my-codex

tsconfig.json

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@weswigham
Wesley Wigham (weswigham) force-pushed the weswigham/negated-types-promise-constraint branch from d5b15ba to 59e27bc Compare November 23, 2026 22:26
@weswigham

Copy link
Copy Markdown
Member Author

Experiment done, work will continue in #64375 - this is just hilariously breaky because Promise<string> can't exist. This can be revisited if we ever make primitives unable to be "branded". In the meantime, if you want, you can actually test this in your own projects without relying on a lib change to core TS by adding a

declare global {
  interface Promise<T extends not {then(): any}> {}
}

or similar (if you think a different constraint works better) to your own codebase. If you think you land on "the perfect one" that works today, let us know - we think T extends string | number | bigint | symbol | not {then(): any} might work, but the constraint might have to propagate too much in generic code for something big like that to be viable ecosystem-wide. Changing Promise is hard. We're open to reconsidering in the future, but as-is, it's not something we can build into the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant