Closed
Description
🐛 Bug Report
import { produce, Draft } from 'immer';
const x = { a: 1 };
function wrapper<T>(s: T, fn: (d: Draft<T>) => void) {
const result = produce(s, (y) => {
return fn(y);
});
return result;
}
function wrapper2<T>(s: T, fn: (d: Draft<T>) => any) {
const result = produce(s, (y) => {
return fn(y);
});
return result;
}
const res = wrapper(x, (y) => {
y.a = 1;
}); // {a:number}
const res2 = wrapper2(x, (y) => {
y.a = 2;
}); // Promise<{a:number}>
res2.then(x => {
console.log('x:',x) // crash
})
console.log(x, res, res2);
Activity
fix: immerjs#785 fix type inference for produce
fix: immerjs#785 fix type inference for produce
mweststrate commentedon Apr 25, 2021
🎉 This issue has been resolved in version 9.0.2 🎉
The release is available on:
Your semantic-release bot 📦🚀