-
Notifications
You must be signed in to change notification settings - Fork 13
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
Typehole not picking up nulls #14
Comments
It definitely seems like a bug. I wasn't able to reproduce it with const list = ["hello", null];
type AutoDiscovered = any;
list.forEach((val) => {
console.log(typehole.t3<AutoDiscovered>(val));
}); and keep getting There is a test case that checks that generating the right type from the samples, which leads me to believe that the issue might between the sample storage and the runtime. |
There also seems to be something off with how json-to-ts generates the types in case of With this input { __typeholeRootWrapper__: [ { a: 2 }, { a: null } ] } We get this output interface RootObject {
__typeholeRootWrapper__: TypeholeRootWrapper[];
}
interface TypeholeRootWrapper {
a?: number;
} I'd expect it to be interface RootObject {
__typeholeRootWrapper__: TypeholeRootWrapper[];
}
interface TypeholeRootWrapper {
a: number | null;
} There's actually an issue about the exact problem MariusAlch/json-to-ts#17 |
Yeah I wonder if these are related. Perhaps json-to-ts just doesn't handle nulls well |
I've now forked |
I've got a typehole as follows:
row
is the following in the debugger:Notice how
totalCompensation
isnull
even though the typehole only picks up the string. I would expect the generated type to betotalCompensation: string | null
;I did run this typehole a number of times and it should have picked up the
null
value before I put a breakpoint here for a screenshot.The text was updated successfully, but these errors were encountered: