Skip to content

Commit 8f8ae89

Browse files
authored
Bigints (#916)
* handle bigints in AST output tab * stringify bigints for console dupe detection
1 parent 83ae719 commit 8f8ae89

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/repl/src/lib/Output/AstNode.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<span class="token comment">{String(value)}</span>
9393
{:else}
9494
<span class="token {typeof value}">
95-
{JSON.stringify(value)}
95+
{typeof value === 'bigint' ? `${value}n` : JSON.stringify(value)}
9696
</span>
9797
{/if}
9898
</span>
@@ -170,7 +170,8 @@
170170
color: var(--shiki-token-string);
171171
}
172172
173-
.token.number {
173+
.token.number,
174+
.token.bigint {
174175
color: var(--shiki-token-constant);
175176
}
176177

packages/repl/src/lib/Output/srcdoc/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@
155155
return { type: 'Set', value };
156156
}
157157

158+
// if we don't handle bigints separately, they will cause JSON.stringify to blow up
159+
if (typeof value === 'bigint') {
160+
return { type: 'BigInt', value: value + '' };
161+
}
162+
158163
return value;
159164
});
160165
} catch (error) {

0 commit comments

Comments
 (0)