diff: import of deep-diff to Typescript broken with 0.3.5 and 0.3.6
When the releases of the past 2 days, my current code is now broken. I believe this has to do with the imports of the package. This would be fine, except for two things:
- The version number updates should be compliant with SEMVER standards and issue a breaking change (IE. 0.4.0, not 0.3.x).
- The documentation (README etc) has no explanation of the import requirements of the package that are not ancient es versions.
On previous versions of deep-diff up until 0.3.4, my working code imported this package as:
import { diff } from 'deep-diff';
.. .. ..
.. .. ..
let isDifferent = diff(lh, rh);
This worked excellently. With the release of 0.3.5 and 0.3.6, the compiler now chokes on this import by stating flatly:
TypeError: deep_diff_1.diff is not a function
Punting to a catch-all import like this:
import * as dDiff from 'deep-diff';
also does no good.
I’m losing my mind trying to understand the change and how it can be accommodated and used in Typescript. I tried reviewing the ‘@types/deep-diff’ was no more helpful as it seems not to be current.
What export changes were made to deep-diff, and how should Typescript users now adjust to import this package? (again, all of this could be resolved instantly if there was a useful README.)…
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (4 by maintainers)
Commits related to this issue
- Update accumulator.js to address flitbit/diff#97 — committed to vergenzt/redux-deep-diff by vergenzt 6 years ago
Kinda hackish, isn’t it? 😃
I hoped for true es6 import like
import { deepDiff} from 'deep-diff'
orimport deepDiff from 'deep-diff'
I am trying to solve this issue by translating the methods definition for named exports. With that I was able to solve all cases pointed here, but when you you this module in a CommonJS environment, the following code will throw an error.
Will be needed to specify the method.
But it will work like a charm in ES2015/Typescript code.
While there is still no definitive solution, you could do:
Any solution here?
import { diff } from 'deep-diff'
is broken, no diff foundPlease reconfirm with
v1.0.0-pre.x
…Install with npm:
Many styled imports,
diff
,DeepDiff
, are interchangeable and refer to the same function, the API functions are properties of the default export:Plain
Destructure(ish)