-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Describe the bug

Plugin throws above issue when used.
Expected behaviour
Plugin should format code
Actual behaviour
theme-tools/packages/prettier-plugin-liquid/src/printer/printer-liquid-html.ts
Lines 631 to 640 in b4cd181
| function hasOrIsNode<N extends LiquidHtmlNode, K extends keyof N>(node: N, key: K) { | |
| const v = node[key]; | |
| // this works because there's no ()[] type that is string | Node, it only | |
| // happens for singular nodes such as name: string | LiquidDrop, etc. | |
| return Array.isArray(v) || isNode(v); | |
| } | |
| function isNode(x: unknown): x is LiquidHtmlNode { | |
| return x !== null && typeof x === 'object' && 'type' in x && typeof x.type === 'string'; | |
| } |
In the minified build, this becomes (reformatted for readability):
function C(e, t) {
const r = e[t];
return (
Array.isArray(r) ||
(null !== (i = r) &&
"object" == typeof i &&
"type" in i &&
"string" == typeof i.type)
);
var i;
}The issue is because the "chunk" this function is inside already has const i = r(849) earlier, so instead of the var getting hoisted and assigned, it tries to reassign the const and throws an error. (in fact when i checked in the browser sources, the var i; statement was missing completely - possibly due to some DCE)
Debugging information
- MacOS
- Tahoe 26.2
Metadata
Metadata
Assignees
Labels
No labels