redux-devtools icon indicating copy to clipboard operation
redux-devtools copied to clipboard

@types/lodash is listed as a dependency for react-json-tree when it should be a dev dependency

Open phapdinh opened this issue 5 months ago • 7 comments

in the package.json for react-json-tree, the typing for lodash is listed as a dependency when it should be a dev dependency

https://github.com/reduxjs/redux-devtools/blob/main/packages/react-json-tree/package.json#L43

Lodash also isn't a dependency in the package.json so the typing is unneeded

https://github.com/reduxjs/redux-devtools/blob/main/packages/react-json-tree/package.json

my solution is to remove the unneeded @types/lodash dependency

phapdinh avatar Jul 12 '25 03:07 phapdinh

The package is used in createStylingFromTheme.d.ts. Let me know if I'm missing anything.

Image

Methuselah96 avatar Sep 15 '25 14:09 Methuselah96

Dug down into the Lodash types. Seems like we could maybe just inline this?

    interface CurriedFunction1<T1, R> {
        (): CurriedFunction1<T1, R>;
        (t1: T1): R;
    }

markerikson avatar Sep 15 '25 14:09 markerikson

We could, but react-base16-styling uses CurriedFunction3 which is a bit less friendly. We could inline that as well, but I'm not sure there's a huge downside to depending on @types/lodash.

Methuselah96 avatar Sep 15 '25 14:09 Methuselah96

we could at least move it into a dev dependency to reduce package size

phapdinh avatar Sep 15 '25 23:09 phapdinh

Since the declaration files depend on it, it needs to be a normal dependency

Methuselah96 avatar Sep 16 '25 01:09 Methuselah96

@Methuselah96 react-json-tree is only an internal tool used by react-dev-tools. from my understanding, react-json-tree is not exposing any of it's types for use by any consuming package. declaration files that depend on dependencies to be normal if the declaration file is being used to exposed types to consuming packages which from my understanding of this package it is not. Since lodash is not listed as a dependency in the package.json, it is being used as a nested dependency and the types lodash are being pulled as a nested dependency as well since I built the package and the typings were still there for lodash. there is no need to pull in a type dependency when the nested dependency already pulls in the types for it. It is better to use the nested dependencies type since it will sync better with the version then leaving the dependency where it is now.

phapdinh avatar Sep 16 '25 02:09 phapdinh

@phapdinh here's a fork of this repo with all deps removed: https://www.npmjs.com/package/@gtk-grafana/react-json-tree (6.25KB gzipped as of 0.0.13)

gtk-grafana avatar Dec 03 '25 21:12 gtk-grafana