phetsims / chipper

Tools for developing and building PhET interactive simulations.
http://scenerystack.org/
MIT License
12 stars 14 forks source link

Better type for Lodash in phetioCompareAPIs.ts #1536

Open samreid opened 3 hours ago

samreid commented 3 hours ago

phetioCompareAPIs.ts currently has:

// TODO: how to type this? https://github.com/phetsims/chipper/issues/1465
type Lodash = any;

@zepumph and I discussed that it would be preferable to get the types from lodash, but it must be done in typespace only so it is compatible with node, browser built and browser unbuilt.

samreid commented 3 hours ago

I found that import type { LoDashStatic } from 'lodash' seems to work well, keeps everything in type space. I tested that this runs properly in density => phet-io standalone + phetioCompareAPIs. If this seems reasonable to you, can you please spot check the type assertions I added to make this work?