Apparently, it's been talked about since 2022 - https://github.com/microsoft/TypeScript/issues/51556
there is a hacky way to do this, I'm wondering if anyone knows a better way
type Foo = {
a?: string;
}
const getFooWithSatisfiesError = (function(){
if(Math.random()) {
return null; // this will result in type error
}
return { a: '1', 'b': 2 }
}) satisfies () => Foo
getFooWithSatisfiesError()
// const getFooWithSatisfiesError: () => {
// a: string;
// b: number;
}