You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It will be nice to separate the standard part from the PackageJson type into it's own type let's say PackageJson.PackageJsonStandard.
This will allow to use keyof PackageJson.PackageJsonStandard and get the actual keys.
Right now since there is & {[key: string]: unknown;} at the end of the type the keyof operator is not very useful it returns string | number.
My use-case is that I want to write a function to copy standard values from one package.json to anther and I want it to be typesafe.
Example:
functioncopyCommonPackageValues(target: PackageJson,origin: PackageJson,// This is not safe right now I need something like keyof PackageJson.PackageJsonStandardkeys: Array<keyofPackageJson>){for(constkeyofkeys){constvalue=origin[key];if(value){target[key]=value;}}}
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
The funding will be given to active contributors.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
I'm actually not sure why we have & {[key: string]: unknown;} there. Unless you see a good reason it's there, maybe we could just remove it? People that need it, could easily add that themselves.
Removing it will probably will be a major change for some people. If you have no problem with that I'm in. if not I can open a PR with the proposed change.
It will be nice to separate the standard part from the
PackageJson
type into it's own type let's sayPackageJson.PackageJsonStandard
.This will allow to use
keyof PackageJson.PackageJsonStandard
and get the actual keys.Right now since there is
& {[key: string]: unknown;}
at the end of the type thekeyof
operator is not very useful it returnsstring | number
.My use-case is that I want to write a function to copy standard values from one package.json to anther and I want it to be typesafe.
Example:
Upvote & Fund
The text was updated successfully, but these errors were encountered: