Skip to content

fix(react-utilities): replace deprecated TypeScript assertion syntax#36185

Merged
Hotell merged 2 commits into
microsoft:masterfrom
Hotell:fix/replace-deprecated-ts-assertion-syntax
May 11, 2026
Merged

fix(react-utilities): replace deprecated TypeScript assertion syntax#36185
Hotell merged 2 commits into
microsoft:masterfrom
Hotell:fix/replace-deprecated-ts-assertion-syntax

Conversation

@Hotell

@Hotell Hotell commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

Replaces the legacy TypeScript angle-bracket type assertion syntax (<Type>expr) with the as syntax (expr as Type) in isVirtualElement.ts.

The angle-bracket assertion syntax (<VirtualElement>element) is invalid when processed by Babel's TSX parser — Babel interprets it as a JSX element rather than a type assertion. While TypeScript's own compiler handles it correctly in .ts files, this causes issues when the code is run through Babel (e.g., when testing out React Compiler integration).

Change

- return element && !!(<VirtualElement>element)._virtual;
+ return element && !!(element as VirtualElement)._virtual;

Both forms are semantically identical in TypeScript, but only the as syntax is compatible with Babel's TypeScript transform.

@Hotell Hotell marked this pull request as ready for review May 11, 2026 10:23
@Hotell Hotell requested review from a team as code owners May 11, 2026 10:23
@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

@github-actions

Copy link
Copy Markdown

📊 Bundle size report

✅ No changes found

@Hotell Hotell merged commit f5bccb8 into microsoft:master May 11, 2026
12 checks passed
@Hotell Hotell deleted the fix/replace-deprecated-ts-assertion-syntax branch May 11, 2026 12:21
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