GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Auto-accessors named get or set consume the following class member across a newline · Issue #65674 · microsoft/TypeScript

Auto-accessors named get or set consume the following class member across a newline #65674

New issue
Copy link
New issue
Copy link
Backlog
#65679
Backlog
Auto-accessors named get or set consume the following class member across a newline#65674
#65679
Copy link

Description

@camc314
Cameron (camc314)
opened on Nov 25, 2026
Issue body actions

🔎 Search Terms

accessor
get
getter
newline

🕗 Version & Regression Information

Reproduced in 5a757e9

⏯ Playground Link

No response

💻 Code

Save as repro.ts:

class C {
    accessor get
    m() { return 42; }
}

Compile with:

tsc --ignoreConfig --target es2022 --strict false --noEmit repro.ts

The same source also reproduces the problem as repro.js:

tsc --ignoreConfig --target es2022 --strict false --allowJs --checkJs --noEmit repro.js

🙁 Actual behavior

Both the TypeScript file and checked JavaScript file report:

error TS1275: 'accessor' modifier can only appear on a property declaration.

The parser constructs a getter named m with an accessor modifier, rather than an auto-accessor named get followed by a method named m.

For JavaScript without checkJs, compilation reports no diagnostics and emits the wrong behavior:

tsc --ignoreConfig --target es2022 --strict false --allowJs --outDir out repro.js

The emitted class is:

class C {
    get m() { return 42; }
}

The intended auto-accessor named get disappears, and typeof new C().m is "number" instead of "function".

🙂 Expected behavior

The newline should allow automatic semicolon insertion after the auto-accessor named get. The example should be equivalent to:

class C {
    accessor get;
    m() { return 42; }
}

That explicit-semicolon version compiles successfully and preserves both members.

The decorators proposal’s FieldDefinition grammar includes this alternative:

accessor [no LineTerminator here] ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]?

The line-terminator restriction is between accessor and the element name. Here, get is that name. The following m starts another class element, with the field terminated through automatic semicolon insertion.

Additional information about the issue

No response

Activity

  1. camc314 commented on Nov 25, 2026

    @camc314
    Cameron (camc314)
    on Nov 25, 2026
    ContributorAuthor
    More actions

    I changed oxc’s behaviour to align with TypeScript here. But upon reflection, i think this is a bug in TypeScrtip rather than Oxc.

    I will send a PR shortly.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.