GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Preserve U+FEFF when Wtf8Decoder reads payload text by joshbarros · Pull Request #65460 · microsoft/TypeScript

Conversation

@joshbarros

@joshbarros Josué Barros (joshbarros) commented Nov 12, 2026

Copy link
Copy Markdown

Fixes #65458

Wtf8Decoder extends TextDecoder without ignoreBOM: true. TextDecoder removes U+FEFF from the start of a decode. This decoder also splits a buffer on a lone surrogate and decodes the following bytes as a new segment, so the same character is removed there.

A string or template value that starts with U+FEFF, or that has U+FEFF immediately after a lone surrogate, comes back from the API without that character. A U+FEFF in the middle of a segment stays. The input in the report has no file-level BOM. The Go filesystem reader already strips a UTF-8 BOM from source text before the compiler sees the file. This default restores the character inside payload text.

The WASM file decoder already constructed Wtf8Decoder with { ignoreBOM: true }. The constructor now defaults ignoreBOM to true. An explicit ignoreBOM: false still opts out.

The new test in packages/typescript/test/wtf8.test.ts covers a leading U+FEFF, a value that is only U+FEFF, U+FEFF after a lone surrogate, a middle U+FEFF, and the template value from the report.

node --conditions=@typescript/source --test ./test/wtf8.test.ts passed, 8 tests.

I also ran the report's async API script on [email protected]. Before the change the code points were leading ["78"], only [], afterSurrogate ["d800"], middle ["61","feff","62"], template ["74","61","69","6c"]. With this constructor on that package's decoder, they are leading ["feff","78"], only ["feff"], afterSurrogate ["d800","feff"], middle ["61","feff","62"], template ["feff","74","61","69","6c"]. Node 22.19 cannot parse using in the local API sources, so that run used the published package. npx hereby test, npx hereby lint, and npx hereby check:format were not run. The issue has no Backlog milestone.

Drafted with assistance from Grok. I reviewed the diff and ran those tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joshbarros
Preserve U+FEFF when Wtf8Decoder reads payload text
d6654d9
TextDecoder drops a leading U+FEFF. Wtf8Decoder decodes each segment on
its own, so the character was lost at the start of a string, a template,
and the span after a lone surrogate. The constructor now defaults
ignoreBOM to true. Passing false still opts out.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 22:22
@github-project-automation github-project-automation Bot added this to PR Backlog Nov 12, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 12, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 12, 2026
@typescript-automation

typescript-automation Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshbarros Josué Barros (joshbarros) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 12, 2026
Copilot started reviewing on behalf of Josué Barros (joshbarros) November 12, 2026 22:24
View session
Copilot AI reviewed Nov 12, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change preserving U+FEFF during native TypeScript text decoding.

No open issues 🎉

What changed in this PR

Fixes #65458 by preserving U+FEFF in text decoded by the native TypeScript API, including literal values that begin with it or contain it immediately after a lone surrogate.

Changes:

  • Defaults Wtf8Decoder to ignoreBOM: true, while preserving explicit ignoreBOM: false behavior.
  • Adds regression coverage for leading, standalone, post-surrogate, middle, and template-text U+FEFF values.
File Description
packages/​typescript/​test/​wtf8.test.ts Adds U+FEFF preservation regression cases.
packages/​typescript/​src/​api/​node/​wtf8.ts Adds a constructor that preserves U+FEFF by default.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jakebailey
Jake Bailey (jakebailey) reviewed Nov 12, 2026
View reviewed changes
Comment thread packages/typescript/src/api/node/wtf8.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshbarros
Wtf8Decoder always ignores the BOM; drop the ignoreBOM option
b43a2ce
Review feedback: the decoder should always set ignoreBOM to true, so the
constructor no longer accepts decoder options. transport.ts no longer
passes the redundant option.
@joshbarros

Josué Barros (joshbarros) commented Nov 12, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshbarros

Josué Barros (joshbarros) commented Nov 12, 2026

Copy link
Copy Markdown
Author

This PR references #65458 (Fixes #65458 in the description), so it already has a linked issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

@jakebailey Jake Bailey (jakebailey) jakebailey left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

PR Backlog
Status: Not started

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Native API: Wtf8Decoder drops U+FEFF from string literals and template text

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@joshbarros @jakebailey
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.