File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -8016,10 +8016,13 @@ namespace ts {
8016
8016
else if (isUnion) {
8017
8017
const indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, IndexKind.Number) || getIndexInfoOfType(type, IndexKind.String));
8018
8018
if (indexInfo) {
8019
- checkFlags |= indexInfo.isReadonly ? CheckFlags.Readonly : 0;
8020
- checkFlags |= CheckFlags.WritePartial;
8019
+ checkFlags |= CheckFlags.WritePartial | (indexInfo.isReadonly ? CheckFlags.Readonly : 0);
8021
8020
indexTypes = append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
8022
8021
}
8022
+ else if (isObjectLiteralType(type)) {
8023
+ checkFlags |= CheckFlags.WritePartial;
8024
+ indexTypes = append(indexTypes, undefinedType);
8025
+ }
8023
8026
else {
8024
8027
checkFlags |= CheckFlags.ReadPartial;
8025
8028
}
@@ -20181,7 +20184,8 @@ namespace ts {
20181
20184
let propType: Type;
20182
20185
const leftType = checkNonNullExpression(left);
20183
20186
const parentSymbol = getNodeLinks(left).resolvedSymbol;
20184
- const apparentType = getApparentType(getWidenedType(leftType));
20187
+ // We widen array literals to get type any[] instead of undefined[] in non-strict mode
20188
+ const apparentType = getApparentType(isEmptyArrayLiteralType(leftType) ? getWidenedType(leftType) : leftType);
20185
20189
if (isTypeAny(apparentType) || apparentType === silentNeverType) {
20186
20190
if (isIdentifier(left) && parentSymbol) {
20187
20191
markAliasReferenced(parentSymbol, node);
You can’t perform that action at this time.
0 commit comments