-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 2.1.5, 2.1.6, 2.2.0-dev20170203
VS Code Version: 1.9.1
Code
class Type<T> { t: T }
type TypeOf<T extends Type<any>> = T['t'];
type Props = { [key: string]: Type<any> };
declare function obj<P extends Props>(props: P): Type<{ [K in keyof P]: TypeOf<P[K]> }>;
const str = new Type<string>()
const A = obj({
a: str
})
type TypeOfA = TypeOf<typeof A> // => Intellisense correctly shows { a: string }
const B = obj({
b: obj({
c: str
})
})
type TypeOfB = TypeOf<typeof B> // => should be { b: { c: string } } but Intellisense shows { b: any; }
// though the inferred type seems correct
const b1: TypeOfB = {} // error
const b2: TypeOfB = { b: {} } // error
const b3: TypeOfB = { b: { c: 'foo' } } // NO error
Expected behavior:
Intellisense should show
type TypeOfB = {
b: {
c: string
};
}
Actual behavior:
Intellisense shows
type TypeOfB = {
b: any;
}
EDIT: detail screenshot
nsf, xealot, octatone, jacobwgillespie, AlexGalays and 14 morekrzkaczor
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed