update type

pull/15091/head
Jayden Carey 2 years ago
parent 51c540c66f
commit 561ed8f3d9

@ -31,6 +31,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { AttachmentsKey } from 'svelte/attachments';
// Note: We also allow `null` as a valid value because Svelte treats this the same as `undefined`
type Booleanish = boolean | 'true' | 'false';
@ -861,7 +863,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
[key: `data-${string}`]: any;
// allow any attachment
[key: symbol]: (node: T) => void | (() => void);
[AttachmentsKey]: Array<(node: T) => void | (() => void)>;
}
export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});

@ -1,4 +1,9 @@
declare const brand: unique symbol;
type Brand<B> = { [brand]: B };
type Branded<T, B> = T & Brand<B>;
type AttachmentsKeySymbol = Branded<symbol, 'svelte.attachments'>;
/**
* A unique symbol used for defining the attachments to be applied to an element or component.
*/
export const AttachmentsKey: unique symbol;
export const AttachmentsKey: AttachmentsKeySymbol;

@ -267,7 +267,7 @@ export function build_component(node, component_name, context, anchor = context.
push_prop(
b.prop(
'get',
b.call('Symbol'),
b.call("Symbol.for('svelte.attachments')"),
/** @type {Expression} */ (
context.visit(attachment.type === 'SpreadElement' ? attachment.argument : attachment)
),

Loading…
Cancel
Save