TypeScript Version: 2.3.0
Code
I'd like this to be a valid TS:
interface T {
a: number;
b: void;
}
const x: T = { a: 1 }
Why would I?
This contrived example doesn't make much sense. Why would someone define a property of type void and then be willing to skip it, right?
Here's a lengthy explanation of my problem: http://stackoverflow.com/questions/43387510/typescript-for-generic-type-interface-make-the-property-required-only-if-its
Long story short I have a generic interface, whenever the type parameter is a real type I want the property to be required, so I cannot mark it as optional.
But if the type is void (and I do use 2.3.0's default type parameters feature to set it and thus make the type parameter itself optional) I don't want to keep typing b: undefined everywhere.
Impact on emitted code: none, it only touches the TS compile-time validation.
TypeScript Version: 2.3.0
Code
I'd like this to be a valid TS:
Why would I?
This contrived example doesn't make much sense. Why would someone define a property of type
voidand then be willing to skip it, right?Here's a lengthy explanation of my problem: http://stackoverflow.com/questions/43387510/typescript-for-generic-type-interface-make-the-property-required-only-if-its
Long story short I have a generic interface, whenever the type parameter is a real type I want the property to be required, so I cannot mark it as optional.
But if the type is
void(and I do use 2.3.0's default type parameters feature to set it and thus make the type parameter itself optional) I don't want to keep typingb: undefinedeverywhere.Impact on emitted code: none, it only touches the TS compile-time validation.