Skip to content

Commit ea04f4e

Browse files
Transpile with TypeScript
Replace Babel for compiling TypeScript code to JavaScript. Update to use TypeScript project references.
1 parent 6f75e6b commit ea04f4e

File tree

12 files changed

+72
-57
lines changed

12 files changed

+72
-57
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"prettier"
99
],
1010
"parserOptions": {
11-
"ecmaVersion": 2018
11+
"ecmaVersion": 2018,
12+
"project": ["./**/tsconfig.json", "./**/tsconfig.test.json"]
1213
},
1314
"rules": {
1415
"@typescript-eslint/no-shadow": "error",

demo/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"private": true,
55
"scripts": {
66
"build": "wp --config webpack.config.js",
7-
"lint": "tsc -p tsconfig.json && eslint ./src --report-unused-disable-directives --ext .js,.ts --parser-options=project:./tsconfig.json",
87
"test": "exit 0"
98
},
109
"devDependencies": {

demo/tsconfig.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"compilerOptions": {
3-
"lib": [
4-
"dom",
5-
"es5",
6-
"es2015.collection",
7-
"es2015.core",
8-
"es2015.iterable",
9-
"es2017.object"
10-
]
3+
"lib": ["dom", "es5"],
4+
"noEmit": true,
5+
"outDir": "lib",
6+
"rootDir": "src",
7+
"tsBuildInfoFile": "lib/demo.tsbuildinfo"
118
},
12-
"extends": "../packages/strings-to-regex/tsconfig.json",
13-
"include": ["../packages/strings-to-regex/src", "./src"]
9+
"extends": "../tsconfig.json",
10+
"exclude": ["**/*.spec.ts", "**/*.config.js"],
11+
"include": ["src"],
12+
"references": [{ "path": "../packages/strings-to-regex" }]
1413
}

demo/tsconfig.test.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["es5"],
4+
"noEmit": true,
5+
"outDir": "lib",
6+
"tsBuildInfoFile": "lib/test.tsbuildinfo",
7+
"types": ["jest"]
8+
},
9+
"extends": "../tsconfig.json",
10+
"include": ["src/**/*.spec.ts", "jest.config.js"],
11+
"references": [{ "path": "./" }]
12+
}

demo/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
noEmit: false,
1818
},
1919
configFile: resolve(__dirname, './tsconfig.json'),
20+
projectReferences: true,
2021
},
2122
},
2223
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "yarn workspaces run build",
99
"format": "prettier --write .",
10-
"lint": "yarn workspaces run lint",
10+
"lint": "tsc -b && eslint . --report-unused-disable-directives",
1111
"test": "yarn workspaces run test"
1212
},
1313
"devDependencies": {

packages/strings-to-regex/.babelrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/strings-to-regex/package.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
"node": ">=12"
2222
},
2323
"scripts": {
24-
"build": "run-s clean build:*",
25-
"build:src": "babel src -d lib --extensions '.js,.ts'",
26-
"build:types": "tsc -p ./tsconfig.types.json",
24+
"build": "tsc -b --clean && tsc -b",
2725
"changelog": "npx auto-changelog",
28-
"clean": "rimraf lib/*",
29-
"lint": "tsc -p ./tsconfig.json && eslint ./src --report-unused-disable-directives --ext .js,.ts --parser-options=project:./tsconfig.json",
3026
"release": "npx release-it --no-increment",
3127
"test": "jest --coverage"
3228
},
@@ -35,17 +31,11 @@
3531
"restoreMocks": true
3632
},
3733
"devDependencies": {
38-
"@babel/cli": "^7.5.5",
39-
"@babel/core": "^7.5.5",
40-
"@babel/preset-env": "^7.5.5",
41-
"@babel/preset-typescript": "^7.5.5",
4234
"@types/jest": "^27.0.1",
4335
"@types/jest-when": "^3.5.0",
4436
"jest": "^27.0.1",
4537
"jest-when": "^3.1.0",
46-
"npm-run-all": "^4.1.5",
4738
"regex-to-strings": "^2.0.1",
48-
"rimraf": "^3.0.2",
4939
"ts-jest": "^27.0.1",
5040
"typescript": "^4.1.3"
5141
},
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
{
22
"compilerOptions": {
3-
"allowJs": true,
4-
"baseUrl": "./",
5-
"checkJs": true,
6-
"downlevelIteration": true,
7-
"esModuleInterop": true,
8-
"forceConsistentCasingInFileNames": true,
93
"lib": [
104
"es5",
115
"es2015.collection",
126
"es2015.core",
137
"es2015.iterable",
148
"es2017.object"
159
],
16-
"module": "es2015",
17-
"moduleResolution": "node",
18-
"noEmit": true,
19-
"noImplicitReturns": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"outDir": "./lib",
23-
"pretty": true,
24-
"sourceMap": true,
25-
"strict": true
10+
"outDir": "lib",
11+
"rootDir": "src",
12+
"tsBuildInfoFile": "lib/tsconfig.tsbuildinfo"
2613
},
14+
"extends": "../../tsconfig.json",
15+
"exclude": ["**/*.spec.ts", "**/*.config.js"],
2716
"include": ["src"]
2817
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["es5", "es2015.core"],
4+
"noEmit": true,
5+
"outDir": "lib",
6+
"tsBuildInfoFile": "lib/test.tsbuildinfo",
7+
"types": ["jest", "jest-when"]
8+
},
9+
"extends": "../../tsconfig.json",
10+
"include": ["src/**/*.spec.ts", "jest.config.js"],
11+
"references": [{ "path": "./" }]
12+
}

0 commit comments

Comments
 (0)