Skip to content

Commit 2538220

Browse files
authored
Convert to typescript (#26)
1 parent 1f9f7da commit 2538220

19 files changed

+3206
-1681
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

.eslintrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": [
5+
"plugin:@typescript-eslint/recommended"
6+
],
7+
"rules": {
8+
"@typescript-eslint/member-ordering": 2,
9+
"@typescript-eslint/camelcase": 0,
10+
"@typescript-eslint/no-explicit-any": 0,
11+
"@typescript-eslint/no-inferrable-types": 0,
12+
"@typescript-eslint/explicit-function-return-type": 0,
13+
"@typescript-eslint/no-non-null-assertion": 0,
14+
"@typescript-eslint/interface-name-prefix": 0
15+
}
16+
}

babel.config.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
corejs: 3,
1111
},
1212
],
13-
]
13+
],
1414
},
1515
node: {
1616
presets: [
@@ -22,23 +22,21 @@ module.exports = {
2222
},
2323
},
2424
],
25-
]
25+
],
2626
},
2727
test: {
2828
presets: [
2929
[
3030
'@babel/preset-env',
3131
{
3232
targets: {
33-
node: 'current'
34-
}
35-
}
36-
]
37-
]
38-
}
33+
node: 'current',
34+
},
35+
},
36+
],
37+
],
38+
},
3939
},
40-
41-
plugins: [
42-
'@babel/plugin-proposal-class-properties'
43-
]
40+
presets: ['@babel/preset-typescript'],
41+
plugins: ['@babel/plugin-proposal-class-properties'],
4442
};

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

package-lock.json

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

package.json

+21-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
"description": "JavaScript client library for the Elastic Maps Service",
55
"main": "target/node/index.js",
66
"browser": "target/web/index.js",
7+
"types": "target/index.d.ts",
78
"scripts": {
8-
"test": "jest",
9-
"build": "yarn build-web && yarn build-node",
10-
"build-web": "BABEL_ENV=web babel src --config-file=./babel.config.js --out-dir=target/web --delete-dir-on-start",
11-
"build-node": "BABEL_ENV=node babel src --config-file=./babel.config.js --out-dir=target/node --delete-dir-on-start"
9+
"lint": "tsc --noEmit && yarn lint-es",
10+
"lint-es": "eslint --ext .ts,.tsx",
11+
"test": "yarn lint && jest",
12+
"build": "tsc --emitDeclarationOnly && yarn build-web && yarn build-node",
13+
"build-web": "BABEL_ENV=web babel src --extensions \".ts,.tsx\" --config-file=./babel.config.js --out-dir=target/web --delete-dir-on-start",
14+
"build-node": "BABEL_ENV=node babel src --extensions \".ts,.tsx\" --config-file=./babel.config.js --out-dir=target/node --delete-dir-on-start"
1215
},
1316
"repository": {
1417
"type": "git",
@@ -30,12 +33,24 @@
3033
"semver": "^6.3.0"
3134
},
3235
"devDependencies": {
33-
"node-fetch": "^1.7.3",
3436
"@babel/cli": "^7.6.4",
3537
"@babel/core": "^7.5.5",
3638
"@babel/plugin-proposal-class-properties": "^7.5.5",
3739
"@babel/preset-env": "^7.5.5",
40+
"@babel/preset-typescript": "^7.9.0",
41+
"@types/jest": "^25.2.1",
42+
"@types/lodash": "^4.14.150",
43+
"@types/mapbox-gl": "^1.9.1",
44+
"@types/node": "^13.13.5",
45+
"@types/node-fetch": "^2.5.7",
46+
"@types/semver": "^7.1.0",
47+
"@typescript-eslint/eslint-plugin": "^2.33.0",
48+
"@typescript-eslint/parser": "^2.33.0",
3849
"babel-jest": "^24.9.0",
39-
"jest": "^24.9.0"
50+
"eslint": "^7.0.0",
51+
"jest": "^25.5.4",
52+
"node-fetch": "^1.7.3",
53+
"ts-jest": "^25.5.1",
54+
"typescript": "^3.9.2"
4055
}
4156
}

0 commit comments

Comments
 (0)