Skip to content

typescript bindings for Svelte? #698

Closed Answered by fev4
smblee asked this question in Q&A
Jul 19, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

For anyone looking for this, the latest way to make this work is:

// app.d.ts
// first import the types for the form element you want to customize

import {
  HTMLInputAttributes,
  HTMLTextareaAttributes,
} from 'svelte/elements';

//...

declare module 'svelte/elements' {
  export interface HTMLInputAttributes {
    'on:accept'?: (event: any) => any;
  }
  export interface HTMLTextareaAttributes {
    'on:accept'?: (event: any) => any;
  }
}

// this is needed to not overwrite the types
export {};

Docs link.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@VityaSchel
Comment options

Answer selected by smblee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants