Skip to content

TypeScript 7.0.2 scanner does not advance on bare hash #64490

Closed as not planned
Closed as not planned

Description

@yum45f

Version

TypeScript 7.0.2

Reproduction

npm install typescript@7.0.2
node --input-type=module -e 'import { createScanner, LanguageVariant, SyntaxKind } from "typescript/unstable/ast"; const scanner=createScanner(false,LanguageVariant.Standard,"#"); for(let i=0;i<2;i++){const token=scanner.scan(); console.log(SyntaxKind[token], scanner.getTokenStart(), scanner.getTokenEnd())}'

Actual output:

PrivateIdentifier 0 0
PrivateIdentifier 0 0

The scanner repeatedly returns the same non-EOF token without moving from offset 0. A loop that scans until EndOfFile therefore never terminates on a bare # (including when a later comment appears in the same source). Expected: scanning malformed input advances or returns EOF so consumers can terminate. A bare # followed by an identifier scans normally.

Activity

  1. RyanCavanaugh commented on Sep 28, 2026

    @RyanCavanaugh
    Member

    Just calling scan in a loop isn't going to give you anything meaningful; this isn't how to use that function

  2. typescript-automation commented on Oct 1, 2026

    @typescript-automation
    Contributor

    This issue has been marked as "Unactionable" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  3. YevheniiKotyrlo commented on Oct 22, 2026

    @YevheniiKotyrlo

    The 6.0.3 and Go scanners both move past the # here: 6.0.3 increments inside its diagnostic call, error(Diagnostics.Invalid_character, pos++, charSize(ch)), and Go's scanIdentifier(1, …) consumes it before reporting the same error. The unstable/ast copy reports no diagnostics, and the pos++ went with the call (scanner.ts), so as I read it this is a gap in the port, like #64135. With pos++; after tokenValue = "#";, the reproduction above prints PrivateIdentifier 0 1 and then EndOfFile 1 1.

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

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions