Skip to content

Design Meeting Notes, 3/10/2023 #53198

Closed
Closed
@DanielRosenwasser

Description

@DanielRosenwasser

Parsing Octal Literals and Escapes

#51837

// 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`);
}

4.9 Playground
PR Build

  • 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 0o170 in 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 \170 in 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

#53194

  • 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.
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions