Repair stringification of nontrivial embedded values

This commit is contained in:
Tony Garnock-Jones 2022-04-27 22:07:44 +03:00
parent 197359ff22
commit 800e9ccf80
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { GenericEmbedded } from './embedded';
import { Embedded, GenericEmbedded } from './embedded';
import type { Value } from './values';
import { Annotated } from './annotated';
@ -13,8 +13,11 @@ export const stringifyEmbeddedWrite: EmbeddedWriter<any> = {
new Writer(s, this).push(v.generic);
} else {
try {
new Writer(s, this).push(fromJS(v));
return;
const j = fromJS(v);
if (!(j instanceof Embedded)) {
new Writer(s, this).push(j);
return;
}
} catch {}
try {
s.pieces.push(JSON.stringify(v));