slash icon indicating copy to clipboard operation
slash copied to clipboard

feat(@toss/utils): Add `ElementType` import from `@toss/utility-types`

Open minsoo-web opened this issue 1 year ago • 8 comments

Overview

Change import path local to @toss/utility-types Because this is likely to be a dualization of management.

PR Checklist

  • [x] I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

minsoo-web avatar Jun 16 '23 09:06 minsoo-web

Deploy request for slash-libraries pending review.

Visit the deploys page to approve it

Name Link
Latest commit add00be58605b22ee51cde305e3371fb9543ed77

netlify[bot] avatar Jun 16 '23 09:06 netlify[bot]

This is redundant:)

It could be a waste for people who don't use typescript!

ref https://github.com/toss/slash/pull/152#discussion_r1027409782

okinawaa avatar Jun 17 '23 00:06 okinawaa

Thank you for your kind explanation.

It could be a waste for people who don't use typescript!

I think this is different between dependencies and devdependencies. I use @toss/utility-types for devdependencies that is not installed for other users (who install @toss/utils)

For example, if you install @toss/react that have typescript package in devdependencies. But users node_modules is installed without typescript package includes any devdependencies in @toss/react.

스크린샷 2023-06-18 오후 5 21 01

reference. whats-the-difference-between-dependencies-devdependencies-and-peerdependencie

minsoo-web avatar Jun 18 '23 08:06 minsoo-web

Actually, when using ElementType from @toss/utility-types, we should use it as a regular dependency (not a devDependency). Otherwise, the returned type from pick or omit would not be inferred.

(Because pick returns Pick<ObjectType, ElementType<KeyTypes>>, and unless we install @toss/utility-types, the definition of ElementType is missing...)

raon0211 avatar Jun 19 '23 00:06 raon0211

This is a very tricky situation.

raon0211 avatar Jun 19 '23 00:06 raon0211

and unless we install @toss/utility-types, the definition of ElementType is missing...)

Oh,,, I missed of the impact of an installed package on another package.

It seems that @toss/utils already provides a function of typed utility. (e.g pick, omit, object-values etc..)

My solution is to add more util types used in utils packages like ObjectKeys to @toss/utility-types, and update devdependencies to dependencies

I think it's the difference between providing a lighter package to the user or guaranteeing the maintenance of the @toss/slash package.

minsoo-web avatar Jun 19 '23 05:06 minsoo-web

Adding "@toss/utily-types" to the dependencies is acceptable since it doesn't increase the size of the runtime bundle where it's utilized, despite potentially increasing the size of "@tossteam/utils" when fetched from npm.

artechventure avatar Jul 03 '23 06:07 artechventure

Adding "@toss/utily-types" to the dependencies is acceptable since it doesn't increase the size of the runtime bundle where it's utilized, despite potentially increasing the size of "@tossteam/utils" when fetched from npm.

Thank you for your kind explanation.

I have finished changing from devDependencies to dependencies. chore: add @toss/utility-types to dependencies

minsoo-web avatar Jul 03 '23 07:07 minsoo-web

Closing this pull request since this became stale. But we picked this change in the following commit: https://github.com/toss/slash/commit/063821639b8680bb1d0348306f43d26fb004a192. Thanks for your contribution!

raon0211 avatar May 31 '24 08:05 raon0211