@@ -4197,6 +4197,7 @@ namespace ts {
4197
4197
let props: Symbol[];
4198
4198
// Flags we want to propagate to the result if they exist in all source symbols
4199
4199
let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None;
4200
+ let isReadonly = false;
4200
4201
for (const current of types) {
4201
4202
const type = getApparentType(current);
4202
4203
if (type !== unknownType) {
@@ -4209,6 +4210,9 @@ namespace ts {
4209
4210
else if (!contains(props, prop)) {
4210
4211
props.push(prop);
4211
4212
}
4213
+ if (isReadonlySymbol(prop)) {
4214
+ isReadonly = true;
4215
+ }
4212
4216
}
4213
4217
else if (containingType.flags & TypeFlags.Union) {
4214
4218
// A union type requires the property to be present in all constituent types
@@ -4238,6 +4242,7 @@ namespace ts {
4238
4242
name);
4239
4243
result.containingType = containingType;
4240
4244
result.declarations = declarations;
4245
+ result.isReadonly = isReadonly;
4241
4246
result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes);
4242
4247
return result;
4243
4248
}
@@ -11975,11 +11980,9 @@ namespace ts {
11975
11980
// Variables declared with 'const'
11976
11981
// Get accessors without matching set accessors
11977
11982
// Enum members
11978
- // Unions and intersections of the above
11979
- if (symbol.flags & SymbolFlags.SyntheticProperty) {
11980
- return forEach(symbol.declarations, decl => isReadonlySymbol(getSymbolOfNode(decl)));
11981
- }
11982
- return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
11983
+ // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation)
11984
+ return symbol.isReadonly ||
11985
+ symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
11983
11986
symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 ||
11984
11987
symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) ||
11985
11988
(symbol.flags & SymbolFlags.EnumMember) !== 0;
0 commit comments