Add ComponentOptions type definition and update index.ts to use it

This commit is contained in:
Astrian Zheng 2025-05-14 10:19:10 +10:00
parent 8fe77f3b9b
commit 5a1d8469d6
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
3 changed files with 10 additions and 9 deletions

View File

@ -1,11 +1,4 @@
export default (options: { export default (options: ComponentOptions) => {
tag: string
template: string
style?: string
onMount?: () => void
onUnmount?: () => void
onAttributeChanged?: (attrName: string, oldValue: string, newValue: string) => void
}) => {
const { tag, template, style, onMount, onUnmount, onAttributeChanged } = options const { tag, template, style, onMount, onUnmount, onAttributeChanged } = options
class CustomElement extends HTMLElement { class CustomElement extends HTMLElement {

8
src/types/ComponentOptions.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
interface ComponentOptions {
tag: string
template: string
style?: string
onMount?: () => void
onUnmount?: () => void
onAttributeChanged?: (attrName: string, oldValue: string, newValue: string) => void
}

View File

@ -32,7 +32,7 @@
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ "typeRoots": ["./src/types"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */