Skip to content

Freeze Template Objects in __makeTemplateObject#51806

Closed
DanielRosenwasser wants to merge 2 commits intomainfrom
freezeTemplateObjects
Closed

Freeze Template Objects in __makeTemplateObject#51806
DanielRosenwasser wants to merge 2 commits intomainfrom
freezeTemplateObjects

Conversation

@DanielRosenwasser
Copy link
Member

This PR has our __makeTemplateObject helper freeze the arrays passed into it. This is more correct according to the ECMAScript spec for our downlevel support in ES5 for tagged template strings, as template objects (a.k.a TemplateStringsArrays) are supposed to be deeply frozen.

While we're here, maybe I should also make the raw property non-enumerable. I don't know if configurability/writability matters if we're just freezing the object after anyway.

Fixes #51789.

@antongolub
Copy link

maybe I should also make the raw property non-enumerable

The closer to the spec, the better for reliability.

14. Perform ! DefinePropertyOrThrow(template, "raw", PropertyDescriptor { [[Value]]: rawObj, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }).

@DanielRosenwasser
Copy link
Member Author

We just no longer support ES5 as an output target starting with TS6.

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Done in PR Backlog Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Downlevel TemplateStringsArray for tagged templates should be frozen

3 participants