Skip to content

Commit af8ff82

Browse files
committed
enable tests by adding babel ts tranform plugin
remove flow plugin
1 parent f8b6310 commit af8ff82

File tree

9 files changed

+63
-67
lines changed

9 files changed

+63
-67
lines changed

.babelrc-deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"plugins": [
3-
"@babel/plugin-transform-flow-strip-types",
4-
["./resources/add-extension-to-import-paths", { "extension": "js" }],
3+
"@babel/plugin-transform-typescript",
4+
["./resources/add-extension-to-import-paths", { "extension": "ts" }],
55
"./resources/inline-invariant"
66
]
77
}

.babelrc-npm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"plugins": [
3-
"@babel/plugin-transform-flow-strip-types",
3+
"@babel/plugin-transform-typescript",
44
"./resources/inline-invariant"
55
],
66
"env": {

.babelrc.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"plugins": ["@babel/plugin-transform-flow-strip-types"],
3-
"presets": [
4-
[
5-
"@babel/preset-env",
6-
{ "bugfixes": true, "targets": { "node": "current" } }
7-
]
8-
]
2+
"plugins": ["@babel/plugin-transform-typescript"],
3+
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
94
}

.mocharc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
throw-deprecation: true
22
check-leaks: true
33
require:
4-
- '@babel/register'
4+
- 'resources/ts-register.js'

package-lock.json

Lines changed: 47 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"scripts": {
2727
"preversion": ". ./resources/checkgit.sh && npm ci",
2828
"version": "node resources/gen-version.js && npm test && git add src/version.js",
29-
"fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.js",
29+
"fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts",
3030
"changelog": "node resources/gen-changelog.js",
3131
"benchmark": "node benchmark/benchmark.js",
3232
"test": "npm run lint && npm run check && npm run testonly && npm run prettier:check && npm run check:spelling && npm run check:integrations",
3333
"lint": "eslint --cache .",
3434
"check": "flow check",
35-
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.js",
35+
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts",
3636
"testonly:cover": "nyc npm run testonly",
3737
"prettier": "prettier --write --list-different .",
3838
"prettier:check": "prettier --check .",
@@ -46,7 +46,7 @@
4646
"devDependencies": {
4747
"@babel/core": "7.14.0",
4848
"@babel/eslint-parser": "7.13.14",
49-
"@babel/plugin-transform-flow-strip-types": "7.13.0",
49+
"@babel/plugin-transform-typescript": "7.13.0",
5050
"@babel/preset-env": "7.14.1",
5151
"@babel/register": "7.13.16",
5252
"@typescript-eslint/eslint-plugin": "4.22.1",

resources/build-deno.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (require.main === module) {
2222
const destPath = path.join('./denoDist', filepath);
2323

2424
fs.mkdirSync(path.dirname(destPath), { recursive: true });
25-
if (filepath.endsWith('.js')) {
25+
if (filepath.endsWith('.ts') && !filepath.endsWith('.d.ts')) {
2626
const options = { babelrc: false, configFile: './.babelrc-deno.json' };
2727
const output = babel.transformFileSync(srcPath, options).code + '\n';
2828
writeGeneratedFile(destPath, output);

resources/build-npm.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ if (require.main === module) {
2323
const destPath = path.join('./npmDist', filepath);
2424

2525
fs.mkdirSync(path.dirname(destPath), { recursive: true });
26-
if (filepath.endsWith('.js')) {
27-
const flowBody =
28-
'// @flow strict\n\n' + fs.readFileSync(srcPath, 'utf-8');
29-
fs.writeFileSync(destPath + '.flow', flowBody);
30-
26+
if (filepath.endsWith('.ts') && !filepath.endsWith('.d.ts')) {
3127
const cjs = babelBuild(srcPath, { envName: 'cjs' });
32-
writeGeneratedFile(destPath, cjs);
28+
writeGeneratedFile(destPath.replace(/\.ts$/, '.js'), cjs);
3329

3430
const mjs = babelBuild(srcPath, { envName: 'mjs' });
35-
writeGeneratedFile(destPath.replace(/\.js$/, '.mjs'), mjs);
31+
writeGeneratedFile(destPath.replace(/\.ts$/, '.mjs'), mjs);
3632
} else if (filepath.endsWith('.d.ts')) {
3733
fs.copyFileSync(srcPath, destPath);
3834
}

resources/ts-register.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
require('@babel/register')({ extensions: ['.ts'] });

0 commit comments

Comments
 (0)