Skip to content

Regression: constructor accessor not allowed on plain objects #52443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mhofman opened this issue Jan 26, 2023 · 0 comments · Fixed by #52452
Closed

Regression: constructor accessor not allowed on plain objects #52443

mhofman opened this issue Jan 26, 2023 · 0 comments · Fixed by #52452
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@mhofman
Copy link

mhofman commented Jan 26, 2023

Bug Report

Since 4.8.0, TypeScript errors when defining a constructor accessor on plain objects. Likely as a side-effect of #48954

🔎 Search Terms

constructor accessor object

🕗 Version & Regression Information

  • This changed between versions 4.7.4 and 4.8

⏯ Playground Link

Playground Link: Provided

Output
"use strict";
const foo = {
    get constructor() {
        return {};
    }
};
Compiler Options
{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ES2017",
    "jsx": "react",
    "module": "ESNext",
    "moduleResolution": "node"
  }
}

💻 Code

const foo = {
  get constructor() {
    return {};
  }
};

🙁 Actual behavior

Class constructor may not be an accessor. ts(1341)

🙂 Expected behavior

No error for non class cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants