-
Notifications
You must be signed in to change notification settings - Fork 11
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
Null is usually not added to a variable's list of types #45
Comments
TY @Irelynx for the issue. Yes, |
This is caused by the Such as: class Foo {
testString1: string = null;
testNumber: number = null;
testBoolean: boolean = null;
}
const x = new Foo();
x.testString1 = null;
x.testNumber = null;
x.testBoolean = null; That is valid TS code with default tsconfig (with strictNullChecks disabled). So when you have class Foo {
testString1: string | null = null;
testNumber: number | null = null;
testBoolean: boolean | null = null;
} it is the same type, cuz those Solution is to enable the There is a way how to get that information anyway (that there is union with null), but it is quite complicated and not reliable. |
This must be handled so the reflection keeps standard behavior, no matter what the So not just But this has big impact and it is quite complicated to implement this into currect version so it will be in the |
Thanks a lot for your investigation! I will try change the tsconfig and test my code as soon as I have time for it. |
Hello.
I have tried to make some fields of class nullable, but can't get any information about allowed "nullable" behavior (same works with types, functions and interfaces too).
After a little investigation of the behavior, it turned out that the null type is added to field types in some cases. Here is an example code (ts) and "compiled" code (js):
As you can see, only types for
testNull
,testDate
,testNullLiteral
are shown as they should.Also, is the behavior of
testDate
correct?In
testDate
recursive reference specified to typetestDate
(_ßr.Type.store.getLazy(99)
)tst-reflect: 0.7.5
tst-reflect-transformer: 0.9.10
The text was updated successfully, but these errors were encountered: