Bit: Incorrect update of dependency infos in dependency-resolver.ts

Created on 14 Nov 2019  路  3Comments  路  Source: teambit/bit

I stumbled upon this while I was trying to trace back another issue I currently have with dependency resolution. Simply these lines of code are useless this way:

https://github.com/teambit/bit/blob/5a60a41b5db67bba138e107e7c1481a5e3d5a089/src/consumer/component/dependencies/dependency-resolver/dependencies-resolver.ts#L1130

https://github.com/teambit/bit/blob/5a60a41b5db67bba138e107e7c1481a5e3d5a089/src/consumer/component/dependencies/dependency-resolver/dependencies-resolver.ts#L1135

They have to use push() instead of concat() like in the updater functions above/below those mentioned above.

You can find this problem directly on the master branch.

typbug

All 3 comments

@edmundmaruhn Thanks for reporting this.
You are correct!
Feel free to open a PR for this change.
I believe it should be

this.issues.missingPackagesDependenciesOnFs[originFile] = this.issues.missingPackagesDependenciesOnFs[originFile].concat(missingPackages); 

since push getting a one item and concat get an array.

@GiladShoham I would rather make use of the spread operator in conjunction with push(), since it's an in-place extension and does not need for reallocation of a new array. Since TypeScript is used it shouldn't be a problem using the spread operator. It's also shorter and more elegant:

this.issues.missingPackagesDependenciesOnFs[originFile].push(...missingPackages);

Do you see any reason against this?

No, I want to suggest that as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hwclass picture hwclass  路  3Comments

KutnerBitsrc picture KutnerBitsrc  路  4Comments

KutnerUri picture KutnerUri  路  3Comments

idkjs picture idkjs  路  4Comments

Nuruddinjr picture Nuruddinjr  路  3Comments