mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Fix js declaration emit for inherited and this-typed inherited fields (#37970)
This commit is contained in:
@@ -5459,7 +5459,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 && getTypeFromTypeNode(annotation) === type) {
|
||||
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) {
|
||||
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -6211,7 +6211,7 @@ namespace ts {
|
||||
...!length(baseTypes) ? [] : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))],
|
||||
...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeBaseType(b, staticBaseType, localName)))]
|
||||
];
|
||||
const symbolProps = getPropertiesOfType(classType);
|
||||
const symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
|
||||
const publicSymbolProps = filter(symbolProps, s => {
|
||||
// `valueDeclaration` could be undefined if inherited from
|
||||
// a union/intersection base type, but inherited properties
|
||||
@@ -33482,6 +33482,26 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNonInterhitedProperties(type: InterfaceType, baseTypes: BaseType[], properties: Symbol[]) {
|
||||
if (!length(baseTypes)) {
|
||||
return properties;
|
||||
}
|
||||
const seen = createUnderscoreEscapedMap<Symbol>();
|
||||
forEach(properties, p => { seen.set(p.escapedName, p); });
|
||||
|
||||
for (const base of baseTypes) {
|
||||
const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
||||
for (const prop of properties) {
|
||||
const existing = seen.get(prop.escapedName);
|
||||
if (existing && !isPropertyIdenticalTo(existing, prop)) {
|
||||
seen.delete(prop.escapedName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arrayFrom(seen.values());
|
||||
}
|
||||
|
||||
function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean {
|
||||
const baseTypes = getBaseTypes(type);
|
||||
if (baseTypes.length < 2) {
|
||||
|
||||
Reference in New Issue
Block a user