Skip to content

Commit 37d70d6

Browse files
Merge pull request #598 from microsoft/main
Create a new pull request by comparing changes across two branches
2 parents 64b3a04 + df9d165 commit 37d70d6

File tree

104 files changed

+2149
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2149
-749
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46774,6 +46774,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4677446774
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
4677546775
// Grammar checking
4677646776
if (!checkGrammarModifiers(node)) checkGrammarInterfaceDeclaration(node);
46777+
if (!allowBlockDeclarations(node.parent)) {
46778+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "interface");
46779+
}
4677746780

4677846781
checkTypeParameters(node.typeParameters);
4677946782
addLazyDiagnostic(() => {
@@ -46817,6 +46820,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4681746820
// Grammar checking
4681846821
checkGrammarModifiers(node);
4681946822
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
46823+
if (!allowBlockDeclarations(node.parent)) {
46824+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "type");
46825+
}
4682046826
checkExportsOnMergedDeclarations(node);
4682146827
checkTypeParameters(node.typeParameters);
4682246828
if (node.type.kind === SyntaxKind.IntrinsicKeyword) {
@@ -52051,7 +52057,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5205152057
return false;
5205252058
}
5205352059

52054-
function allowLetAndConstDeclarations(parent: Node): boolean {
52060+
function allowBlockDeclarations(parent: Node): boolean {
5205552061
switch (parent.kind) {
5205652062
case SyntaxKind.IfStatement:
5205752063
case SyntaxKind.DoStatement:
@@ -52062,14 +52068,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5206252068
case SyntaxKind.ForOfStatement:
5206352069
return false;
5206452070
case SyntaxKind.LabeledStatement:
52065-
return allowLetAndConstDeclarations(parent.parent);
52071+
return allowBlockDeclarations(parent.parent);
5206652072
}
5206752073

5206852074
return true;
5206952075
}
5207052076

5207152077
function checkGrammarForDisallowedBlockScopedVariableStatement(node: VariableStatement) {
52072-
if (!allowLetAndConstDeclarations(node.parent)) {
52078+
if (!allowBlockDeclarations(node.parent)) {
5207352079
const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & NodeFlags.BlockScoped;
5207452080
if (blockScopeKind) {
5207552081
const keyword = blockScopeKind === NodeFlags.Let ? "let" :

src/compiler/factory/emitHelpers.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,13 +1188,23 @@ const importStarHelper: UnscopedEmitHelper = {
11881188
dependencies: [createBindingHelper, setModuleDefaultHelper],
11891189
priority: 2,
11901190
text: `
1191-
var __importStar = (this && this.__importStar) || function (mod) {
1192-
if (mod && mod.__esModule) return mod;
1193-
var result = {};
1194-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1195-
__setModuleDefault(result, mod);
1196-
return result;
1197-
};`,
1191+
var __importStar = (this && this.__importStar) || (function () {
1192+
var ownKeys = function(o) {
1193+
ownKeys = Object.getOwnPropertyNames || function (o) {
1194+
var ar = [];
1195+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1196+
return ar;
1197+
};
1198+
return ownKeys(o);
1199+
};
1200+
return function (mod) {
1201+
if (mod && mod.__esModule) return mod;
1202+
var result = {};
1203+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1204+
__setModuleDefault(result, mod);
1205+
return result;
1206+
};
1207+
})();`,
11981208
};
11991209

12001210
// emit helper for `import Name from "foo"`

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,11 +2784,11 @@
27842784
</Str>
27852785
<Disp Icon="Str" />
27862786
</Item>
2787-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2787+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
27882788
<Str Cat="Text">
2789-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2789+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
27902790
<Tgt Cat="Text" Stat="Loc" Orig="New">
2791-
<Val><![CDATA[至少一个访问器必须具有带有 --isolatedDeclarations 的显式返回类型注释。]]></Val>
2791+
<Val><![CDATA[至少一个访问器必须具有带有 --isolatedDeclarations 的显式类型注释。]]></Val>
27922792
</Tgt>
27932793
</Str>
27942794
<Disp Icon="Str" />
@@ -5040,11 +5040,11 @@
50405040
</Str>
50415041
<Disp Icon="Str" />
50425042
</Item>
5043-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5043+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50445044
<Str Cat="Text">
5045-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5045+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50465046
<Tgt Cat="Text" Stat="Loc" Orig="New">
5047-
<Val><![CDATA[为此参数发出的声明要求隐式添加未定义的类型。--isolatedDeclarations 不支持此功能。]]></Val>
5047+
<Val><![CDATA[为此参数发出的声明要求将未定义隐式添加到其类型。--isolatedDeclarations 不支持此功能。]]></Val>
50485048
</Tgt>
50495049
</Str>
50505050
<Disp Icon="Str" />
@@ -11548,7 +11548,7 @@
1154811548
<Str Cat="Text">
1154911549
<Val><![CDATA[Property '{0}' cannot have an initializer because it is marked abstract.]]></Val>
1155011550
<Tgt Cat="Text" Stat="Loc" Orig="New">
11551-
<Val><![CDATA[属性“{0}”不能具有初始化表杰式,因为它标记为摘要。]]></Val>
11551+
<Val><![CDATA[属性“{0}”不能具有初始化表达式,因为它标记为摘要。]]></Val>
1155211552
</Tgt>
1155311553
</Str>
1155411554
<Disp Icon="Str" />

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,11 +2784,11 @@
27842784
</Str>
27852785
<Disp Icon="Str" />
27862786
</Item>
2787-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2787+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
27882788
<Str Cat="Text">
2789-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2789+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
27902790
<Tgt Cat="Text" Stat="Loc" Orig="New">
2791-
<Val><![CDATA[至少一個存取子必須有具備 --isolatedDeclarations 的明確傳回類型註解。]]></Val>
2791+
<Val><![CDATA[至少一個存取子必須有具備 --isolatedDeclarations 的明確型別註釋。]]></Val>
27922792
</Tgt>
27932793
</Str>
27942794
<Disp Icon="Str" />
@@ -5040,11 +5040,11 @@
50405040
</Str>
50415041
<Disp Icon="Str" />
50425042
</Item>
5043-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5043+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50445044
<Str Cat="Text">
5045-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5045+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50465046
<Tgt Cat="Text" Stat="Loc" Orig="New">
5047-
<Val><![CDATA[此參數發出的宣告需要隱含地新增未定義值至其類型。該情況不受 --isolatedDeclarations 支援。]]></Val>
5047+
<Val><![CDATA[此參數發出的宣告需要隱含地新增未定義值至其類型。此情況不受 --isolatedDeclarations 支援。]]></Val>
50485048
</Tgt>
50495049
</Str>
50505050
<Disp Icon="Str" />

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,11 +2793,11 @@
27932793
</Str>
27942794
<Disp Icon="Str" />
27952795
</Item>
2796-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2796+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
27972797
<Str Cat="Text">
2798-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2798+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
27992799
<Tgt Cat="Text" Stat="Loc" Orig="New">
2800-
<Val><![CDATA[Alespoň jeden přistupující objekt musí mít explicitní anotaci návratového typu s možností --isolatedDeclarations.]]></Val>
2800+
<Val><![CDATA[Minimálně jeden přistupující objekt musí mít explicitní anotaci typu s možností --isolatedDeclarations.]]></Val>
28012801
</Tgt>
28022802
</Str>
28032803
<Disp Icon="Str" />
@@ -5049,11 +5049,11 @@
50495049
</Str>
50505050
<Disp Icon="Str" />
50515051
</Item>
5052-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5052+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50535053
<Str Cat="Text">
5054-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5054+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50555055
<Tgt Cat="Text" Stat="Loc" Orig="New">
5056-
<Val><![CDATA[Generování deklarace pro tento parametr vyžaduje implicitně přidání možnosti „undefined“ do jeho typu. Toto není podporováno s možností --isolatedDeclarations.]]></Val>
5056+
<Val><![CDATA[Generování deklarace pro tento parametr vyžaduje implicitní přidání možnosti „undefined“ do jeho typu. Není podporováno s možností --isolatedDeclarations.]]></Val>
50575057
</Tgt>
50585058
</Str>
50595059
<Disp Icon="Str" />

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,11 +2781,11 @@
27812781
</Str>
27822782
<Disp Icon="Str" />
27832783
</Item>
2784-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2784+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
27852785
<Str Cat="Text">
2786-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2786+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
27872787
<Tgt Cat="Text" Stat="Loc" Orig="New">
2788-
<Val><![CDATA[Mindestens ein Accessor muss eine explizite Rückgabetypanmerkung mit "--isolatedDeclarations" aufweisen.]]></Val>
2788+
<Val><![CDATA[Mindestens ein Accessor muss über eine explizite Typanmerkung mit --isolatedDeclarations“ verfügen.]]></Val>
27892789
</Tgt>
27902790
</Str>
27912791
<Disp Icon="Str" />
@@ -5037,11 +5037,11 @@
50375037
</Str>
50385038
<Disp Icon="Str" />
50395039
</Item>
5040-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5040+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50415041
<Str Cat="Text">
5042-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5042+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50435043
<Tgt Cat="Text" Stat="Loc" Orig="New">
5044-
<Val><![CDATA[Die Deklarationsausgabe für diesen Parameter erfordert das implizit undefinierte Hinzufügen zum Typ. Dies wird mit "--isolatedDeclarations" nicht unterstützt.]]></Val>
5044+
<Val><![CDATA[Die Deklarationsausgabe für diesen Parameter erfordert das implizit undefinierte Hinzufügen zum Typ. Dies wird mit --isolatedDeclarations nicht unterstützt.]]></Val>
50455045
</Tgt>
50465046
</Str>
50475047
<Disp Icon="Str" />

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,11 +2796,11 @@
27962796
</Str>
27972797
<Disp Icon="Str" />
27982798
</Item>
2799-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2799+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
28002800
<Str Cat="Text">
2801-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2801+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
28022802
<Tgt Cat="Text" Stat="Loc" Orig="New">
2803-
<Val><![CDATA[Al menos un descriptor de acceso debe tener una anotación de tipo de valor devuelto explícita con --isolatedDeclarations.]]></Val>
2803+
<Val><![CDATA[Al menos un descriptor de acceso debe tener una anotación de tipo explícita con --isolatedDeclarations.]]></Val>
28042804
</Tgt>
28052805
</Str>
28062806
<Disp Icon="Str" />
@@ -5052,9 +5052,9 @@
50525052
</Str>
50535053
<Disp Icon="Str" />
50545054
</Item>
5055-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5055+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50565056
<Str Cat="Text">
5057-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5057+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50585058
<Tgt Cat="Text" Stat="Loc" Orig="New">
50595059
<Val><![CDATA[La emisión de declaración para este parámetro requiere agregar implícitamente un elemento no definido a su tipo. Esto no se admite con --isolatedDeclarations.]]></Val>
50605060
</Tgt>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,11 +2796,11 @@
27962796
</Str>
27972797
<Disp Icon="Str" />
27982798
</Item>
2799-
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
2799+
<Item ItemId=";At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009" ItemType="0" PsrId="306" Leaf="true">
28002800
<Str Cat="Text">
2801-
<Val><![CDATA[At least one accessor must have an explicit return type annotation with --isolatedDeclarations.]]></Val>
2801+
<Val><![CDATA[At least one accessor must have an explicit type annotation with --isolatedDeclarations.]]></Val>
28022802
<Tgt Cat="Text" Stat="Loc" Orig="New">
2803-
<Val><![CDATA[Au moins un accesseur doit avoir une annotation de type de retour explicite avec --isolatedDeclarations.]]></Val>
2803+
<Val><![CDATA[Au moins un accesseur doit avoir une annotation de type explicite avec --isolatedDeclarations.]]></Val>
28042804
</Tgt>
28052805
</Str>
28062806
<Disp Icon="Str" />
@@ -5052,11 +5052,11 @@
50525052
</Str>
50535053
<Disp Icon="Str" />
50545054
</Item>
5055-
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025" ItemType="0" PsrId="306" Leaf="true">
5055+
<Item ItemId=";Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025" ItemType="0" PsrId="306" Leaf="true">
50565056
<Str Cat="Text">
5057-
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.]]></Val>
5057+
<Val><![CDATA[Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.]]></Val>
50585058
<Tgt Cat="Text" Stat="Loc" Orig="New">
5059-
<Val><![CDATA[L’émission de déclaration pour ce paramètre nécessite l’ajout implicite non défini à son type. Cette opération n’est pas pris en charge avec --isolatedDeclarations.]]></Val>
5059+
<Val><![CDATA[L’émission de déclaration pour ce paramètre nécessite l’ajout implicite de « non défini » à son type. Cette opération n’est pas pris en charge avec --isolatedDeclarations.]]></Val>
50605060
</Tgt>
50615061
</Str>
50625062
<Disp Icon="Str" />

0 commit comments

Comments
 (0)