-
Notifications
You must be signed in to change notification settings - Fork 906
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
chore: assign TS migration #709
chore: assign TS migration #709
Conversation
Looks like we can remove |
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.
Looking good!
packages/cli/src/tools/assign.ts
Outdated
return acc; | ||
}, {}); | ||
let descriptors = Object.keys(source).reduce( | ||
(acc: {[k: string]: any}, key) => { |
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.
how about moving the type to initial value in second argument of reduce? also, please use "unknown" instead of "any"
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.
Maybe PropertyDescriptorMap
it's a better fit than unknown
?
(acc: PropertyDescriptorMap, key: string) => {
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.
New update using PropertyDescriptorMap
. I had to add a safety check because getOwnPropertyDescriptor
also returns undefined.
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.
Also uknown
does not work that great here because you cannot pass it to Object.defineProperties
later on.
Removed. |
} | ||
return acc; | ||
}, | ||
{} as PropertyDescriptorMap, |
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.
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.
IMO it's a bit also more readable like you said, but we can wait for @thymikee opinion.
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.
I prefer {} as PropertyDescriptorMap
. As long as TS is able to give me correct autocompletion, it's better to rely on inference and type less imho :)
You may want to add |
@assuncaocharles missed that from other PRs, thanks |
Summary:
Migrated
assign.js
andisValidPackageName.js
to typescript. Related to #683Is
isValidPackageName
used by external tool? Because it's not being used inside CLI so maybe we can remove it.