-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@turf/clone] - object with key "length" is interpreted as array due to value.length in js code #1621
Comments
Thanks for the report @udos |
I've just done a quick check and I'm having trouble replicating your error Another option to check out is the v5 series of modules was published using regular js so there shouldn't be any ts to js transformation issues there. Hope that helps |
@rowanwins, I tried to reproduce on runkit but I'm struggling to understand how to use it properly :| is it possible that nodejs is using the ts files where the Array identification is properly identified? note: I'm using the latest versions via npm. actually I'm using @turf/simplify which at some point calls @turf/clone when the error is thrown. from your runkit I noticed that @turf/clone is at version 6.0.2. @turf/simplify is at version 5.1.5. @turf/clone is a dependency of @turf/simplify (package-lock.json):
so @turf/clone is "locked" at version 5.5. I will try to re-install @turf/simplify to see if this changes. |
As yes ok with v@5.1.5 of clone I'm seeing the issue, looks like the offending code is here . It looks like it was resolved last year in the v6 series here. The challenge you'll have is that |
thanks. no worries! the workaround until I will give that a try later today |
Fairly sure this would have been resolved when Turf updated its JS target from es5 (as of v5.1.5) to es20xx. Have confirmed the currently generated code for CJS and ESM builds uses the Have submitted PR #2749 to add a regression test making sure a property with a name |
I have a GeoJSON feature with a key "length":
at some point,
clone
is called, which interprets the processed object as an array due to linein
and throws an error...
looking at the TypeScript code, it looks as this is handled properly (source: https://github.com/Turfjs/turf/blob/master/packages/turf-clone/index.ts#L78):
there might be a reason for this, but it would be nice if JS array identification would be done in a more robust way.
p.s.: meanwhile I change my key :|
The text was updated successfully, but these errors were encountered: