-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codefix for implementing interfaces #11547
Changes from all commits
1438f9a
7a5cb5f
bf3e487
6b4f6b5
151f940
d1cea73
c2feab6
f74872d
2abf906
132b746
ecc029f
a66b0ae
5d9a4e3
3ac9ffa
d24236b
7758e6d
7272833
834245c
c89b97b
16dc834
cbaea99
bc21346
99ae5d9
aa6ecd4
3240000
0380f3f
1b60a97
e5279fd
04968ab
d02eb6c
3b0b696
36c5bef
1b8486d
b7b30aa
71d1744
8c35185
bc1bb0e
0ce53f0
b26ba83
11cea6a
7141a2a
55bf3e3
4441380
1ec234a
6bd35fb
4973852
1d6ef6a
d842a6f
b1e97b3
c650c33
0591e1b
263734f
4b202ab
357ed7e
f6fc320
efd16c7
bba96da
cfe50d1
ad3035d
d8b359f
6400d53
c010a0e
395d736
d7d4bf6
a94d955
43afb80
6ed8d18
389959a
69118cd
4af0e2a
680af0f
16b146f
f37640a
5d6a714
bf48564
ba80ce6
8134d64
0c1772b
f0c7713
c511aea
5cd0ea3
c22e47d
c1a41b9
2f51b36
97b3d7a
819a654
5e48e33
1338b94
b9ae36c
d724517
469745b
1ba6c86
ad01110
3cfac08
4673812
4b02099
8be8819
d75d548
4af3937
97f18c9
3fc94bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,9 +79,11 @@ namespace ts { | |
getDeclaredTypeOfSymbol, | ||
getPropertiesOfType, | ||
getPropertyOfType, | ||
getIndexInfoOfType, | ||
getSignaturesOfType, | ||
getIndexTypeOfType, | ||
getBaseTypes, | ||
getTypeFromTypeNode, | ||
getReturnTypeOfSignature, | ||
getNonNullableType, | ||
getSymbolsInScope, | ||
|
@@ -90,6 +92,7 @@ namespace ts { | |
getExportSpecifierLocalTargetSymbol, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would say use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
getTypeAtLocation: getTypeOfNode, | ||
getPropertySymbolOfDestructuringAssignment, | ||
signatureToString, | ||
typeToString, | ||
getSymbolDisplayBuilder, | ||
symbolToString, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider inlining these two using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
@@ -1344,7 +1347,9 @@ namespace ts { | |
return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); | ||
} | ||
|
||
// Resolves a qualified name and any involved aliases | ||
/** | ||
* Resolves a qualified name and any involved aliases. | ||
*/ | ||
function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined { | ||
if (nodeIsMissing(name)) { | ||
return undefined; | ||
|
@@ -2085,7 +2090,7 @@ namespace ts { | |
return result || types; | ||
} | ||
|
||
function visibilityToString(flags: ModifierFlags) { | ||
function visibilityToString(flags: ModifierFlags): string | undefined { | ||
if (flags === ModifierFlags.Private) { | ||
return "private"; | ||
} | ||
|
@@ -2463,26 +2468,6 @@ namespace ts { | |
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); | ||
} | ||
|
||
function writeIndexSignature(info: IndexInfo, keyword: SyntaxKind) { | ||
if (info) { | ||
if (info.isReadonly) { | ||
writeKeyword(writer, SyntaxKind.ReadonlyKeyword); | ||
writeSpace(writer); | ||
} | ||
writePunctuation(writer, SyntaxKind.OpenBracketToken); | ||
writer.writeParameter(info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x"); | ||
writePunctuation(writer, SyntaxKind.ColonToken); | ||
writeSpace(writer); | ||
writeKeyword(writer, keyword); | ||
writePunctuation(writer, SyntaxKind.CloseBracketToken); | ||
writePunctuation(writer, SyntaxKind.ColonToken); | ||
writeSpace(writer); | ||
writeType(info.type, TypeFormatFlags.None); | ||
writePunctuation(writer, SyntaxKind.SemicolonToken); | ||
writer.writeLine(); | ||
} | ||
} | ||
|
||
function writePropertyWithModifiers(prop: Symbol) { | ||
if (isReadonlySymbol(prop)) { | ||
writeKeyword(writer, SyntaxKind.ReadonlyKeyword); | ||
|
@@ -2570,8 +2555,8 @@ namespace ts { | |
writePunctuation(writer, SyntaxKind.SemicolonToken); | ||
writer.writeLine(); | ||
} | ||
writeIndexSignature(resolved.stringIndexInfo, SyntaxKind.StringKeyword); | ||
writeIndexSignature(resolved.numberIndexInfo, SyntaxKind.NumberKeyword); | ||
buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, IndexKind.String, enclosingDeclaration, globalFlags, symbolStack); | ||
buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, IndexKind.Number, enclosingDeclaration, globalFlags, symbolStack); | ||
for (const p of resolved.properties) { | ||
const t = getTypeOfSymbol(p); | ||
if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { | ||
|
@@ -2762,6 +2747,11 @@ namespace ts { | |
} | ||
|
||
function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { | ||
const returnType = getReturnTypeOfSignature(signature); | ||
if (flags & TypeFormatFlags.SuppressAnyReturnType && isTypeAny(returnType)) { | ||
return; | ||
} | ||
|
||
if (flags & TypeFormatFlags.WriteArrowStyleSignature) { | ||
writeSpace(writer); | ||
writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken); | ||
|
@@ -2775,7 +2765,6 @@ namespace ts { | |
buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); | ||
} | ||
else { | ||
const returnType = getReturnTypeOfSignature(signature); | ||
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); | ||
} | ||
} | ||
|
@@ -2800,6 +2789,34 @@ namespace ts { | |
buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); | ||
} | ||
|
||
function buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { | ||
if (info) { | ||
if (info.isReadonly) { | ||
writeKeyword(writer, SyntaxKind.ReadonlyKeyword); | ||
writeSpace(writer); | ||
} | ||
writePunctuation(writer, SyntaxKind.OpenBracketToken); | ||
writer.writeParameter(info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x"); | ||
writePunctuation(writer, SyntaxKind.ColonToken); | ||
writeSpace(writer); | ||
switch (kind) { | ||
case IndexKind.Number: | ||
writeKeyword(writer, SyntaxKind.NumberKeyword); | ||
break; | ||
case IndexKind.String: | ||
writeKeyword(writer, SyntaxKind.StringKeyword); | ||
break; | ||
} | ||
|
||
writePunctuation(writer, SyntaxKind.CloseBracketToken); | ||
writePunctuation(writer, SyntaxKind.ColonToken); | ||
writeSpace(writer); | ||
buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); | ||
writePunctuation(writer, SyntaxKind.SemicolonToken); | ||
writer.writeLine(); | ||
} | ||
} | ||
|
||
return _displayBuilder || (_displayBuilder = { | ||
buildSymbolDisplay, | ||
buildTypeDisplay, | ||
|
@@ -2810,6 +2827,7 @@ namespace ts { | |
buildDisplayForTypeParametersAndDelimiters, | ||
buildTypeParameterDisplayFromSymbol, | ||
buildSignatureDisplay, | ||
buildIndexSignatureDisplay, | ||
buildReturnTypeDisplay | ||
}); | ||
} | ||
|
@@ -3765,11 +3783,13 @@ namespace ts { | |
return signatures; | ||
} | ||
|
||
// The base constructor of a class can resolve to | ||
// undefinedType if the class has no extends clause, | ||
// unknownType if an error occurred during resolution of the extends expression, | ||
// nullType if the extends expression is the null value, or | ||
// an object type with at least one construct signature. | ||
/** | ||
* The base constructor of a class can resolve to | ||
* * undefinedType if the class has no extends clause, | ||
* * unknownType if an error occurred during resolution of the extends expression, | ||
* * nullType if the extends expression is the null value, or | ||
* * an object type with at least one construct signature. | ||
*/ | ||
function getBaseConstructorTypeOfClass(type: InterfaceType): Type { | ||
if (!type.resolvedBaseConstructorType) { | ||
const baseTypeNode = getBaseTypeNodeOfClass(type); | ||
|
@@ -4250,7 +4270,7 @@ namespace ts { | |
return <InterfaceTypeWithDeclaredMembers>type; | ||
} | ||
|
||
function getTypeWithThisArgument(type: Type, thisArgument?: Type) { | ||
function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { | ||
if (getObjectFlags(type) & ObjectFlags.Reference) { | ||
return createTypeReference((<TypeReference>type).target, | ||
concatenate((<TypeReference>type).typeArguments, [thisArgument || (<TypeReference>type).target.thisType])); | ||
|
@@ -4476,6 +4496,9 @@ namespace ts { | |
setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); | ||
} | ||
|
||
/** | ||
* Converts an AnonymousType to a ResolvedType. | ||
*/ | ||
function resolveAnonymousTypeMembers(type: AnonymousType) { | ||
const symbol = type.symbol; | ||
if (type.target) { | ||
|
@@ -7238,10 +7261,12 @@ namespace ts { | |
return false; | ||
} | ||
|
||
// Compare two types and return | ||
// Ternary.True if they are related with no assumptions, | ||
// Ternary.Maybe if they are related with assumptions of other relationships, or | ||
// Ternary.False if they are not related. | ||
/** | ||
* Compare two types and return | ||
* * Ternary.True if they are related with no assumptions, | ||
* * Ternary.Maybe if they are related with assumptions of other relationships, or | ||
* * Ternary.False if they are not related. | ||
*/ | ||
function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { | ||
let result: Ternary; | ||
if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is not used i would remove it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.