Skip to content
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

Add option preserveReferences #3

Merged
merged 7 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix reconstructing a map with preserveReferences false
remcohaszing committed Apr 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 70f3e3d9cc4637cc036ec737d6ccb6b784f09a90
5 changes: 4 additions & 1 deletion fixtures/map/input.js
Original file line number Diff line number Diff line change
@@ -12,4 +12,7 @@ export default (() => {

// Default output
// { preserveReferences: false }
const withoutPreserveReferences = new Map()
const withoutPreserveReferences = new Map([
[{}, 42],
[42, {}]
])
2 changes: 1 addition & 1 deletion src/estree-util-value-to-estree.ts
Original file line number Diff line number Diff line change
@@ -281,7 +281,7 @@ function processValue(value: unknown, context: Context): Expression {
const definition = context.define(value, {
type: 'NewExpression',
callee: identifier('Map'),
arguments: []
arguments: args
})

if (isIdentifier(definition)) {