tweak types

pull/15000/head
Rich Harris 1 year ago
parent 999a05a3b7
commit 339ce842b9

@ -31,6 +31,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import type { Attachment } 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';
@ -862,7 +864,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
[key: `data-${string}`]: any;
// allow any attachment
[key: symbol]: (node: T) => void | (() => void);
[key: symbol]: Attachment<T>;
}
export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});

@ -5,8 +5,8 @@
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
*/
export interface Attachment {
(element: Element): void | (() => void);
export interface Attachment<T extends EventTarget = Element> {
(element: T): void | (() => void);
}
export * from './index.js';

@ -632,8 +632,8 @@ declare module 'svelte/attachments' {
* It can be attached to an element with an `{@attach ...}` tag, or by spreading an object containing
* a property created with [`createAttachmentKey`](https://svelte.dev/docs/svelte/svelte-attachments#createAttachmentKey).
*/
export interface Attachment {
(element: Element): void | (() => void);
export interface Attachment<T extends EventTarget = Element> {
(element: T): void | (() => void);
}
/**
* Creates an object key that will be recognised as an attachment when the object is spread onto an element,

Loading…
Cancel
Save