Skip to content

Don't quote Unicode member names in type signatures - #3130

Open
davidpavlovschi wants to merge 1 commit into
TypeStrong:masterfrom
davidpavlovschi:fix/unicode-property-names
Open

Don't quote Unicode member names in type signatures#3130
davidpavlovschi wants to merge 1 commit into
TypeStrong:masterfrom
davidpavlovschi:fix/unicode-property-names

Conversation

@davidpavlovschi

Copy link
Copy Markdown

Summary

  • render Unicode member names such as café, 日本語, and astral-plane identifiers without quotes when TypeScript accepts them as identifiers
  • validate code points with TypeScript's public isIdentifierStart and isIdentifierPart predicates, keeping the formatter aligned with the supported TypeScript version instead of the host Node.js Unicode tables
  • preserve quoting for names that TypeScript rejects, with regression coverage for both paths

Problem

FormattedCodeBuilder.propertyName() used an ASCII-only \w expression. As a result, valid TypeScript names such as öffnen rendered as "öffnen" in type signatures.

Validation

  • node_modules/.bin/hereby build
  • node_modules/.bin/hereby test --grep '^Formatter' — 37 passing
  • node_modules/.bin/hereby lint
  • node_modules/.bin/tsc -p . --noEmit
  • exhaustive comparison against TypeScript 6.0.3's internal isIdentifierText over 2,224,128 bare and continuation strings — 0 mismatches

AI assistance

Claude Opus 5 produced the initial patch and tests. OpenAI Codex independently reviewed the diff, found and removed a host-Unicode/TypeScript-version mismatch, added the TypeScript-table regression, and reran the checks above. The commit retains the Claude co-author trailer.

FormattedCodeBuilder.propertyName tested names against an ASCII-only regular expression, so valid identifiers like café or 日本語 were rendered as quoted string literals.

Validate each code point with TypeScript's public identifier predicates instead. This accepts exactly the same Unicode identifier table as the supported TypeScript version, including astral-plane characters, without depending on the host Node.js ICU tables.
@davidpavlovschi
davidpavlovschi force-pushed the fix/unicode-property-names branch from 2a71665 to a2b3217 Compare July 30, 2026 19:28
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.

1 participant