Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug with shared reference + ES Set #27

Open
Jack-Works opened this issue May 18, 2022 · 2 comments
Open

Bug with shared reference + ES Set #27

Jack-Works opened this issue May 18, 2022 · 2 comments

Comments

@Jack-Works
Copy link
Contributor

Code:

import { Typeson } from 'typeson'
import { builtin } from 'typeson-registry'
const typeson = new Typeson().register([builtin])

const shared_reference = { hi: 1 }
const original = [
    //
    new Set([shared_reference]),
    new Set([shared_reference]),
]
console.log('Original:', original)

const toJson = typeson.encapsulate(original)
console.log('toJson:', toJson)

console.log('Revived:', typeson.revive(toJson))

image

@brettz9
Copy link
Collaborator

brettz9 commented May 19, 2022

While our Set type may be inadequate to handle such references, I wonder if typeson proper may also have issues dealing with this.

Unfortunately, I don't have the time to dig into this now. The typeson codebase and relevant portions of typeson-registry are not large, however, so you might be able to figure out an approach. Sorry couldn't be of more help.

@Jack-Works
Copy link
Contributor Author

Thanks for your reply! I understand that. I turn off the cyclic reference feature to make it work again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants