Skip to content

Commit 8a7eda9

Browse files
dgrahammuan
andcommitted
Configure compiler in tsconfig.json
Co-authored-by: Mu-An Chiou <[email protected]>
1 parent 2649dcb commit 8a7eda9

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

.eslintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"extends": [
33
"plugin:github/browser",
4-
"plugin:github/es6"
4+
"plugin:github/es6",
5+
"plugin:github/typescript"
56
],
6-
"parser": "babel-eslint",
7+
"globals": {
8+
"RemoteInputElement": "readable"
9+
},
710
"overrides": [
811
{
912
"files": "test/**/*.js",
1013
"rules": {
11-
"flowtype/require-valid-file-annotation": "off",
1214
"github/unescaped-html-literal": "off"
1315
}
1416
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
],
1313
"scripts": {
1414
"clean": "rm -rf dist",
15-
"lint": "github-lint",
15+
"lint": "github-lint src/*",
1616
"prebuild": "npm run clean && npm run lint",
17-
"build": "tsc --target es2019 --declaration --outDir dist src/index.ts ",
17+
"build": "tsc",
1818
"pretest": "npm run build",
1919
"test": "karma start test/karma.config.js",
2020
"prepublishOnly": "npm run build",

src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
class RemoteInputElement extends HTMLElement {
22
currentQuery: string | null
3-
debounceInputChange: (Event) => void
4-
boundFetchResults: (Event) => void
3+
debounceInputChange: (event: Event) => void
4+
boundFetchResults: (event: Event) => void
5+
6+
constructor() {
7+
super()
8+
this.currentQuery = null
9+
this.debounceInputChange = debounce(() => fetchResults(this))
10+
this.boundFetchResults = () => fetchResults(this)
11+
}
512

613
static get observedAttributes() {
714
return ['src']
@@ -20,8 +27,6 @@ class RemoteInputElement extends HTMLElement {
2027
input.setAttribute('autocomplete', 'off')
2128
input.setAttribute('spellcheck', 'false')
2229

23-
this.debounceInputChange = debounce(() => fetchResults(this))
24-
this.boundFetchResults = () => fetchResults(this)
2530
input.addEventListener('focus', this.boundFetchResults)
2631
input.addEventListener('change', this.boundFetchResults)
2732
input.addEventListener('input', this.debounceInputChange)
@@ -99,8 +104,8 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
99104
remoteInput.dispatchEvent(new CustomEvent('loadend'))
100105
}
101106

102-
function debounce(callback) {
103-
let timeout
107+
function debounce(callback: () => void) {
108+
let timeout: number
104109
return function() {
105110
clearTimeout(timeout)
106111
timeout = setTimeout(() => {

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "es2019",
5+
"strict": true,
6+
"declaration": true,
7+
"outDir": "dist",
8+
"removeComments": true,
9+
"preserveConstEnums": true
10+
},
11+
"files": [
12+
"src/index.ts"
13+
]
14+
}

0 commit comments

Comments
 (0)