mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 12:15:34 -06:00
Add type-to-string support for 'this: readonly' annotations
This commit is contained in:
parent
73b1c7167a
commit
201100dd3c
@ -2395,7 +2395,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
return createKeywordTypeNode(SyntaxKind.AnyKeyword);
|
||||
return createKeywordTypeNode(type !== readonlyThisType ? SyntaxKind.AnyKeyword : SyntaxKind.ReadonlyKeyword);
|
||||
}
|
||||
if (type.flags & TypeFlags.String) {
|
||||
return createKeywordTypeNode(SyntaxKind.StringKeyword);
|
||||
@ -3212,7 +3212,7 @@ namespace ts {
|
||||
// Write undefined/null type as any
|
||||
if (type.flags & TypeFlags.Intrinsic) {
|
||||
// Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving
|
||||
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type)
|
||||
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type) && type !== readonlyThisType
|
||||
? "any"
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
@ -5515,8 +5515,8 @@ namespace ts {
|
||||
// Union the result types when more than one signature matches
|
||||
if (unionSignatures.length > 1) {
|
||||
s = cloneSignature(signature);
|
||||
if (forEach(unionSignatures, sig => sig.thisParameter)) {
|
||||
const thisType = getUnionType(map(unionSignatures, sig => getTypeOfSymbol(sig.thisParameter) || anyType), /*subtypeReduction*/ true);
|
||||
if (forEach(unionSignatures, sig => getThisTypeOfSignature(sig))) {
|
||||
const thisType = getUnionType(map(unionSignatures, sig => getThisTypeOfSignature(sig)), /*subtypeReduction*/ true);
|
||||
s.thisParameter = createSymbolWithType(signature.thisParameter, thisType);
|
||||
}
|
||||
// Clear resolved return type we possibly got from cloneSignature
|
||||
|
||||
@ -915,7 +915,8 @@ namespace ts {
|
||||
| SyntaxKind.VoidKeyword
|
||||
| SyntaxKind.UndefinedKeyword
|
||||
| SyntaxKind.NullKeyword
|
||||
| SyntaxKind.NeverKeyword;
|
||||
| SyntaxKind.NeverKeyword
|
||||
| SyntaxKind.ReadonlyKeyword;
|
||||
}
|
||||
|
||||
export interface ThisTypeNode extends TypeNode {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user