diff --git a/types/preact-custom-element/index.d.ts b/types/preact-custom-element/index.d.ts new file mode 100644 index 0000000000..90b10814f2 --- /dev/null +++ b/types/preact-custom-element/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for preact-custom-element 4.0 +// Project: https://github.com/preactjs/preact-custom-element#readme +// Definitions by: Nicolai Kasper +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.9 + +import { ComponentClass, FunctionComponent, FunctionalComponent } from 'preact'; +declare function register( + componentDefinition: FunctionComponent | ComponentClass | FunctionalComponent, + tagName: string, + observedAttributes?: string[], + options?: { shadow: boolean }, +): void; + +export = register; diff --git a/types/preact-custom-element/package.json b/types/preact-custom-element/package.json new file mode 100644 index 0000000000..161a5cbf60 --- /dev/null +++ b/types/preact-custom-element/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "preact": "^10.0.0" + } +} diff --git a/types/preact-custom-element/preact-custom-element-tests.tsx b/types/preact-custom-element/preact-custom-element-tests.tsx new file mode 100644 index 0000000000..a838ed1ed6 --- /dev/null +++ b/types/preact-custom-element/preact-custom-element-tests.tsx @@ -0,0 +1,8 @@ +import { h, render, Component, FunctionalComponent } from 'preact'; +import register = require('preact-custom-element'); + +const Foo: FunctionalComponent = props => { + return
; +}; + +register(Foo, 'my-foo'); diff --git a/types/preact-custom-element/tsconfig.json b/types/preact-custom-element/tsconfig.json new file mode 100644 index 0000000000..d19cd7a0c4 --- /dev/null +++ b/types/preact-custom-element/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "jsx": "react", + "jsxFactory": "h", + "experimentalDecorators": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "preact-custom-element-tests.tsx" + ] +} diff --git a/types/preact-custom-element/tslint.json b/types/preact-custom-element/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/preact-custom-element/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}