Skip to content

Commit b216843

Browse files
committed
Test TypeScript type definitions
1 parent 2fc9b95 commit b216843

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"scripts": {
1111
"clean": "rm -rf build dist",
1212
"flow": "flow check",
13+
"ts": "tsc --noEmit test/test-ts.ts",
1314
"lint": "eslint delegated-events.js test",
1415
"bootstrap": "git submodule update --init && npm install",
15-
"prebuild": "npm run clean && npm run flow && npm run lint",
16+
"prebuild": "npm run clean && npm run flow && npm run ts && npm run lint",
1617
"build": "rollup -c && cp delegated-events.js.flow dist/index.esm.js.flow && cp delegated-events.js.flow dist/index.umd.js.flow",
17-
"pretest": "npm run clean && npm run flow && npm run lint && rollup -c rollup.config.test.js",
18+
"pretest": "npm run clean && npm run flow && npm run ts && npm run lint && rollup -c rollup.config.test.js",
1819
"test": "karma start --single-run --browsers ChromeHeadless karma.conf.js",
1920
"prebrowser": "npm run pretest",
2021
"browser": "open \"file://$(pwd)/test/test.html\"",
@@ -42,7 +43,8 @@
4243
"prettier": "^1.18.2",
4344
"rollup": "^1.20.3",
4445
"rollup-plugin-babel": "^4.3.3",
45-
"rollup-plugin-node-resolve": "^5.2.0"
46+
"rollup-plugin-node-resolve": "^5.2.0",
47+
"typescript": "^3.6.3"
4648
},
4749
"files": [
4850
"dist",

test/test-ts.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {on} from '../index';
2+
3+
on('click', '.hubot', function(event) {
4+
const e: MouseEvent = event;
5+
event.button;
6+
7+
const self: Element = this;
8+
this.matches;
9+
10+
const t: Element = event.currentTarget;
11+
event.currentTarget.matches;
12+
});
13+
14+
on('custom:event', '.hubot', function(event) {
15+
const e: CustomEvent = event;
16+
event.detail;
17+
18+
const self: Element = this;
19+
this.matches;
20+
21+
const t: Element = event.currentTarget;
22+
event.currentTarget.matches;
23+
});
24+
25+
document.addEventListener('click', handleEvent);
26+
on('click', '.hubot', handleEvent);
27+
28+
function handleEvent(event: MouseEvent) {
29+
event.button;
30+
event.target;
31+
}

0 commit comments

Comments
 (0)