TypeScript/tests/cases/compiler/inferrenceInfiniteLoopWithSubtyping.ts
Anders Hejlsberg b78ef30cb7
No union subtype reduction during type inference (#37327)
* No union type subtype reduction in getImplicitIndexTypeOfType

* Add regression test
2020-03-11 10:27:51 -07:00

37 lines
1 KiB
TypeScript

// @filename: graphql-compose.d.ts
// @declaration: true
export type ObjMapReadOnly<T> = Readonly<{ [key: string]: Readonly<T> }>;
export type Thunk<T> = (() => T) | T;
export type ComposeOutputTypeDefinition = Readonly<ObjectTypeComposer<any, any> | EnumTypeComposer>;
export class EnumTypeComposer {
public setFields(fields: { [name: string]: { [key: string]: any } }): this;
}
export class ObjectTypeComposer<TSource, TContext> {
public setFields(fields: ObjMapReadOnly<Resolver>): this;
public addResolver<TResolverSource>(opts: { type?: Thunk<ComposeOutputTypeDefinition> }): this;
}
export class Resolver {
public wrapArgs<NewContext>(
cb: () => {
[argName: string]: Thunk<Readonly<EnumTypeComposer>>;
}
): void;
public wrapType(cb: () => ComposeOutputTypeDefinition): void;
}
// @filename: app.ts
import { ObjectTypeComposer } from './graphql-compose';
declare const User: ObjectTypeComposer<any, any>;
User.addResolver({
type: User, // `User as any` fix the problem
});