Skip to content
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

Downlevel TemplateStringsArray for tagged templates should be frozen #51789

Open
rbuckton opened this issue Dec 6, 2022 · 3 comments · May be fixed by #51806
Open

Downlevel TemplateStringsArray for tagged templates should be frozen #51789

rbuckton opened this issue Dec 6, 2022 · 3 comments · May be fixed by #51806
Assignees
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec
Milestone

Comments

@rbuckton
Copy link
Member

rbuckton commented Dec 6, 2022

Bug Report

The TemplateStringsArray we emit for tagged templates (as well as its raw property) should be frozen when we emit to --target ES5, to match the ES2015 specification. Without this change, developers could run into issues with a spec-compliant String.dedent polyfill. This was first reported here: tc39/proposal-string-dedent#75 (comment)

🔎 Search Terms

tagged template array frozen TemplateStringsArray

⏯ Playground Link

Playground link with relevant code

💻 Code

const f = (ar: TemplateStringsArray, ...args) => ar;
const x = f`a${1}b`
console.log(Object.isFrozen(x));
console.log(Object.isFrozen(x.raw));

🙁 Actual behavior

Neither the TemplateStringsArray nor its raw property are frozen.

🙂 Expected behavior

Both the TemplateStringsArray and its raw property should be frozen.

@fatcerberus
Copy link

Unrelated but I really don’t like that the proposal wants to strip blank lines completely. That feels like more than what a function called dedent should be doing.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 6, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 6, 2022
@bakkot
Copy link
Contributor

bakkot commented Dec 6, 2022

@fatcerberus You should open an issue on that repo there if you want to discuss it; this thread isn't the right place. (Though I think you may have misread the proposal.)

@fatcerberus
Copy link

Yes, I know this isn't the right place to discuss it. That's why I said "unrelated". It was more idle musing than anything; I don't actually have a strong enough opinion one way or the other to bother formally arguing the point.

tbh I'm more curious exactly what this function is doing under the hood that it apparently requires a frozen TemplateStringsArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants