diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9c6b8237a7f74..22f71ef3f209f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12829,7 +12829,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const baseTypes = getBaseTypes(source); if (baseTypes.length) { if (source.symbol && members === getMembersOfSymbol(source.symbol)) { - members = createSymbolTable(source.declaredProperties); + const symbolTable = createSymbolTable(); + // copy all symbols (except type parameters), including the ones with internal names like `InternalSymbolName.Index` + for (const symbol of members.values()) { + if (!(symbol.flags & SymbolFlags.TypeParameter)) { + symbolTable.set(symbol.escapedName, symbol); + } + } + members = symbolTable; } setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos); const thisArgument = lastOrUndefined(typeArguments); diff --git a/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols new file mode 100644 index 0000000000000..dca9748d6539b --- /dev/null +++ b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.symbols @@ -0,0 +1,75 @@ +//// [tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts] //// + +=== classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts === +interface IObserver { +>IObserver : Symbol(IObserver, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 0, 0)) + + handleChange(observable: IObservable, change: TChange): void; +>handleChange : Symbol(IObserver.handleChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 0, 21)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 14)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 16)) +>observable : Symbol(observable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 26)) +>IObservable : Symbol(IObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 2, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 14)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 16)) +>change : Symbol(change, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 62)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 1, 16)) +} + +interface IObservable { +>IObservable : Symbol(IObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 2, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 22)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 24), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 5, 10)) + + get(): T; +>get : Symbol(IObservable.get, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 45)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 22)) + + readonly TChange: TChange; +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 24), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 5, 10)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 4, 24), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 5, 10)) +} + +export interface IReader { +>IReader : Symbol(IReader, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 7, 1)) + + readObservable(observable: IObservable): T; +>readObservable : Symbol(IReader.readObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 9, 26)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 10, 16)) +>observable : Symbol(observable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 10, 19)) +>IObservable : Symbol(IObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 2, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 10, 16)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 10, 16)) +} + +export abstract class ConvenientObservable implements IObservable { +>ConvenientObservable : Symbol(ConvenientObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 11, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 43)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 45), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 91)) +>IObservable : Symbol(IObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 2, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 43)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 45), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 91)) + + get TChange(): TChange { return null!; } +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 45), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 91)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 45), Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 91)) + + public abstract get(): T; +>get : Symbol(ConvenientObservable.get, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 14, 41)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 13, 43)) +} + +export abstract class BaseObservable extends ConvenientObservable { +>BaseObservable : Symbol(BaseObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 16, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 37)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 39)) +>ConvenientObservable : Symbol(ConvenientObservable, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 11, 1)) +>T : Symbol(T, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 37)) +>TChange : Symbol(TChange, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 39)) + + protected readonly observers = new Set(); +>observers : Symbol(BaseObservable.observers, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 18, 98)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>IObserver : Symbol(IObserver, Decl(classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts, 0, 0)) +} + diff --git a/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.types b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.types new file mode 100644 index 0000000000000..706dc2d2a501f --- /dev/null +++ b/tests/baselines/reference/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts] //// + +=== classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts === +interface IObserver { + handleChange(observable: IObservable, change: TChange): void; +>handleChange : (observable: IObservable, change: TChange) => void +>observable : IObservable +>change : TChange +} + +interface IObservable { + get(): T; +>get : () => T + + readonly TChange: TChange; +>TChange : TChange +} + +export interface IReader { + readObservable(observable: IObservable): T; +>readObservable : (observable: IObservable) => T +>observable : IObservable +} + +export abstract class ConvenientObservable implements IObservable { +>ConvenientObservable : ConvenientObservable + + get TChange(): TChange { return null!; } +>TChange : TChange +>null! : never + + public abstract get(): T; +>get : () => T +} + +export abstract class BaseObservable extends ConvenientObservable { +>BaseObservable : BaseObservable +>ConvenientObservable : ConvenientObservable + + protected readonly observers = new Set(); +>observers : Set +>new Set() : Set +>Set : SetConstructor +} + diff --git a/tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts b/tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts new file mode 100644 index 0000000000000..a5ab28856660f --- /dev/null +++ b/tests/cases/compiler/classExtendingAbstractClassWithMemberCalledTheSameAsItsOwnTypeParam.ts @@ -0,0 +1,25 @@ +// @strict: true +// @lib: esnext +// @noEmit: true + +interface IObserver { + handleChange(observable: IObservable, change: TChange): void; +} + +interface IObservable { + get(): T; + readonly TChange: TChange; +} + +export interface IReader { + readObservable(observable: IObservable): T; +} + +export abstract class ConvenientObservable implements IObservable { + get TChange(): TChange { return null!; } + public abstract get(): T; +} + +export abstract class BaseObservable extends ConvenientObservable { + protected readonly observers = new Set(); +} diff --git a/tests/cases/fourslash/quickInfoOnPropDeclaredUsingIndexSignatureOnInterfaceWithBase.ts b/tests/cases/fourslash/quickInfoOnPropDeclaredUsingIndexSignatureOnInterfaceWithBase.ts new file mode 100644 index 0000000000000..e55088eb64dd2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnPropDeclaredUsingIndexSignatureOnInterfaceWithBase.ts @@ -0,0 +1,12 @@ +/// + +// https://github.com/microsoft/TypeScript/issues/55251 + +//// interface P {} +//// interface B extends P { +//// [k: string]: number; +//// } +//// declare const b: B; +//// b.t/*1*/est = 10; + +verify.quickInfoAt("1", "(index) B[string]: number");