Repository navigation
Design Meeting Notes, 3/10/2023 #53198
Copy link
Copy link
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
Parsing Octal Literals and Escapes
// allowed outside of strict mode
function loose() {
// numeric octal
console.log(0170);
// octal string escapes
console.log("\170");
console.log("\0170");
}
// errors in strict mode
function strict() {
"use strict";
// numeric octal
"use strict"; console.log(0170);
// octal string escape
"use strict"; console.log("\170");
"use strict"; console.log("\0170");
}
function errorsAlways() {
// octal template string escapes
console.log(`\170`);
console.log(`\0170`);
}
// valid ALWAYS
function validAlways() {
// explicit octal
console.log(0o170);
// not even an octal string escape sequence
console.log("\0o170");
// Tagged Template Strings
console.log(String.raw `\170`);
console.log(String.raw `\0170`);
}- In JS, octal numeric literals have a leading zero
- It is an error to use this in strict mode
- Octals also exist in string escape sequences
- Don't need a leading zero(!)
- It is an error to use this in strict mode
- Octals also exist in template strings
- It is an error to use this in any mode
- You may write
0o170in any mode "\0o170"is not a string escape sequence, though.- You may write
String.raw`\170`and get the string "slash one seven zero" - TS currently fails to error on
\170in strict mode. - This PR fixes this, but also treats octals in sloppy-mode is if they were in strict mode.
- Does anyone want to stand up for sloppy mode?
- No.
- Think this is technically Annex B, so we can claim your engine technically might not support this.
- Steelman case: Someone using TS for JS-only tooling purposes?
- Probably rare, and parse errors can be ignored.
- Saves some performance.
- Conclusion: Ship it!
Testing Node 12.20
- Made it so 5.0 says Node 12 is a minimum (even though we work on lower than that right now).
- But Node 12 is old.
- Should we have set our minimum to higher?
- Feels like it's a bit too late for that.
- Our infra can't use stuff like
??and?.if we have to test on Node 12. - Also, stable sort is only mandated in ES2019 (so questionable if Node 12 can "guarantee" that even if it always has)
- Could we say "TypeScript 5.x will always support Node 12?"
- That's going to be 2.5 years! Node 12 doesn't even get security updates anymore, does it?
- Node 12 goes out of maintenance in April.
- TypeScript 5.1 goes out just after that - doesn't make sense to support.
- Conclusion: should say Node 14 is what's supported in 5.1, so don't add a test runner we'd have to rip out immediately.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Activity
fatcerberus commentedon Mar 10, 2023
Wait, I could have sworn
0oXXXstyle octals weren't introduced until ES6 (or possibly later)... weird that0XXXis disallowed in strict mode since that breaks any ES5 strict-mode code that uses themfatcerberus commentedon Mar 10, 2023
Off-topic but I really don't like V8's error message for this:
0o42is allowed so I guess that doesn't count as an octal literal 😉RyanCavanaugh commentedon Mar 10, 2023
I looked it up so I'll post it: The spec calls
017a "LegacyOctalIntegerLiteral" and0o17an "OctalIntegerLiteral"RyanCavanaugh commentedon Mar 10, 2023
Also: octal integer literals allow separators!!
jakebailey commentedon Mar 10, 2023
Note discrepancy: Node 12 went EOL last April, it's Node 14 that's going EOL this April.
fatcerberus commentedon Mar 10, 2023
Hmm, so by the same argument made in the notes, TS 5.1 should have a minimum target of node 16 😉
jakebailey commentedon Mar 10, 2023
My recollection was that I basically said "TS is more conservative than most projects, so people are likely to have hit other things breaking earlier", but, I do think that we should try and not break the previous EOL version when possible because there really always are people stuck just one version behind.
Once Node 14 is EOL, there should truly be no reason to be using Node 12.
graphemecluster commentedon Mar 11, 2023
Thank you for bring this to the design meeting — I've just updated the PR. 🎉🚀
HolgerJeromin commentedon Jun 23, 2023
Just wanted to add that this breaks VS2019 support with a suggested fix to hack in the registry...
#54686
I have no idea who could update EOL node in VS2019