diff --git a/types/egjs__component/egjs__component-tests.ts b/types/egjs__component/egjs__component-tests.ts new file mode 100644 index 0000000000..010efdfb19 --- /dev/null +++ b/types/egjs__component/egjs__component-tests.ts @@ -0,0 +1,33 @@ +import * as Component from "@egjs/component"; + +class TestKlass extends Component { +} +let is = false; +const klass = new TestKlass(); +klass.options; + +is = klass.hasOn("click"); +klass.on("click", () => { +}); +klass.on({ + click1: () => { + }, + click2: e => { + } +}); +klass.once("click", () => { +}); +klass.once({ + click1: () => { + }, + click2: e => { + } +}); +klass.off("click", () => { +}); +klass.off("click"); +klass.off(); +is = klass.trigger("click"); +is = klass.trigger("click", { + test: 1 +}); diff --git a/types/egjs__component/index.d.ts b/types/egjs__component/index.d.ts new file mode 100644 index 0000000000..e52cbba65e --- /dev/null +++ b/types/egjs__component/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for egjs-component 2.0 +// Project: https://github.com/naver/egjs-component +// Definitions by: Naver +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export as namespace eg; + +export = Component; +declare class Component { + constructor(options?: { [key: string]: any }); + trigger(eventName: string, customEvent?: { [key: string]: any }): boolean; + hasOn(eventName: string): boolean; + on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): Component; + on(events: { [key: string]: (event: { [key: string]: any }) => any }): Component; + off(eventName?: string, handlerToAttach?: (event: { [key: string]: any }) => any): Component; + once(events: { [key: string]: (event: { [key: string]: any }) => any }): Component; + once(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): Component; + options: { [key: string]: any }; +} +declare namespace Component { + function trigger(eventName: string, customEvent?: { [key: string]: any }): boolean; + function hasOn(eventName: string): boolean; + function on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): Component; + function on(events: { [key: string]: (event: { [key: string]: any }) => any }): Component; + function off(eventName?: string, handlerToAttach?: (event: { [key: string]: any }) => any): Component; + function once(events: { [key: string]: (event: { [key: string]: any }) => any }): Component; + function once(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): Component; + let options: { [key: string]: any }; +} diff --git a/types/egjs__component/tsconfig.json b/types/egjs__component/tsconfig.json new file mode 100644 index 0000000000..b010a23eed --- /dev/null +++ b/types/egjs__component/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths":{ + "@egjs/component": ["egjs__component"] + } + }, + "files": [ + "index.d.ts", + "egjs__component-tests.ts" + ] +} diff --git a/types/egjs__component/tslint.json b/types/egjs__component/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/egjs__component/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }