Skip to content

Conversation

@eddeee888
Copy link
Collaborator

Description

When a TypeScript type is any and unknown, and we try to add other union options e.g. any | null | undefined, they'd be collapsed down to the any or unknown.

This PR adds printTypeScriptType to consistently print TypeScript types with these scenarios in mind.
Note: this function doesn't exhaustively does all scenarios right now (maybe it shouldn't, otherwise, it'd be too many cases? 🤔 ). Anyways, adding it here for consistency and we can see how it evoles.

Related #10496

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: d2aa8f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript-operations Patch
@graphql-codegen/typescript-document-nodes Patch
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/typescript-resolvers Patch
@graphql-codegen/typed-document-node Patch
@graphql-codegen/typescript Patch
@graphql-codegen/graphql-modules-preset Patch
@graphql-codegen/client-preset Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 6.1.1-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 5.0.1-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 5.0.8-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 5.1.3-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 6.0.0-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 6.1.6-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 5.1.3-alpha-20260117105221-d2aa8f22f154fadab9ac34896ea317a18b05f4d6 npm ↗︎ unpkg ↗︎

@eddeee888 eddeee888 changed the title Handle printing types consistently when types are any and unknown [typescript-operations] Handle printing types consistently when types are any and unknown Jan 17, 2026
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