-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Closed as not planned
Copy link
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 3.7.3
Code
type Schema = {
[key: string]: Number | String | Boolean | (() => Model<any>)
}
type Model<T extends Schema> = {
}
function model<T extends Schema>(type: Schema): Model<T> {
return undefined as any
}
const User = model({
id: Number,
name: String,
photo: () => Photo
})
const Photo = model({
id: Number,
filename: String,
user: () => User
})
Expected behavior:
No errors. I need this technic to implement automatically inferred circular types. I already have a class-based implementation (you can see example here) and I basically want same with objects of course without manually defining its type. If it's not a bug, any advances on how to implement it keeping type inferred are highly appreciated.
Actual behavior:
Gives following error:
'User' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.(7022)
amatiasq, vobarian, scaleflake, harrysolovay, semoal and 35 more
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed