-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: v4.1.0-dev.20200826 (Nightly)
Search Terms: Type of property x circularly references itself in mapped type xx.
Code
type Extract<Root extends Record<string, any>> = {
[key in keyof Root]: Root[key]
}
type Effects<T> = (p: Extract<T>) => void
export const create: <Root extends Record<string, any>>() => <
E extends Effects<Root>,
S extends Record<string, any>
>(mo: {
state?: S;
effects?: E
}) => {
state: S;
effects: E
} = () => (p): any => p
interface Root {
foo: typeof foo
}
const foo = create<Root>()({
state: {
bar: 1
},
// effects: (dispatch) => {
// // worked without destructing dispatch
// console.log(dispatch.foo.state.bar);
// },
effects: ({ foo }) => {
// failed with destructing
console.log(foo.state.bar);
},
})
Expected behavior:
no errors with dispatch
destructed.
Actual behavior:
errors occurred when destructing dispatch
, but no errors while using it directly.
semoal
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug