Skip to content

Commit 561ed8f

Browse files
committed
update type
1 parent 51c540c commit 561ed8f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/svelte/elements.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
3232
// TypeScript Version: 2.8
3333

34+
import { AttachmentsKey } from 'svelte/attachments';
35+
3436
// Note: We also allow `null` as a valid value because Svelte treats this the same as `undefined`
3537

3638
type Booleanish = boolean | 'true' | 'false';
@@ -861,7 +863,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
861863
[key: `data-${string}`]: any;
862864

863865
// allow any attachment
864-
[key: symbol]: (node: T) => void | (() => void);
866+
[AttachmentsKey]: Array<(node: T) => void | (() => void)>;
865867
}
866868

867869
export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
declare const brand: unique symbol;
2+
type Brand<B> = { [brand]: B };
3+
type Branded<T, B> = T & Brand<B>;
4+
type AttachmentsKeySymbol = Branded<symbol, 'svelte.attachments'>;
5+
16
/**
27
* A unique symbol used for defining the attachments to be applied to an element or component.
38
*/
4-
export const AttachmentsKey: unique symbol;
9+
export const AttachmentsKey: AttachmentsKeySymbol;

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export function build_component(node, component_name, context, anchor = context.
267267
push_prop(
268268
b.prop(
269269
'get',
270-
b.call('Symbol'),
270+
b.call("Symbol.for('svelte.attachments')"),
271271
/** @type {Expression} */ (
272272
context.visit(attachment.type === 'SpreadElement' ? attachment.argument : attachment)
273273
),

0 commit comments

Comments
 (0)