Skip to content

Commit 470bcf6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. Fix relation between generic mapped types and types with index signatures (microsoft#38761) LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. Revert "Wrap classes with decorators or static properties in an IIFE, even for ES2015+ (microsoft#32011)" Preserve module marker in es2015+ module emit for tool compatability (microsoft#38712) Fix recently added test so it is cross-plat fix(33286): add outlining for arrow function with one parameter (microsoft#38631) fix(38463): show completions for index access properties
2 parents 6b28248 + 6ccc048 commit 470bcf6

File tree

125 files changed

+1689
-1366
lines changed

Some content is hidden

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

125 files changed

+1689
-1366
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17291,9 +17291,10 @@ namespace ts {
1729117291
return Ternary.True;
1729217292
}
1729317293
if (isGenericMappedType(source)) {
17294-
// A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U }
17295-
// if T is related to U.
17296-
return kind === IndexKind.String ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : Ternary.False;
17294+
// A generic mapped type { [P in K]: T } is related to a type with an index signature
17295+
// { [x: string]: U }, and optionally with an index signature { [x: number]: V },
17296+
// if T is related to U and V.
17297+
return getIndexTypeOfType(target, IndexKind.String) ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : Ternary.False;
1729717298
}
1729817299
const indexType = getIndexTypeOfType(source, kind) || kind === IndexKind.Number && getIndexTypeOfType(source, IndexKind.String);
1729917300
if (indexType) {

src/compiler/transformers/module/esnextAnd2015.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,36 @@ namespace ts {
1818
}
1919

2020
if (isExternalModule(node) || compilerOptions.isolatedModules) {
21-
const externalHelpersImportDeclaration = createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
22-
if (externalHelpersImportDeclaration) {
23-
const statements: Statement[] = [];
24-
const statementOffset = addPrologue(statements, node.statements);
25-
append(statements, externalHelpersImportDeclaration);
26-
27-
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
28-
return updateSourceFileNode(
29-
node,
30-
setTextRange(createNodeArray(statements), node.statements));
31-
}
32-
else {
33-
return visitEachChild(node, visitor, context);
21+
const result = updateExternalModule(node);
22+
if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) {
23+
return result;
3424
}
25+
return updateSourceFileNode(
26+
result,
27+
setTextRange(createNodeArray([...result.statements, createEmptyExports()]), result.statements),
28+
);
3529
}
3630

3731
return node;
3832
}
3933

34+
function updateExternalModule(node: SourceFile) {
35+
const externalHelpersImportDeclaration = createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
36+
if (externalHelpersImportDeclaration) {
37+
const statements: Statement[] = [];
38+
const statementOffset = addPrologue(statements, node.statements);
39+
append(statements, externalHelpersImportDeclaration);
40+
41+
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
42+
return updateSourceFileNode(
43+
node,
44+
setTextRange(createNodeArray(statements), node.statements));
45+
}
46+
else {
47+
return visitEachChild(node, visitor, context);
48+
}
49+
}
50+
4051
function visitor(node: Node): VisitResult<Node> {
4152
switch (node.kind) {
4253
case SyntaxKind.ImportEqualsDeclaration:

src/compiler/transformers/ts.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ namespace ts {
2323
IsNamedExternalExport = 1 << 4,
2424
IsDefaultExternalExport = 1 << 5,
2525
IsDerivedClass = 1 << 6,
26+
UseImmediatelyInvokedFunctionExpression = 1 << 7,
2627

2728
HasAnyDecorators = HasConstructorDecorators | HasMemberDecorators,
2829
NeedsName = HasStaticInitializedProperties | HasMemberDecorators,
29-
UseImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties,
30+
MayNeedImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties,
3031
IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport,
3132
}
3233

@@ -595,6 +596,7 @@ namespace ts {
595596
if (isExportOfNamespace(node)) facts |= ClassFacts.IsExportOfNamespace;
596597
else if (isDefaultExternalModuleExport(node)) facts |= ClassFacts.IsDefaultExternalExport;
597598
else if (isNamedExternalModuleExport(node)) facts |= ClassFacts.IsNamedExternalExport;
599+
if (languageVersion <= ScriptTarget.ES5 && (facts & ClassFacts.MayNeedImmediatelyInvokedFunctionExpression)) facts |= ClassFacts.UseImmediatelyInvokedFunctionExpression;
598600
return facts;
599601
}
600602

@@ -665,12 +667,6 @@ namespace ts {
665667
const iife = createImmediatelyInvokedArrowFunction(statements);
666668
setEmitFlags(iife, EmitFlags.TypeScriptClassWrapper);
667669

668-
// Class comment is already added by the ES2015 transform when targeting ES5 or below.
669-
// Only add if targetting ES2015+ to prevent duplicates
670-
if (languageVersion > ScriptTarget.ES5) {
671-
addSyntheticLeadingComment(iife, SyntaxKind.MultiLineCommentTrivia, "* @class ");
672-
}
673-
674670
const varStatement = createVariableStatement(
675671
/*modifiers*/ undefined,
676672
createVariableDeclarationList([
@@ -679,7 +675,7 @@ namespace ts {
679675
/*type*/ undefined,
680676
iife
681677
)
682-
], languageVersion > ScriptTarget.ES5 ? NodeFlags.Let : undefined)
678+
])
683679
);
684680

685681
setOriginalNode(varStatement, node);

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

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,24 @@
459459
</Str>
460460
<Disp Icon="Str" />
461461
</Item>
462+
<Item ItemId=";A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086" ItemType="0" PsrId="306" Leaf="true">
463+
<Str Cat="Text">
464+
<Val><![CDATA[A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.]]></Val>
465+
<Tgt Cat="Text" Stat="Loc" Orig="New">
466+
<Val><![CDATA[Element popsané řazené kolekce členů se deklaroval jako nepovinný pomocí otazníku za názvem a před dvojtečkou, nikoli za typem.]]></Val>
467+
</Tgt>
468+
</Str>
469+
<Disp Icon="Str" />
470+
</Item>
471+
<Item ItemId=";A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087" ItemType="0" PsrId="306" Leaf="true">
472+
<Str Cat="Text">
473+
<Val><![CDATA[A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.]]></Val>
474+
<Tgt Cat="Text" Stat="Loc" Orig="New">
475+
<Val><![CDATA[Element popsané řazené kolekce členů se deklaroval jako zbytek s třemi tečkami (...) před názvem, nikoli před typem.]]></Val>
476+
</Tgt>
477+
</Str>
478+
<Disp Icon="Str" />
479+
</Item>
462480
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
463481
<Str Cat="Text">
464482
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -876,6 +894,15 @@
876894
</Str>
877895
<Disp Icon="Str" />
878896
</Item>
897+
<Item ItemId=";A_tuple_member_cannot_be_both_optional_and_rest_5085" ItemType="0" PsrId="306" Leaf="true">
898+
<Str Cat="Text">
899+
<Val><![CDATA[A tuple member cannot be both optional and rest.]]></Val>
900+
<Tgt Cat="Text" Stat="Loc" Orig="New">
901+
<Val><![CDATA[Člen řazené kolekce členů nemůže být volitelný a zbytek.]]></Val>
902+
</Tgt>
903+
</Str>
904+
<Disp Icon="Str" />
905+
</Item>
879906
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
880907
<Str Cat="Text">
881908
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
@@ -3531,6 +3558,15 @@
35313558
</Str>
35323559
<Disp Icon="Str" />
35333560
</Item>
3561+
<Item ItemId=";Convert_overload_list_to_single_signature_95118" ItemType="0" PsrId="306" Leaf="true">
3562+
<Str Cat="Text">
3563+
<Val><![CDATA[Convert overload list to single signature]]></Val>
3564+
<Tgt Cat="Text" Stat="Loc" Orig="New">
3565+
<Val><![CDATA[Převést seznam přetížení na jednu signaturu]]></Val>
3566+
</Tgt>
3567+
</Str>
3568+
<Disp Icon="Str" />
3569+
</Item>
35343570
<Item ItemId=";Convert_parameters_to_destructured_object_95075" ItemType="0" PsrId="306" Leaf="true">
35353571
<Str Cat="Text">
35363572
<Val><![CDATA[Convert parameters to destructured object]]></Val>
@@ -4732,7 +4768,7 @@
47324768
<Str Cat="Text">
47334769
<Val><![CDATA[Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later.]]></Val>
47344770
<Tgt Cat="Text" Stat="Loc" Orig="New">
4735-
<Val><![CDATA[Pokud možnost target není nastavená na es2016 nebo novější, nedají se hodnoty bigint umocnit.]]></Val>
4771+
<Val><![CDATA[Pokud není možnost target nastavená na es2016 nebo novější, nedají se hodnoty bigint umocnit.]]></Val>
47364772
</Tgt>
47374773
</Str>
47384774
<Disp Icon="Str" />
@@ -6064,7 +6100,7 @@
60646100
<Str Cat="Text">
60656101
<Val><![CDATA[Its element type '{0}' is not a valid JSX element.]]></Val>
60666102
<Tgt Cat="Text" Stat="Loc" Orig="New">
6067-
<Val><![CDATA[Jeho typ prvku {0} není platný prvek JSX.]]></Val>
6103+
<Val><![CDATA[Typ prvku {0} není platný prvek JSX.]]></Val>
60686104
</Tgt>
60696105
</Str>
60706106
<Disp Icon="Str" />
@@ -6073,7 +6109,7 @@
60736109
<Str Cat="Text">
60746110
<Val><![CDATA[Its instance type '{0}' is not a valid JSX element.]]></Val>
60756111
<Tgt Cat="Text" Stat="Loc" Orig="New">
6076-
<Val><![CDATA[Jeho typ instance {0} není platný prvek JSX.]]></Val>
6112+
<Val><![CDATA[Typ instance {0} není platný prvek JSX.]]></Val>
60776113
</Tgt>
60786114
</Str>
60796115
<Disp Icon="Str" />
@@ -6082,7 +6118,7 @@
60826118
<Str Cat="Text">
60836119
<Val><![CDATA[Its return type '{0}' is not a valid JSX element.]]></Val>
60846120
<Tgt Cat="Text" Stat="Loc" Orig="New">
6085-
<Val><![CDATA[Jeho návratový typ {0} není platný prvek JSX.]]></Val>
6121+
<Val><![CDATA[Návratový typ {0} není platný prvek JSX.]]></Val>
60866122
</Tgt>
60876123
</Str>
60886124
<Disp Icon="Str" />
@@ -6816,6 +6852,15 @@
68166852
</Str>
68176853
<Disp Icon="Str" />
68186854
</Item>
6855+
<Item ItemId=";Move_labeled_tuple_element_modifiers_to_labels_95117" ItemType="0" PsrId="306" Leaf="true">
6856+
<Str Cat="Text">
6857+
<Val><![CDATA[Move labeled tuple element modifiers to labels]]></Val>
6858+
<Tgt Cat="Text" Stat="Loc" Orig="New">
6859+
<Val><![CDATA[Přesunout modifikátory elementu popsané řazené kolekce členů na popisky]]></Val>
6860+
</Tgt>
6861+
</Str>
6862+
<Disp Icon="Str" />
6863+
</Item>
68196864
<Item ItemId=";Move_to_a_new_file_95049" ItemType="0" PsrId="306" Leaf="true">
68206865
<Str Cat="Text">
68216866
<Val><![CDATA[Move to a new file]]></Val>
@@ -10608,6 +10653,15 @@
1060810653
</Str>
1060910654
<Disp Icon="Str" />
1061010655
</Item>
10656+
<Item ItemId=";This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234" ItemType="0" PsrId="306" Leaf="true">
10657+
<Str Cat="Text">
10658+
<Val><![CDATA[This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?]]></Val>
10659+
<Tgt Cat="Text" Stat="Loc" Orig="New">
10660+
<Val><![CDATA[Tento výraz se nedá volat, protože je to přístupový objekt get. Nechtěli jste ho použít bez ()?]]></Val>
10661+
</Tgt>
10662+
</Str>
10663+
<Disp Icon="Str" />
10664+
</Item>
1061110665
<Item ItemId=";This_expression_is_not_constructable_2351" ItemType="0" PsrId="306" Leaf="true">
1061210666
<Str Cat="Text">
1061310667
<Val><![CDATA[This expression is not constructable.]]></Val>
@@ -10773,6 +10827,15 @@
1077310827
</Str>
1077410828
<Disp Icon="Str" />
1077510829
</Item>
10830+
<Item ItemId=";Tuple_members_must_all_have_names_or_all_not_have_names_5084" ItemType="0" PsrId="306" Leaf="true">
10831+
<Str Cat="Text">
10832+
<Val><![CDATA[Tuple members must all have names or all not have names.]]></Val>
10833+
<Tgt Cat="Text" Stat="Loc" Orig="New">
10834+
<Val><![CDATA[Název musí mít buď všechny členy řazené kolekce členů, nebo ho nesmí mít žádný člen.]]></Val>
10835+
</Tgt>
10836+
</Str>
10837+
<Disp Icon="Str" />
10838+
</Item>
1077610839
<Item ItemId=";Tuple_type_0_of_length_1_has_no_element_at_index_2_2493" ItemType="0" PsrId="306" Leaf="true">
1077710840
<Str Cat="Text">
1077810841
<Val><![CDATA[Tuple type '{0}' of length '{1}' has no element at index '{2}'.]]></Val>

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

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,24 @@
450450
</Str>
451451
<Disp Icon="Str" />
452452
</Item>
453+
<Item ItemId=";A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086" ItemType="0" PsrId="306" Leaf="true">
454+
<Str Cat="Text">
455+
<Val><![CDATA[A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.]]></Val>
456+
<Tgt Cat="Text" Stat="Loc" Orig="New">
457+
<Val><![CDATA[Un elemento tupla con etichetta è dichiarato come facoltativo con un punto interrogativo dopo il nome e prima dei due punti, anziché dopo il tipo.]]></Val>
458+
</Tgt>
459+
</Str>
460+
<Disp Icon="Str" />
461+
</Item>
462+
<Item ItemId=";A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087" ItemType="0" PsrId="306" Leaf="true">
463+
<Str Cat="Text">
464+
<Val><![CDATA[A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.]]></Val>
465+
<Tgt Cat="Text" Stat="Loc" Orig="New">
466+
<Val><![CDATA[Un elemento tupla con etichetta è dichiarato come inattivo con `...` prima del nome, anziché prima del tipo.]]></Val>
467+
</Tgt>
468+
</Str>
469+
<Disp Icon="Str" />
470+
</Item>
453471
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
454472
<Str Cat="Text">
455473
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -867,6 +885,15 @@
867885
</Str>
868886
<Disp Icon="Str" />
869887
</Item>
888+
<Item ItemId=";A_tuple_member_cannot_be_both_optional_and_rest_5085" ItemType="0" PsrId="306" Leaf="true">
889+
<Str Cat="Text">
890+
<Val><![CDATA[A tuple member cannot be both optional and rest.]]></Val>
891+
<Tgt Cat="Text" Stat="Loc" Orig="New">
892+
<Val><![CDATA[Un membro di tupla non può essere sia facoltativo che inattivo.]]></Val>
893+
</Tgt>
894+
</Str>
895+
<Disp Icon="Str" />
896+
</Item>
870897
<Item ItemId=";A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" ItemType="0" PsrId="306" Leaf="true">
871898
<Str Cat="Text">
872899
<Val><![CDATA[A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.]]></Val>
@@ -3522,6 +3549,15 @@
35223549
</Str>
35233550
<Disp Icon="Str" />
35243551
</Item>
3552+
<Item ItemId=";Convert_overload_list_to_single_signature_95118" ItemType="0" PsrId="306" Leaf="true">
3553+
<Str Cat="Text">
3554+
<Val><![CDATA[Convert overload list to single signature]]></Val>
3555+
<Tgt Cat="Text" Stat="Loc" Orig="New">
3556+
<Val><![CDATA[Convertire l'elenco di overload in una firma singola]]></Val>
3557+
</Tgt>
3558+
</Str>
3559+
<Disp Icon="Str" />
3560+
</Item>
35253561
<Item ItemId=";Convert_parameters_to_destructured_object_95075" ItemType="0" PsrId="306" Leaf="true">
35263562
<Str Cat="Text">
35273563
<Val><![CDATA[Convert parameters to destructured object]]></Val>
@@ -3655,7 +3691,7 @@
36553691
<Str Cat="Text">
36563692
<Val><![CDATA[Declaration augments declaration in another file. This cannot be serialized.]]></Val>
36573693
<Tgt Cat="Text" Stat="Loc" Orig="New">
3658-
<Val><![CDATA[La dichiarazione causa un aumento della dichiarazione in un altro file. Questa condizione non è serializzabile.]]></Val>
3694+
<Val><![CDATA[La dichiarazione causa un aumento di una dichiarazione in un altro file. Questa operazione non è serializzabile.]]></Val>
36593695
</Tgt>
36603696
</Str>
36613697
<Disp Icon="Str" />
@@ -6807,6 +6843,15 @@
68076843
</Str>
68086844
<Disp Icon="Str" />
68096845
</Item>
6846+
<Item ItemId=";Move_labeled_tuple_element_modifiers_to_labels_95117" ItemType="0" PsrId="306" Leaf="true">
6847+
<Str Cat="Text">
6848+
<Val><![CDATA[Move labeled tuple element modifiers to labels]]></Val>
6849+
<Tgt Cat="Text" Stat="Loc" Orig="New">
6850+
<Val><![CDATA[Spostare i modificatori di elemento tupla con etichetta nelle etichette]]></Val>
6851+
</Tgt>
6852+
</Str>
6853+
<Disp Icon="Str" />
6854+
</Item>
68106855
<Item ItemId=";Move_to_a_new_file_95049" ItemType="0" PsrId="306" Leaf="true">
68116856
<Str Cat="Text">
68126857
<Val><![CDATA[Move to a new file]]></Val>
@@ -10599,6 +10644,15 @@
1059910644
</Str>
1060010645
<Disp Icon="Str" />
1060110646
</Item>
10647+
<Item ItemId=";This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234" ItemType="0" PsrId="306" Leaf="true">
10648+
<Str Cat="Text">
10649+
<Val><![CDATA[This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?]]></Val>
10650+
<Tgt Cat="Text" Stat="Loc" Orig="New">
10651+
<Val><![CDATA[Non è possibile chiamare questa espressione perché è una funzione di accesso 'get'. Si intendeva usarla senza '()'?]]></Val>
10652+
</Tgt>
10653+
</Str>
10654+
<Disp Icon="Str" />
10655+
</Item>
1060210656
<Item ItemId=";This_expression_is_not_constructable_2351" ItemType="0" PsrId="306" Leaf="true">
1060310657
<Str Cat="Text">
1060410658
<Val><![CDATA[This expression is not constructable.]]></Val>
@@ -10764,6 +10818,15 @@
1076410818
</Str>
1076510819
<Disp Icon="Str" />
1076610820
</Item>
10821+
<Item ItemId=";Tuple_members_must_all_have_names_or_all_not_have_names_5084" ItemType="0" PsrId="306" Leaf="true">
10822+
<Str Cat="Text">
10823+
<Val><![CDATA[Tuple members must all have names or all not have names.]]></Val>
10824+
<Tgt Cat="Text" Stat="Loc" Orig="New">
10825+
<Val><![CDATA[I membri di tupla devono tutti avere o non avere nomi.]]></Val>
10826+
</Tgt>
10827+
</Str>
10828+
<Disp Icon="Str" />
10829+
</Item>
1076710830
<Item ItemId=";Tuple_type_0_of_length_1_has_no_element_at_index_2_2493" ItemType="0" PsrId="306" Leaf="true">
1076810831
<Str Cat="Text">
1076910832
<Val><![CDATA[Tuple type '{0}' of length '{1}' has no element at index '{2}'.]]></Val>
@@ -12685,7 +12748,7 @@
1268512748
<Str Cat="Text">
1268612749
<Val><![CDATA['export *' does not re-export a default.]]></Val>
1268712750
<Tgt Cat="Text" Stat="Loc" Orig="New">
12688-
<Val><![CDATA['export *' non consente di riesportare un'impostazione predefinita.]]></Val>
12751+
<Val><![CDATA['export *' non consente di riesportare esportazioni predefinite.]]></Val>
1268912752
</Tgt>
1269012753
</Str>
1269112754
<Disp Icon="Str" />

0 commit comments

Comments
 (0)