Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
* Similar to Object.assign(), but it doesn't execute getters. This allows us to have
* lazy properties on an object and still be able to merge them together
*
* @flow
*/
export default function assign(target: Object, ...sources: Object[]) {
sources.forEach(source => {
let descriptors = Object.keys(source).reduce((acc, key) => {
acc[key] = Object.getOwnPropertyDescriptor(source, key);
return acc;
}, {});
let descriptors = Object.keys(source).reduce(
(acc, key) => {
const propertyDescriptor = Object.getOwnPropertyDescriptor(source, key);
if (propertyDescriptor !== undefined) {
acc[key] = propertyDescriptor;
}
return acc;
},
{} as PropertyDescriptorMap,
Copy link
Contributor

@assuncaocharles assuncaocharles Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's more readable with the typing in the parameters?!?

(acc: PropertyDescriptorMap, key: string) => {

So you avoid the typecasting in the initial value as PropertyDescriptorMap

But it's just my opinion 🤔

What do you think, @thymikee and @radko93?

Copy link
Contributor Author

@radko93 radko93 Sep 11, 2019

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.

Copy link
Member

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 :)

);
// by default, Object.assign copies enumerable Symbols too
Object.getOwnPropertySymbols(source).forEach(sym => {
let descriptor = Object.getOwnPropertyDescriptor(source, sym);
Expand Down
14 changes: 0 additions & 14 deletions packages/cli/src/tools/isValidPackageName.js

This file was deleted.