JSON-Patch icon indicating copy to clipboard operation
JSON-Patch copied to clipboard

importing fast-json-patch fails in typescript / angular 6

Open jeffreyabecker opened this issue 6 years ago • 4 comments

I'm getting an error when trying to import v 3.0.0: ERROR in ./node_modules/fast-json-patch/index.mjs Module parse failed: Unexpected token (25:4) You may need an appropriate loader to handle this file type.

as far as I can tell this is related to how typescript deals with .mjs files. However the package itself doesnt appear to have the source typescript files to use directly.

jeffreyabecker avatar Sep 04 '19 17:09 jeffreyabecker

I just checked with a plain TS project and it seems to work as expected with fast-json-patch 3.0.0-1.

I think that TypeScript works well with MJS as long as you have a current version of TSC. Any idea what's different in your setup?

Source: https://github.com/warpech/fast-json-patch-typescript-demo

(it's actually pretty similar to https://github.com/Starcounter-Jack/JSON-Patch/blob/18a14f0b7d4e567ef605d21dd681718968d642e5/test/spec/typings/typingsSpec.ts)

image

warpech avatar Sep 06 '19 08:09 warpech

The biggest difference I notice from that repo is that my ts code contains a line import * as jsonpatch from "fast-json-patch" Is it possible that you've not pushed something?

jeffreyabecker avatar Sep 06 '19 13:09 jeffreyabecker

Sorry, I forgot to push my final version of the files to https://github.com/warpech/fast-json-patch-typescript-demo

Now I have pushed it and the wildcard import works OK: https://github.com/warpech/fast-json-patch-typescript-demo/blob/b2a668291ba0701ec3bfaed97823f815c125bd45/index.ts#L2

warpech avatar Sep 06 '19 14:09 warpech

I have to believe this issue can be closed at this point?

rcollette avatar Feb 21 '23 19:02 rcollette