Skip to content

Commit a25388d

Browse files
committed
Merge branch 'main' into improveIntersectionReduction
2 parents d0b7ec8 + 9e70b69 commit a25388d

18 files changed

+164
-7
lines changed

package-lock.json

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35407,6 +35407,10 @@ namespace ts {
3540735407
// Grammar checking
3540835408
if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name);
3540935409

35410+
if (isMethodDeclaration(node) && node.asteriskToken && isIdentifier(node.name) && idText(node.name) === "constructor") {
35411+
error(node.name, Diagnostics.Class_constructor_may_not_be_a_generator);
35412+
}
35413+
3541035414
// Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration
3541135415
checkFunctionOrMethodDeclaration(node);
3541235416

@@ -35559,6 +35563,9 @@ namespace ts {
3555935563
}
3556035564

3556135565
function checkAccessorDeclaration(node: AccessorDeclaration) {
35566+
if (isIdentifier(node.name) && idText(node.name) === "constructor") {
35567+
error(node.name, Diagnostics.Class_constructor_may_not_be_an_accessor);
35568+
}
3556235569
addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
3556335570
checkSourceElement(node.body);
3556435571
setNodeLinksForPrivateIdentifierScope(node);

src/compiler/diagnosticMessages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,10 @@
10201020
"category": "Error",
10211021
"code": 1340
10221022
},
1023+
"Class constructor may not be an accessor.": {
1024+
"category": "Error",
1025+
"code": 1341
1026+
},
10231027
"Type arguments cannot be used here.": {
10241028
"category": "Error",
10251029
"code": 1342
@@ -1092,6 +1096,10 @@
10921096
"category": "Error",
10931097
"code": 1359
10941098
},
1099+
"Class constructor may not be a generator.": {
1100+
"category": "Error",
1101+
"code": 1360
1102+
},
10951103
"'{0}' cannot be used as a value because it was imported using 'import type'.": {
10961104
"category": "Error",
10971105
"code": 1361

src/compiler/program.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ namespace ts {
966966
Diagnostics.extends_clause_already_seen.code,
967967
Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code,
968968
Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
969+
Diagnostics.Class_constructor_may_not_be_a_generator.code,
970+
Diagnostics.Class_constructor_may_not_be_an_accessor.code,
969971
]);
970972

971973
/**

src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16416,6 +16416,15 @@
1641616416
</Str>
1641716417
<Disp Icon="Str" />
1641816418
</Item>
16419+
<Item ItemId=";or_JSX_element_expected_1145" ItemType="0" PsrId="306" Leaf="true">
16420+
<Str Cat="Text">
16421+
<Val><![CDATA['{' or JSX element expected.]]></Val>
16422+
<Tgt Cat="Text" Stat="Loc" Orig="New">
16423+
<Val><![CDATA['{' oder JSX-Element erwartet.]]></Val>
16424+
</Tgt>
16425+
</Str>
16426+
<Disp Icon="Str" />
16427+
</Item>
1641916428
<Item ItemId=";or_expected_1144" ItemType="0" PsrId="306" Leaf="true">
1642016429
<Str Cat="Text">
1642116430
<Val><![CDATA['{' or ';' expected.]]></Val>

src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16434,6 +16434,15 @@
1643416434
</Str>
1643516435
<Disp Icon="Str" />
1643616436
</Item>
16437+
<Item ItemId=";or_JSX_element_expected_1145" ItemType="0" PsrId="306" Leaf="true">
16438+
<Str Cat="Text">
16439+
<Val><![CDATA['{' or JSX element expected.]]></Val>
16440+
<Tgt Cat="Text" Stat="Loc" Orig="New">
16441+
<Val><![CDATA['{' ou élément JSX attendu.]]></Val>
16442+
</Tgt>
16443+
</Str>
16444+
<Disp Icon="Str" />
16445+
</Item>
1643716446
<Item ItemId=";or_expected_1144" ItemType="0" PsrId="306" Leaf="true">
1643816447
<Str Cat="Text">
1643916448
<Val><![CDATA['{' or ';' expected.]]></Val>

src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16422,6 +16422,15 @@
1642216422
</Str>
1642316423
<Disp Icon="Str" />
1642416424
</Item>
16425+
<Item ItemId=";or_JSX_element_expected_1145" ItemType="0" PsrId="306" Leaf="true">
16426+
<Str Cat="Text">
16427+
<Val><![CDATA['{' or JSX element expected.]]></Val>
16428+
<Tgt Cat="Text" Stat="Loc" Orig="New">
16429+
<Val><![CDATA[Previsto elemento '{' o JSX.]]></Val>
16430+
</Tgt>
16431+
</Str>
16432+
<Disp Icon="Str" />
16433+
</Item>
1642516434
<Item ItemId=";or_expected_1144" ItemType="0" PsrId="306" Leaf="true">
1642616435
<Str Cat="Text">
1642716436
<Val><![CDATA['{' or ';' expected.]]></Val>

src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16415,6 +16415,15 @@
1641516415
</Str>
1641616416
<Disp Icon="Str" />
1641716417
</Item>
16418+
<Item ItemId=";or_JSX_element_expected_1145" ItemType="0" PsrId="306" Leaf="true">
16419+
<Str Cat="Text">
16420+
<Val><![CDATA['{' or JSX element expected.]]></Val>
16421+
<Tgt Cat="Text" Stat="Loc" Orig="New">
16422+
<Val><![CDATA['{' veya JSX öğesi bekleniyor.]]></Val>
16423+
</Tgt>
16424+
</Str>
16425+
<Disp Icon="Str" />
16426+
</Item>
1641816427
<Item ItemId=";or_expected_1144" ItemType="0" PsrId="306" Leaf="true">
1641916428
<Str Cat="Text">
1642016429
<Val><![CDATA['{' or ';' expected.]]></Val>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests/cases/conformance/salsa/constructorNameInAccessor.ts(2,9): error TS1341: Class constructor may not be an accessor.
2+
tests/cases/conformance/salsa/constructorNameInAccessor.ts(3,9): error TS1341: Class constructor may not be an accessor.
3+
4+
5+
==== tests/cases/conformance/salsa/constructorNameInAccessor.ts (2 errors) ====
6+
class C1 {
7+
get constructor() { return }
8+
~~~~~~~~~~~
9+
!!! error TS1341: Class constructor may not be an accessor.
10+
set constructor(value) {}
11+
~~~~~~~~~~~
12+
!!! error TS1341: Class constructor may not be an accessor.
13+
}
14+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [constructorNameInAccessor.ts]
2+
class C1 {
3+
get constructor() { return }
4+
set constructor(value) {}
5+
}
6+
7+
8+
//// [constructorNameInAccessor.js]
9+
class C1 {
10+
get constructor() { return; }
11+
set constructor(value) { }
12+
}

0 commit comments

Comments
 (0)