Skip to content

fix: use renderName for scalar types to escape TypeScript reserved keywords #1363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 14, 2025

Conversation

jasonkuhrt
Copy link
Member

@jasonkuhrt jasonkuhrt commented Jul 14, 2025

Fixes #1354

Summary

  • Fixes scalar type generation to properly escape TypeScript reserved keywords
  • Ensures scalar types like bigint are generated as $bigint to avoid conflicts

Problem

When a GraphQL schema contains a scalar with a name that matches a TypeScript reserved keyword (like bigint), the generated code would fail to compile with errors like:

Type alias name cannot be 'bigint'

Solution

  • Import and use the existing renderName() function in the scalar generator
  • This function already handles TypeScript reserved keywords by prefixing them with $
  • Applied the fix to both custom scalar type generation paths

…reserved keywords

Fixes scalar type generation to properly escape TypeScript reserved keywords
like 'bigint' by using the existing renderName() function. This prevents
compilation errors when GraphQL schemas contain scalars with reserved names.

Fixes #1354
@jasonkuhrt jasonkuhrt force-pushed the fix/reserved-scalar-names branch from 94c789e to 4c487bc Compare July 14, 2025 19:20
Add tests that demonstrate the issue where scalar names that are TypeScript
reserved keywords (like 'bigint', 'boolean') generate invalid TypeScript code.
The fix is commented out with TODO markers.

Issue #1354
@jasonkuhrt jasonkuhrt merged commit b3d36c9 into main Jul 14, 2025
7 of 14 checks passed
@jasonkuhrt jasonkuhrt deleted the fix/reserved-scalar-names branch July 14, 2025 20:58
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.

Some scalar names conflict with TypeScript syntax
1 participant