Similar to #31296
In Strada, it is roughly possible to reimplement .isReadonlySymbol() using the internal CheckFlags (which is necessary to detect readonly properties in mapped types). That will not work with TypeScript 7.
A solution could be adding .isReadonlySymbol() to the type checker as requested in the above-mentioned issue.
But it feels like APIs to detect wherever a symbol is optional or readonly could be similar. For instance, symbol.flags could be used to check for SymbolFlags.Readonly (similar to SymbolFlags.Optional):
function isOptionalProperty(symbol: ts.Symbol) {
return !!(symbol.flags & ts.SymbolFlags.Optional);
}
function isReadonlyProperty(symbol: ts.Symbol) {
return !!(symbol.flags & ts.SymbolFlags.Readonly);
}
Alternatively, those both could be getters: symbol.isOptional, symbol.isReadonly.
Similar to #31296
In Strada, it is roughly possible to reimplement
.isReadonlySymbol()using the internalCheckFlags(which is necessary to detect readonly properties in mapped types). That will not work with TypeScript 7.A solution could be adding
.isReadonlySymbol()to the type checker as requested in the above-mentioned issue.But it feels like APIs to detect wherever a symbol is optional or readonly could be similar. For instance,
symbol.flagscould be used to check forSymbolFlags.Readonly(similar toSymbolFlags.Optional):Alternatively, those both could be getters:
symbol.isOptional,symbol.isReadonly.