Skip to content

Commit f2c9398

Browse files
TypeScript Botweswighamtypescript-bot
authored
🤖 Pick PR microsoft#38101 (Skip comparing optional property fl...) into release-3.9 (microsoft#38199)
* Cherry-pick PR microsoft#38101 into release-3.9 Component commits: f0aeef1 Skip comparing optional property flag when comparing against discriminant properties * Update LKG Co-authored-by: Wesley Wigham <t-weswig@microsoft.com> Co-authored-by: typescript-bot <typescript@microsoft.com>
1 parent cefa5f4 commit f2c9398

11 files changed

+54
-28
lines changed

‎lib/tsc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41603,7 +41603,7 @@ var ts;
4160341603
return "continue-outer";
4160441604
if (sourceProperty === targetProperty)
4160541605
return "continue";
41606-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0);
41606+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
4160741607
if (!related) {
4160841608
return "continue-outer";
4160941609
}
@@ -41702,7 +41702,7 @@ var ts;
4170241702
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
4170341703
}
4170441704
}
41705-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
41705+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
4170641706
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
4170741707
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
4170841708
if (sourcePropFlags & 8 || targetPropFlags & 8) {
@@ -41739,7 +41739,7 @@ var ts;
4173941739
}
4174041740
return 0;
4174141741
}
41742-
if (relation !== comparableRelation && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
41742+
if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
4174341743
if (reportErrors) {
4174441744
reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
4174541745
}
@@ -41853,7 +41853,7 @@ var ts;
4185341853
if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
4185441854
var sourceProp = getPropertyOfType(source, name);
4185541855
if (sourceProp && sourceProp !== targetProp) {
41856-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
41856+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
4185741857
if (!related) {
4185841858
return 0;
4185941859
}

‎lib/tsserver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49915,7 +49915,7 @@ var ts;
4991549915
if (sourceProperty === targetProperty)
4991649916
return "continue";
4991749917
// We compare the source property to the target in the context of a single discriminant type.
49918-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */);
49918+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
4991949919
// If the target property could not be found, or if the properties were not related,
4992049920
// then this constituent is not a match.
4992149921
if (!related) {
@@ -50023,7 +50023,7 @@ var ts;
5002350023
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState);
5002450024
}
5002550025
}
50026-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50026+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
5002750027
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
5002850028
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
5002950029
if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
@@ -50062,7 +50062,7 @@ var ts;
5006250062
return 0 /* False */;
5006350063
}
5006450064
// When checking for comparability, be more lenient with optional properties.
50065-
if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
50065+
if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
5006650066
// TypeScript 1.0 spec (April 2014): 3.8.3
5006750067
// S is a subtype of a type T, and T is a supertype of S if ...
5006850068
// S' and T are object types and, for each member M in T..
@@ -50187,7 +50187,7 @@ var ts;
5018750187
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
5018850188
var sourceProp = getPropertyOfType(source, name);
5018950189
if (sourceProp && sourceProp !== targetProp) {
50190-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
50190+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
5019150191
if (!related) {
5019250192
return 0 /* False */;
5019350193
}

‎lib/tsserverlibrary.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50065,7 +50065,7 @@ var ts;
5006550065
if (sourceProperty === targetProperty)
5006650066
return "continue";
5006750067
// We compare the source property to the target in the context of a single discriminant type.
50068-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */);
50068+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
5006950069
// If the target property could not be found, or if the properties were not related,
5007050070
// then this constituent is not a match.
5007150071
if (!related) {
@@ -50173,7 +50173,7 @@ var ts;
5017350173
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState);
5017450174
}
5017550175
}
50176-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50176+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
5017750177
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
5017850178
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
5017950179
if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
@@ -50212,7 +50212,7 @@ var ts;
5021250212
return 0 /* False */;
5021350213
}
5021450214
// When checking for comparability, be more lenient with optional properties.
50215-
if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
50215+
if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
5021650216
// TypeScript 1.0 spec (April 2014): 3.8.3
5021750217
// S is a subtype of a type T, and T is a supertype of S if ...
5021850218
// S' and T are object types and, for each member M in T..
@@ -50337,7 +50337,7 @@ var ts;
5033750337
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
5033850338
var sourceProp = getPropertyOfType(source, name);
5033950339
if (sourceProp && sourceProp !== targetProp) {
50340-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
50340+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
5034150341
if (!related) {
5034250342
return 0 /* False */;
5034350343
}

‎lib/typescript.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50065,7 +50065,7 @@ var ts;
5006550065
if (sourceProperty === targetProperty)
5006650066
return "continue";
5006750067
// We compare the source property to the target in the context of a single discriminant type.
50068-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */);
50068+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
5006950069
// If the target property could not be found, or if the properties were not related,
5007050070
// then this constituent is not a match.
5007150071
if (!related) {
@@ -50173,7 +50173,7 @@ var ts;
5017350173
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState);
5017450174
}
5017550175
}
50176-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50176+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
5017750177
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
5017850178
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
5017950179
if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
@@ -50212,7 +50212,7 @@ var ts;
5021250212
return 0 /* False */;
5021350213
}
5021450214
// When checking for comparability, be more lenient with optional properties.
50215-
if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
50215+
if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
5021650216
// TypeScript 1.0 spec (April 2014): 3.8.3
5021750217
// S is a subtype of a type T, and T is a supertype of S if ...
5021850218
// S' and T are object types and, for each member M in T..
@@ -50337,7 +50337,7 @@ var ts;
5033750337
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
5033850338
var sourceProp = getPropertyOfType(source, name);
5033950339
if (sourceProp && sourceProp !== targetProp) {
50340-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
50340+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
5034150341
if (!related) {
5034250342
return 0 /* False */;
5034350343
}

‎lib/typescriptServices.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50065,7 +50065,7 @@ var ts;
5006550065
if (sourceProperty === targetProperty)
5006650066
return "continue";
5006750067
// We compare the source property to the target in the context of a single discriminant type.
50068-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */);
50068+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
5006950069
// If the target property could not be found, or if the properties were not related,
5007050070
// then this constituent is not a match.
5007150071
if (!related) {
@@ -50173,7 +50173,7 @@ var ts;
5017350173
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState);
5017450174
}
5017550175
}
50176-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50176+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
5017750177
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
5017850178
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
5017950179
if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
@@ -50212,7 +50212,7 @@ var ts;
5021250212
return 0 /* False */;
5021350213
}
5021450214
// When checking for comparability, be more lenient with optional properties.
50215-
if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
50215+
if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
5021650216
// TypeScript 1.0 spec (April 2014): 3.8.3
5021750217
// S is a subtype of a type T, and T is a supertype of S if ...
5021850218
// S' and T are object types and, for each member M in T..
@@ -50337,7 +50337,7 @@ var ts;
5033750337
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
5033850338
var sourceProp = getPropertyOfType(source, name);
5033950339
if (sourceProp && sourceProp !== targetProp) {
50340-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
50340+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
5034150341
if (!related) {
5034250342
return 0 /* False */;
5034350343
}

‎lib/typingsInstaller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49904,7 +49904,7 @@ var ts;
4990449904
if (sourceProperty === targetProperty)
4990549905
return "continue";
4990649906
// We compare the source property to the target in the context of a single discriminant type.
49907-
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */);
49907+
var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
4990849908
// If the target property could not be found, or if the properties were not related,
4990949909
// then this constituent is not a match.
4991049910
if (!related) {
@@ -50012,7 +50012,7 @@ var ts;
5001250012
return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState);
5001350013
}
5001450014
}
50015-
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50015+
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
5001650016
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
5001750017
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
5001850018
if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
@@ -50051,7 +50051,7 @@ var ts;
5005150051
return 0 /* False */;
5005250052
}
5005350053
// When checking for comparability, be more lenient with optional properties.
50054-
if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
50054+
if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
5005550055
// TypeScript 1.0 spec (April 2014): 3.8.3
5005650056
// S is a subtype of a type T, and T is a supertype of S if ...
5005750057
// S' and T are object types and, for each member M in T..
@@ -50176,7 +50176,7 @@ var ts;
5017650176
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
5017750177
var sourceProp = getPropertyOfType(source, name);
5017850178
if (sourceProp && sourceProp !== targetProp) {
50179-
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
50179+
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
5018050180
if (!related) {
5018150181
return 0 /* False */;
5018250182
}

0 commit comments

Comments
 (0)