Closed
Description
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.