diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fb6f7ba030..7d4afa76d3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4125,6 +4125,7 @@ /types/timelinejs3/ @MikeMatusz /types/timer-machine/ @dolanmiu /types/timezone-js/ @bonnici +/types/tinajs__tina/ @Jimexist /types/tinder/ @pingec /types/tiny-slider-react/ @screendriver /types/tinycolor2/ @M-Zuber @geertjansen @nvh diff --git a/types/tinajs__tina/index.d.ts b/types/tinajs__tina/index.d.ts new file mode 100644 index 0000000000..b29ad6bff9 --- /dev/null +++ b/types/tinajs__tina/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for @tinajs/tina 1.4 +// Project: https://github.com/tinajs/tina +// Definitions by: Jiayu Liu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tinajs__tina +// TypeScript Version: 2.2 + +export function use(plugin: any): void; + +export interface ComponentProperties { + [key: string]: any; +} + +export interface ComponentLifecycles { + created: () => void; + attached: () => void; + ready: () => void; + moved: () => void; + detached: () => void; +} + +export interface ComponentDefinitions extends ComponentLifecycles { + properties: ComponentProperties; + data: { [key: string]: any }; + compute: (data: { [key: string]: any }) => { [key: string]: any }; + methods: { [name: string]: (this: Component) => any }; + mixins: Array>; +} + +export class Component { + static define(definitions: Partial): void; + static mixin(definitions: Partial): void; + setData(data: { [key: string]: any }): void; + data: { [key: string]: any }; +} + +export interface PageHooks { + beforeLoad: (this: Page) => void; + onLoad: (this: Page) => void; + onReady: (this: Page) => void; + onShow: (this: Page) => void; + onHide: (this: Page) => void; + onUnload: (this: Page) => void; +} + +export interface PageEvents { + onPullDownRefresh: (event: Page) => void; + onReachBottom: (event: Page) => void; + onShareAppMessage: (event: Page) => void; + onPageScroll: (event: Page) => void; +} + +export interface PageDefinitions + extends ComponentDefinitions, + PageEvents, + PageHooks { + mixins: Array>; +} + +export class Page extends Component { + static define(definitions: Partial): void; + static mixin(definitions: Partial): void; +} diff --git a/types/tinajs__tina/tinajs__tina-tests.ts b/types/tinajs__tina/tinajs__tina-tests.ts new file mode 100644 index 0000000000..3f3fad874f --- /dev/null +++ b/types/tinajs__tina/tinajs__tina-tests.ts @@ -0,0 +1,57 @@ +import { Page, Component } from "@tinajs/tina"; + +function sayHi() { + return "hi"; +} + +Page.mixin({ + onLoad: sayHi, + created: sayHi +}); + +Component.mixin({ + created: sayHi +}); + +Page.define({ + properties: { + content: String + } +}); + +Page.define({ + mixins: [ + { + methods: { + lol() { + return; + } + } + }, + { + methods: { + tiktok() { + return; + } + } + } + ], + data: { + count: 0 + }, + compute({ count }) { + return { countPlus1: count + 1 }; + }, + onLoad() { + this.data.count; + }, + methods: { + handleTapButton() { + this.data.count; + } + } +}); + +Component.define({ + data: {} +}); diff --git a/types/tinajs__tina/tsconfig.json b/types/tinajs__tina/tsconfig.json new file mode 100644 index 0000000000..8c2f008caa --- /dev/null +++ b/types/tinajs__tina/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@tinajs/tina": ["tinajs__tina"] + } + }, + "files": ["index.d.ts", "tinajs__tina-tests.ts"] +} diff --git a/types/tinajs__tina/tslint.json b/types/tinajs__tina/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/tinajs__tina/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}