Skip to content

[typescript-operations] test: reproduce @oneOf input emitted as interface with declarationKind 'interface' (failing) (#10996) - #10998

Merged
eddeee888 merged 1 commit into
masterfrom
claude/magical-ptolemy-47ugru
Sep 29, 2026
Merged

eddeee888 merged 1 commit into
masterfrom
claude/magical-ptolemy-47ugru

Conversation

@eddeee888

@eddeee888 eddeee888 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR adds a failing test that reproduces the bug reported in #10996, as a checkpoint before the fix. It adds only the test, not a fix.

With declarationKind: 'interface' and no importSchemaTypesFrom, typescript-operations emits a multi-field @oneOf input as an interface followed by a union. That isn't valid TypeScript. The shared base types visitor in visitor-plugin-common, which the typescript plugin uses, already forces a type alias in this case (#8586). The operations visitor has its own copy of the oneOf branch without that fallback (packages/plugins/typescript/operations/src/visitor.ts, InputObjectTypeDefinition).

The new test, generates @oneOf input as a type alias when declarationKind is interface in packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts, expects the type alias. It currently fails on the inline snapshot:

-      export type FooInput =
+      export interface FooInput
         {   a: string; b?: never; }
-        |  { a?: never;   b: number; };
+        |  { a?: never;   b: number; }

The fix will be built directly on top of this commit. This PR doesn't need to merge, or go green, first.

Related #10996

Type of change

  • Bug fix (non-breaking change which fixes an issue) — test only so far; the fix will follow

Screenshots/Sandbox (if appropriate/relevant):

Reporter's repro: https://stackblitz.com/github/jakubwawrzyczek/codegen-oneof-repro

How Has This Been Tested?

  • Unit tests — the new test fails on purpose with the snapshot diff above, reproducing the bug (re-checked after rebasing onto the latest master)

🤖 Generated with Claude Code

https://claude.ai/code/session_01TsaydotU8AFHMT1P4MEfra

@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 86f763e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@eddeee888
eddeee888 added this pull request to stack #11002 September 29, 2026 12:53
@eddeee888
eddeee888 force-pushed the claude/magical-ptolemy-47ugru branch from 3e35329 to e59347b Compare September 29, 2026 12:54
@eddeee888
eddeee888 marked this pull request as ready for review September 29, 2026 13:10
…rationKind 'interface'

With `declarationKind: 'interface'`, typescript-operations emits a multi-field
@OneOf input as `export interface FooInput { ... } | { ... }`, which is invalid
TypeScript. The test asserts the expected type alias and currently fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsaydotU8AFHMT1P4MEfra

eddeee888:oss:issue-verify
@eddeee888
eddeee888 force-pushed the claude/magical-ptolemy-47ugru branch from e59347b to 86f763e Compare September 29, 2026 13:17
@eddeee888
eddeee888 merged commit be8ead1 into master Sep 29, 2026
15 of 22 checks passed
@eddeee888
eddeee888 deleted the claude/magical-ptolemy-47ugru branch September 29, 2026 13:55
Sign up for free to 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.

2 participants