Skip to content

Commit 9dc4228

Browse files
committed
Merge branch 'main' into gabritto/d2-detect
2 parents eb88415 + df9d165 commit 9dc4228

File tree

123 files changed

+2206
-781
lines changed

Some content is hidden

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

123 files changed

+2206
-781
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47129,6 +47129,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4712947129
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
4713047130
// Grammar checking
4713147131
if (!checkGrammarModifiers(node)) checkGrammarInterfaceDeclaration(node);
47132+
if (!allowBlockDeclarations(node.parent)) {
47133+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "interface");
47134+
}
4713247135

4713347136
checkTypeParameters(node.typeParameters);
4713447137
addLazyDiagnostic(() => {
@@ -47172,6 +47175,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4717247175
// Grammar checking
4717347176
checkGrammarModifiers(node);
4717447177
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
47178+
if (!allowBlockDeclarations(node.parent)) {
47179+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "type");
47180+
}
4717547181
checkExportsOnMergedDeclarations(node);
4717647182
checkTypeParameters(node.typeParameters);
4717747183
if (node.type.kind === SyntaxKind.IntrinsicKeyword) {
@@ -52406,7 +52412,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5240652412
return false;
5240752413
}
5240852414

52409-
function allowLetAndConstDeclarations(parent: Node): boolean {
52415+
function allowBlockDeclarations(parent: Node): boolean {
5241052416
switch (parent.kind) {
5241152417
case SyntaxKind.IfStatement:
5241252418
case SyntaxKind.DoStatement:
@@ -52417,14 +52423,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5241752423
case SyntaxKind.ForOfStatement:
5241852424
return false;
5241952425
case SyntaxKind.LabeledStatement:
52420-
return allowLetAndConstDeclarations(parent.parent);
52426+
return allowBlockDeclarations(parent.parent);
5242152427
}
5242252428

5242352429
return true;
5242452430
}
5242552431

5242652432
function checkGrammarForDisallowedBlockScopedVariableStatement(node: VariableStatement) {
52427-
if (!allowLetAndConstDeclarations(node.parent)) {
52433+
if (!allowBlockDeclarations(node.parent)) {
5242852434
const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & NodeFlags.BlockScoped;
5242952435
if (blockScopeKind) {
5243052436
const keyword = blockScopeKind === NodeFlags.Let ? "let" :

src/compiler/commandLineParser.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
addToSeen,
23
AlternateModeDiagnostics,
34
append,
45
arrayFrom,
@@ -2629,7 +2630,7 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
26292630
const providedKeys = new Set(optionMap.keys());
26302631
const impliedCompilerOptions: Record<string, CompilerOptionsValue> = {};
26312632
for (const option in computedOptions) {
2632-
if (!providedKeys.has(option) && some(computedOptions[option].dependencies, dep => providedKeys.has(dep))) {
2633+
if (!providedKeys.has(option) && optionDependsOn(option, providedKeys)) {
26332634
const implied = computedOptions[option].computeValue(configParseResult.options);
26342635
const defaultValue = computedOptions[option].computeValue({});
26352636
if (implied !== defaultValue) {
@@ -2641,6 +2642,18 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
26412642
return config;
26422643
}
26432644

2645+
function optionDependsOn(option: string, dependsOn: Set<string>): boolean {
2646+
const seen = new Set<string>();
2647+
return optionDependsOnRecursive(option);
2648+
2649+
function optionDependsOnRecursive(option: string): boolean {
2650+
if (addToSeen(seen, option)) {
2651+
return some(computedOptions[option]?.dependencies, dep => dependsOn.has(dep) || optionDependsOnRecursive(dep));
2652+
}
2653+
return false;
2654+
}
2655+
}
2656+
26442657
/** @internal */
26452658
export function optionMapToObject(optionMap: Map<string, CompilerOptionsValue>): object {
26462659
return Object.fromEntries(optionMap);

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/compiler/utilities.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8193,15 +8193,11 @@ export function getLastChild(node: Node): Node | undefined {
81938193
*
81948194
* @internal
81958195
*/
8196-
export function addToSeen<K>(seen: Map<K, true>, key: K): boolean;
8197-
/** @internal */
8198-
export function addToSeen<K, T>(seen: Map<K, T>, key: K, value: T): boolean;
8199-
/** @internal */
8200-
export function addToSeen<K, T>(seen: Map<K, T>, key: K, value: T = true as any): boolean {
8196+
export function addToSeen<K>(seen: Set<K>, key: K): boolean {
82018197
if (seen.has(key)) {
82028198
return false;
82038199
}
8204-
seen.set(key, value);
8200+
seen.add(key);
82058201
return true;
82068202
}
82078203

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>

0 commit comments

Comments
 (0)