-
Notifications
You must be signed in to change notification settings - Fork 75
Add Option type for NULL fields #263
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if the property is nullable or not.
We should also consider the implications of wrapping the types with Option to dot notation usage in IDEs.
How can I check if a property is |
|
Tried my best to follow the styling~ let me know if any changes need to be made with my indentation. |
Any movement on this? |
This adds This appears to be a breaking change as the following code results in the following message: export interface UserIdentity {
// Unique identifier for the identity.
id: Option<string>;
// The identity's display name. Note that this may not always be available or up-to-date.
displayName: Option<string>;
// Indicates the client IP address used by user performing the activity (audit log only).
ipAddress: Option<string>;
// The userPrincipalName attribute of the user.
userPrincipalName: Option<string>;
}
/* Same issue */
// export interface UserIdentity {
// // Unique identifier for the identity.
// id: string | null | undefined;
// // The identity's display name. Note that this may not always be available or up-to-date.
// displayName: string | null | undefined;
// // Indicates the client IP address used by user performing the activity (audit log only).
// ipAddress: string | null | undefined;
// // The userPrincipalName attribute of the user.
// userPrincipalName: string | null | undefined;
// }
/* Original - this shows no warnings from TS */
// export interface UserIdentity {
// // Unique identifier for the identity.
// id?: string;
// // The identity's display name. Note that this may not always be available or up-to-date.
// displayName?: string;
// // Indicates the client IP address used by user performing the activity (audit log only).
// ipAddress?: string;
// // The userPrincipalName attribute of the user.
// userPrincipalName?: string;
// }
type Option<T> = T | undefined | null;
function printId(userIdentity: UserIdentity) {
console.log(userIdentity.id);
}
// let myObj = { id: "10", displayName: "Size 10 Object", ipAddress: null, userPrincipalName: null };
let myObj = { id: "10", displayName: "Size 10 Object" };
printId(myObj); @meme Can you help me understand what I see here? |
This was an oversight~ since |
To cover the point I mentioned in my review, dot notation in VSCode auto-complete doesn't break with this change. |
closes #257 |
#257