preact-custom-elements types (#47779)

* preact-custom-elements types

* Tabs to Spaces

* test case for function call register from package preact-custom-element

* typing to export equals convention

* Tests adjusted to naming convention

* commonjs syntax for backwards compatibility

Co-authored-by: Kasper <kasper@sitepark.com>
This commit is contained in:
paull39 2020-09-21 17:33:14 +02:00 committed by GitHub
parent a349594bae
commit 21abd0b325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 0 deletions

15
types/preact-custom-element/index.d.ts vendored Normal file
View File

@ -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 <https://github.com/paull39>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.9
import { ComponentClass, FunctionComponent, FunctionalComponent } from 'preact';
declare function register(
componentDefinition: FunctionComponent<any> | ComponentClass<any> | FunctionalComponent<any>,
tagName: string,
observedAttributes?: string[],
options?: { shadow: boolean },
): void;
export = register;

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"preact": "^10.0.0"
}
}

View File

@ -0,0 +1,8 @@
import { h, render, Component, FunctionalComponent } from 'preact';
import register = require('preact-custom-element');
const Foo: FunctionalComponent<any> = props => {
return <div></div>;
};
register(Foo, 'my-foo');

View File

@ -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"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}