add typings for egjs-component

This commit is contained in:
sculove
2017-08-22 17:29:30 +09:00
parent cf0172024a
commit e57f80d903
4 changed files with 78 additions and 0 deletions
@@ -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
});
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for egjs-component 2.0
// Project: https://github.com/naver/egjs-component
// Definitions by: Naver <https://github.com/naver>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
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 module "@egjs/component";
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"egjs-component-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }