Browse Source
* Use unreachable exception in favor of type safety * Add tests * add testpull/22945/head
Eric Wang
5 years ago
committed by
GitHub
5 changed files with 38 additions and 9 deletions
@ -0,0 +1,8 @@ |
|||
import UnreachableException from '../unreachableException'; |
|||
|
|||
describe('UnreachableException', () => { |
|||
it('error thrown matches snapshot', () => { |
|||
const exception = new UnreachableException('some value'); |
|||
expect(exception.message).toMatchInlineSnapshot(`"unreachable case: \\"some value\\""`); |
|||
}); |
|||
}); |
@ -0,0 +1,5 @@ |
|||
export default class UnreachableException { |
|||
constructor(value: never) { |
|||
return new Error(`unreachable case: ${JSON.stringify(value)}`); |
|||
} |
|||
} |
Loading…
Reference in new issue