-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertType throws errors on valid union null results #73
Comments
A similar problem exists with type test1 = {
a?: number,
b: string
};
type test2 = {
a: null | number,
b: string
};
const testObject1 = {
a: null,
b: 'asdf'
};
const testObject2 = {
b: 'asdf'
};
console.log(is<test1>(testObject1), is<test1>(testObject2));
console.log(is<test2>(testObject1), is<test2>(testObject2)); output:
should be (as far as I know):
|
hi @stevenlaidlaw and @Pwuts I'm suspecting it has to do with the |
I've made a preliminary fix in v0.17.0 which hopefully addresses the Please let me know if it's working or not. |
it worked 🎉 |
@woutervh- in reference to my previous comment: with false true
false false with false true
true false with true true
true false The default of Some other possibly notable options from my tsconfig.json: "target": "ES2020",
"allowSyntheticDefaultImports": true,
"lib": ["ES2020", "dom"], |
(Sidenote: I looked into fixing this myself and making a PR, but there was so much code and it seemed immensely complex; I didn't even know where to begin. If you can point me in a direction I might be able to contribute.) |
const body: string | null = assertType<string | null>(null);
This simple test will cause a TypeGuardError to be thrown.
The text was updated successfully, but these errors were encountered: