mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add type definitions for RE:DOM 3.6 (#20469)
Introduce new type definition package into repository which adds type definitions for a library called RE:DOM. These type definitions are made against RE:DOM version 3.6.2.
This commit is contained in:
parent
226a61a527
commit
a97f575766
69
types/redom/index.d.ts
vendored
Normal file
69
types/redom/index.d.ts
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
// Type definitions for redom 3.6
|
||||
// Project: https://github.com/redom/redom/
|
||||
// Definitions by: Rauli Laine <https://github.com/RauliL>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export type RedomElement = Node | RedomComponent;
|
||||
export type RedomQuery = string | RedomElement;
|
||||
export type RedomMiddleware = (el: HTMLElement) => void;
|
||||
export type RedomQueryArgumentValue = RedomElement | string | number | { [key: string]: any } | RedomMiddleware;
|
||||
export type RedomQueryArgument = RedomQueryArgumentValue | RedomQueryArgumentValue[];
|
||||
|
||||
export interface RedomComponent {
|
||||
el: HTMLElement;
|
||||
}
|
||||
|
||||
export interface RedomComponentConstructor {
|
||||
new (): RedomComponent;
|
||||
}
|
||||
|
||||
export class List implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any);
|
||||
|
||||
update(data: any[], context?: any): void;
|
||||
}
|
||||
|
||||
export class Place implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(View: RedomComponentConstructor, initData?: any);
|
||||
|
||||
update(visible: boolean, data?: any): void;
|
||||
}
|
||||
|
||||
export class Router implements RedomComponent {
|
||||
el: HTMLElement;
|
||||
|
||||
constructor(parent: RedomQuery, Views: RouterDictionary, initData?: any);
|
||||
|
||||
update(route: string, data?: any): void;
|
||||
}
|
||||
|
||||
export interface RouterDictionary {
|
||||
[key: string]: RedomComponentConstructor;
|
||||
}
|
||||
|
||||
export function html(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement;
|
||||
export function el(query: RedomQuery, ...args: RedomQueryArgument[]): HTMLElement;
|
||||
|
||||
export function list(parent: RedomQuery, View: RedomComponentConstructor, key?: string, initData?: any): List;
|
||||
|
||||
export function mount(parent: RedomElement, child: RedomElement, before?: RedomElement): RedomElement;
|
||||
export function unmount(parent: RedomElement, child: RedomElement): RedomElement;
|
||||
|
||||
export function place(View: RedomComponentConstructor, initData?: any): Place;
|
||||
|
||||
export function router(parent: RedomQuery, Views: RouterDictionary, initData?: any): Router;
|
||||
|
||||
export function setAttr(view: RedomElement, arg1: string | object, arg2?: string): void;
|
||||
|
||||
export function setStyle(view: RedomElement, arg1: string | object, arg2?: string): void;
|
||||
|
||||
export function setChildren(parent: RedomElement, children: RedomElement[]): void;
|
||||
|
||||
export function svg(query: RedomQuery, ...args: RedomQueryArgument[]): SVGElement;
|
||||
|
||||
export function text(str: string): Text;
|
||||
16
types/redom/redom-tests.ts
Normal file
16
types/redom/redom-tests.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import * as redom from 'redom';
|
||||
|
||||
const el1: HTMLElement = redom.el('');
|
||||
const el2: HTMLElement = redom.el('p', 'Hello, World!', (el: HTMLElement) => { el.setAttribute('ok', '!'); });
|
||||
const el3: HTMLElement = redom.html('p', 2, { color: 'red' });
|
||||
|
||||
redom.mount(document.body, el1);
|
||||
redom.mount(document.body, el2, el1);
|
||||
redom.unmount(document.body, el1);
|
||||
|
||||
redom.setAttr(el3, 'ok', '!');
|
||||
redom.setAttr(el3, { ok: '!' });
|
||||
redom.setStyle(el3, { color: 'blue' });
|
||||
redom.setChildren(el1, [el2, el3]);
|
||||
|
||||
redom.mount(document.body, redom.text('Hello, World!'));
|
||||
25
types/redom/tsconfig.json
Normal file
25
types/redom/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redom-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/redom/tslint.json
Normal file
1
types/redom/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user