Skip to content

Commit 81d72a0

Browse files
committed
fix
1 parent a59a2b8 commit 81d72a0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/context/script-let.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,12 @@ export class ScriptLetContext {
344344
);
345345

346346
if (ranges.defaultRange) {
347-
const defaultType = this.ctx.code.slice(...ranges.defaultRange);
348-
const id = this.generateUniqueId(defaultType);
349-
const scriptLet = `type ${id}=${this.ctx.code.slice(...ranges.defaultRange)};`;
347+
const eqDefaultType = this.ctx.code.slice(
348+
ranges.constraintRange?.[1] ?? ranges.idRange[1],
349+
ranges.defaultRange[1],
350+
);
351+
const id = this.generateUniqueId(eqDefaultType);
352+
const scriptLet = `type ${id}${eqDefaultType};`;
350353

351354
this.appendScript(
352355
scriptLet,
@@ -364,8 +367,7 @@ export class ScriptLetContext {
364367
(typeAnnotation as any).parent = param;
365368

366369
tokens.shift(); // type
367-
tokens.shift(); // id
368-
tokens.shift(); // =
370+
tokens.shift(); // ${id}
369371
tokens.pop(); // ;
370372

371373
// Disconnect the tree structure.

0 commit comments

Comments
 (0)