mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 22:32:33 -05:00
fix(49719): Incorrect error 2301 when using ES standard class properties (#49725)
* fix(49719): omit TS2301 error with enabled usedefineforclassfields * show error for target lower than esnext with useddefineforclassfields enabled * change target from esnext to es2022
This commit is contained in:
@@ -2191,7 +2191,7 @@ namespace ts {
|
||||
// 1. When result is undefined, after checking for a missing "this."
|
||||
// 2. When result is defined
|
||||
function checkAndReportErrorForInvalidInitializer() {
|
||||
if (propertyWithInvalidInitializer && !(getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields)) {
|
||||
if (propertyWithInvalidInitializer && !(useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2022)) {
|
||||
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
||||
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
||||
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
||||
|
||||
@@ -141,7 +141,8 @@ namespace Harness {
|
||||
"preserveConstEnums",
|
||||
"skipLibCheck",
|
||||
"exactOptionalPropertyTypes",
|
||||
"useUnknownInCatchVariables"
|
||||
"useDefineForClassFields",
|
||||
"useUnknownInCatchVariables",
|
||||
];
|
||||
private fileName: string;
|
||||
private justName: string;
|
||||
|
||||
Reference in New Issue
Block a user