Skip to content

Scanner treats U+0085 and U+200B as whitespace, but ECMAScript doesn't #65730

Backlog

Description

@camc314

🔎 Search Terms

U+0085, NEL, next line, U+200B, ZWSP, zero width space, whitespace, Invalid character, TS1127, isWhiteSpaceSingleLine

🕗 Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/v2/#code/v2/N4IghgxgLglgbgUwGIwDYJALhAegO4D2ATgNYDOADpAjmURDgHYJ4C0AZmggHQBWZIADQhO6AZlD5i5KhBpQyEAo04BzPmWVYQwADqMABAd0glAWwpciAeQqxlZE5gN7DR4yDMEAJgFd0Th6MPgjMAB5QJoL67h5QYESqCJFYHghk4SnRbkYmZFBEMNCBBb4I2bEmwQCqjBAAFggQJAjeAJKM3ghhrQCCEHJkjqml5THuJt2QULb2jGCoAApEBBQIRFAAngAqm2vDzqMVE54+-ggAIslNc4Em7MRyUeO5IF0QqAlgtyNEZcevMgkGAUAAyMAARgBhRrNEp-BDjAC+xxMMDqqF8XUCAG0TNxaPQcAAqYkkkwAXX0SP0QlwhFIlGohIY6K6YW4Cm0cASAFCwgBuOlSRmyGhs7rcMz8bTsXx1ObEgyqAAUAEoXONQr4zAYAKIuAybGAIVDeAwAXgMAEZBAZepajSazXaAEKOh0AHydpvNNMY-rAZE2dQMcoVMGUYfVmrcSkY+QM2t1BuABjAeDAMCgjtt9sdGazOf9SOFDJkzLoDGYbFEPDMXOw4egkcYStVGtcRmT+sNxt9ubtDqt-ZdBndVq9PrNBhL+iDIYgYflLaj7BjXYM8cTPdT6cz2cH+athcPJbL0iZchZTBYHC43Gg4hAF9FlaJNfv6A03L5gpAKIgGQpo3K2WCgBQBBkNmrZQgQmJmIwWAAOzCJB0FzOCzAAHI6hC6xYLaQEgaujAAMrxBscEIUhmCocR6CkRRCRQFhCC4WY+FEIRgGIEQ0FaJgABMSJAA

💻 Code

The separators are invisible and tend to get lost when pasted, so here's how to create the files:

printf 'var\xc2\x85x;\n' > nel.ts       # var<U+0085>x;
printf 'var\xe2\x80\x8bx;\n' > zwsp.ts  # var<U+200B>x;
printf 'var\xe1\xa0\x8ex;\n' > mvs.ts   # var<U+180E>x;  (for comparison)

The same happens with .js copies of these files.

🙁 Actual behavior

nel.ts and zwsp.ts parse with no errors and are treated as var x;. The separator is turned into a normal space in the emitted output.

mvs.ts reports TS1127: Invalid character. at the separator.

🙂 Expected behavior

nel.ts and zwsp.ts should report TS1127: Invalid character. at the separator, the same as mvs.ts. Neither U+0085 nor U+200B is ECMAScript WhiteSpace or a LineTerminator.

Additional information about the issue

  • ECMA-262, White Space: "Other than for the code points listed in [the table], ECMAScript |WhiteSpace| intentionally excludes all code points that have the Unicode “White_Space” property but which are not classified in general category “Space_Separator” (“Zs”)."
  • U+0085 is general category Cc. U+200B is Cf; it was Zs until Unicode 4.0.1. Neither is in the table. This is the same situation as U+180E, which became Cf in Unicode 6.3. test262 covers U+180E in test/language/white-space/mongolian-vowel-separator.js, and TypeScript already rejects it.
  • ECMA-262, Line Terminators: "Other new line or line breaking Unicode code points are not treated as line terminators but are treated as white space if they meet the requirements listed in [the table]." NEL doesn't meet those requirements.
  • Treat 0x0085 as whitespace, not as a line terminator. This matches ES5 and ES6. #2448 cited ES5 §7.3 ("Other new line or line breaking characters are treated as white space but not as line terminators"). However, ES5's WhiteSpace was also limited to the listed characters plus Zs, so NEL wasn't whitespace in ES5 either. The current spec makes this explicit.
  • The comment next to nextLine in IsWhiteSpaceSingleLine says NEL is in Zs. It's actually Cc.
  • V8 (SyntaxError: Invalid or unexpected token) and Babel (Unexpected character) both reject both inputs.
  • tsc emits a normal space in place of the separator, so its output runs even though the input wouldn't. A fix would turn input that's currently accepted into an error.

Activity

  1. RyanCavanaugh commented on Nov 30, 2026

    @RyanCavanaugh
    Member

    Cameron (@camc314) please use the "Agent" template when using AI to create issues next time. Thanks

  2. camc314 commented on Nov 30, 2026

    @camc314
    ContributorAuthor

    Ryan Cavanaugh (@RyanCavanaugh) I didn't use AI to create this issue? I hand wrote and triaged based on my findings in oxc-project/oxc#30581

  3. RyanCavanaugh commented on Nov 30, 2026

    @RyanCavanaugh
    Member

    Cameron (@camc314) you have super-human levels of "additional information" 😅

  4. MartinJohns commented on Nov 30, 2026

    @MartinJohns
    Contributor

    Camerons response almost looks like a human wrote it. Amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions