-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Design Meeting Notes, 11/17/2017 #20117
Comments
My notes: Strict Property Initialization Checks in Classes
|
This sounds funny. Nearly all of our classes are handled by some sort of IoC container. Sometimes(99% in my case) classes, are just definitions and construction is "inversioned". The IoC container takes care of construction of the class. I don't want the compiler to complain in these type of classes. And providing a flag to opt-out or banging all the properties doesn't sound optimal either. One suggestion, I can think of, at least for the decorator use case, is to have a modifier on the "definition" class decorator. In the below example you can see a export function Entity(definitions?: EntityDefinitions) {
return constructtarget function(target: any) {
//...
};
} And applying it on entity definitions will not cause any errors: @Entity()
class User {
@Column()
name: string; // no error
@Column()
age: number; // no error
} Example from TypeOrm https://github.com/typeorm/typeorm. |
We discussed decorators that can declare how they modify the target, so it's an option, but others in the meeting felt like doing so shouldn't be a blocker for the flag as it exists today. |
Should this flag hold off from graduating to If it needs to be disabled for a all/large subset of angular code out there, perception of TS as a stable platform might be affected. |
we have the infrastructure in place to opt-out of specific |
Hope you're right — regardless of technical reasoning you still want gain > pain to proceed |
I think many people would rather bang all properties than setting the flag, to just keep the default "strict" mode. But I hope the TS team can hold this off a bit, certainly a contentious topic. As of right now, it feels like a choice between pest and colera. |
Strict property initialization checks in classes
abstract
properties should be excludedT extends number | underfed
is an error, since we do not know if it is one or the other at instantiation time--strictPropertyInitialization
x["foo"]
currently, we only do it onx.foo
.// @ts-ignore
"b"
lateinit
, swift haslazy
?a!: number
const
readonly
is ok to have!
to allow for externalstatic
s!
The text was updated successfully, but these errors were encountered: