79785930

Date: 2025-10-08 23:48:10
Score: 1.5
Natty:
Report link

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;
}
Reasons:
  • Blacklisted phrase (1): anyone knows
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: MichaƂ Krautforst