mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add special lookups test case, rename helper
This commit is contained in:
5 files changed
+285
-3
No files matched your search
@@ -5505,7 +5505,7 @@ namespace ts {
|
||||
return symbol.declarations && find(symbol.declarations, s => !!getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, n => n === enclosingDeclaration)));
|
||||
}
|
||||
|
||||
function getExistingNodeHasNoTypeParametersOrMatchingTypeParameters(existing: TypeNode, type: Type) {
|
||||
function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing: TypeNode, type: Type) {
|
||||
return !(getObjectFlags(type) & ObjectFlags.Reference) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount((type as TypeReference).target.typeParameters);
|
||||
}
|
||||
|
||||
@@ -5519,7 +5519,7 @@ namespace ts {
|
||||
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation)) {
|
||||
// try to reuse the existing annotation
|
||||
const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation)!;
|
||||
if (getTypeFromTypeNode(existing) === type && getExistingNodeHasNoTypeParametersOrMatchingTypeParameters(existing, type)) {
|
||||
if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
||||
const result = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -5540,7 +5540,7 @@ namespace ts {
|
||||
function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) {
|
||||
if (type !== errorType && context.enclosingDeclaration) {
|
||||
const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
|
||||
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && getExistingNodeHasNoTypeParametersOrMatchingTypeParameters(annotation, type)) {
|
||||
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
|
||||
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -5647,6 +5647,9 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isTypeReferenceNode(node) && isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), SymbolFlags.Type, /*ignoreErrors*/ true))) {
|
||||
return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
||||
}
|
||||
if (isLiteralImportTypeNode(node)) {
|
||||
return updateImportTypeNode(
|
||||
node,
|
||||
|
||||
Reference in new issue
Block a user