Skip to content

Commit d53afe1

Browse files
authoredAug 21, 2022
feat!: upgrade ts@v4.7, remove unnecessary plugins, dual ESM (#153)
1 parent 4c8ddb4 commit d53afe1

40 files changed

+7675
-5878
lines changed
 

‎.changeset/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"$schema": "https://unpkg.com/@changesets/config@1.6.0/schema.json",
2+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
33
"changelog": [
44
"@changesets/changelog-github",
55
{
6-
"repo": "rx-ts/babel-preset-proposal-typescript"
6+
"repo": "un-ts/babel-preset-proposal-typescript"
77
}
88
],
99
"commit": false,

‎.codesandbox/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"node": "14",
2+
"node": "16",
33
"sandboxes": []
44
}

‎.eslintignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
!/.*.js
21
coverage
32
lib
43
node_modules
54
CHANGELOG.md
6-
# babel-eslint parse issue, ignore temporarily
7-
test/private-methods.ts
5+
/test/v8intrinsic.cjs
6+
!/.github
7+
!/.*.js

‎.eslintrc.js ‎.eslintrc.cjs

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@ const {
22
configs,
33
jest,
44
js,
5+
json,
6+
jsonc,
57
test,
68
ts,
79
md,
810
mdx,
11+
yml,
912
} = require('@1stg/eslint-config/overrides')
1013

11-
const tsBase = ts[0]
12-
1314
module.exports = {
1415
extends: ['@1stg/eslint-config/base'],
1516
overrides: [
16-
tsBase,
17+
ts[0],
1718
{
1819
...js,
1920
files: 'test/*.{js,ts}',
2021
rules: js.rules,
2122
},
2223
jest,
24+
json,
25+
jsonc,
2326
md,
2427
mdx,
2528
test,
2629
configs,
30+
yml,
2731
],
2832
}

‎.github/FUNDING.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
github: [JounQin]
2-
open_collective: rxts
1+
github:
2+
- JounQin
3+
- 1stG
4+
- rxts
5+
- unts
6+
patreon: 1stG
7+
open_collective: unts
8+
custom:
9+
- https://opencollective.com/1stG
10+
- https://opencollective.com/rxts
11+
- https://afdian.net/@JounQin

‎.github/workflows/ci.yml

+6-31
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,28 @@ jobs:
1010
strategy:
1111
matrix:
1212
node:
13-
- 12
1413
- 14
1514
- 16
15+
- 18
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout Repo
19-
uses: actions/checkout@master
19+
uses: actions/checkout@v3
2020

2121
- name: Setup Node.js ${{ matrix.node }}
22-
uses: actions/setup-node@master
22+
uses: actions/setup-node@v3
2323
with:
2424
node-version: ${{ matrix.node }}
25-
26-
- name: Link Yarn global binaries into PATH
27-
run: echo "$(yarn global bin)" >> $GITHUB_PATH
28-
29-
- name: Get yarn cache directory path
30-
id: yarn-cache-dir-path
31-
run: echo "::set-output name=dir::$(yarn cache dir)"
32-
33-
- uses: actions/cache@v2
34-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
35-
with:
36-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
37-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
38-
restore-keys: |
39-
${{ runner.os }}-yarn-
25+
cache: yarn
4026

4127
- name: Install Dependencies
4228
run: yarn --frozen-lockfile
4329

4430
- name: Build, Lint and test
45-
run: |
46-
yarn build
47-
yarn lint
48-
yarn test
31+
run: yarn run-s build lint test
4932
env:
5033
EFF_NO_LINK_RULES: true
5134
PARSER_NO_WATCH: true
5235

5336
- name: Codecov
54-
run: |
55-
yarn global add codecov codacy-coverage
56-
codecov
57-
cat ./coverage/lcov.info | codacy-coverage -u rx-ts -n babel-preset-proposal-typescript
58-
env:
59-
CI: 'true'
60-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
61-
CODACY_ACCOUNT_TOKEN: ${{ secrets.CODACY_ACCOUNT_TOKEN }}
62-
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
37+
uses: codecov/codecov-action@v3

‎.github/workflows/release.yml

+9-24
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,25 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout Repo
14-
uses: actions/checkout@master
14+
uses: actions/checkout@v3
1515
with:
1616
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1717
fetch-depth: 0
1818

19-
- name: Setup Node.js 14.x
20-
uses: actions/setup-node@master
19+
- name: Setup Node.js 16
20+
uses: actions/setup-node@v3
2121
with:
22-
node-version: 14.x
23-
24-
- name: Get yarn cache directory path
25-
id: yarn-cache-dir-path
26-
run: echo "::set-output name=dir::$(yarn cache dir)"
27-
28-
- uses: actions/cache@v2
29-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
30-
with:
31-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
33-
restore-keys: |
34-
${{ runner.os }}-yarn-
35-
36-
- name: Install Dependencies
37-
# https://github.com/atlassian/changesets/issues/246
38-
run: |
39-
yarn --frozen-lockfile
40-
rm -rf .git/hooks/commit-msg
22+
node-version: 16
23+
cache: yarn
4124

4225
- name: Create Release Pull Request or Publish to npm
4326
id: changesets
44-
uses: changesets/action@master
27+
uses: changesets/action@v1
4528
with:
4629
# This expects you to have a script called release which does a build for your packages and calls changeset publish
47-
publish: npm run release
30+
publish: yarn release
31+
commit: 'chore: release babel-preset-proposal-typescript'
32+
title: 'chore: release babel-preset-proposal-typescript'
4833
env:
4934
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5035
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

‎.lintstagedrc.js ‎.lintstagedrc.cjs

File renamed without changes.

‎.remarkrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"plugins": [
3-
"@1stg/remark-config"
3+
"@1stg/preset"
44
]
55
}
File renamed without changes.

‎README.md

+14-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# babel-preset-proposal-typescript
22

3-
[![GitHub Actions](https://github.com/rx-ts/babel-preset-proposal-typescript/workflows/CI/badge.svg)](https://github.com/rx-ts/babel-preset-proposal-typescript/actions/workflows/ci.yml)
4-
[![Codecov](https://img.shields.io/codecov/c/github/rx-ts/babel-preset-proposal-typescript.svg)](https://codecov.io/gh/rx-ts/babel-preset-proposal-typescript)
5-
[![Codacy Grade](https://img.shields.io/codacy/grade/bb554fe914d64b4b87cadb8a48b2a97b)](https://www.codacy.com/gh/rx-ts/babel-preset-proposal-typescript)
3+
[![GitHub Actions](https://github.com/un-ts/babel-preset-proposal-typescript/workflows/CI/badge.svg)](https://github.com/un-ts/babel-preset-proposal-typescript/actions/workflows/ci.yml)
4+
[![Codecov](https://img.shields.io/codecov/c/github/un-ts/babel-preset-proposal-typescript.svg)](https://codecov.io/gh/un-ts/babel-preset-proposal-typescript)
5+
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/un-ts/babel-preset-proposal-typescript.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/un-ts/babel-preset-proposal-typescript/context:javascript)
66
[![npm](https://img.shields.io/npm/v/babel-preset-proposal-typescript.svg)](https://www.npmjs.com/package/babel-preset-proposal-typescript)
7-
[![GitHub Release](https://img.shields.io/github/release/rx-ts/babel-preset-proposal-typescript)](https://github.com/rx-ts/babel-preset-proposal-typescript/releases)
8-
9-
[![David Peer](https://img.shields.io/david/peer/rx-ts/babel-preset-proposal-typescript.svg)](https://david-dm.org/rx-ts/babel-preset-proposal-typescript?type=peer)
10-
[![David](https://img.shields.io/david/rx-ts/babel-preset-proposal-typescript.svg)](https://david-dm.org/rx-ts/babel-preset-proposal-typescript)
11-
[![David Dev](https://img.shields.io/david/dev/rx-ts/babel-preset-proposal-typescript.svg)](https://david-dm.org/rx-ts/babel-preset-proposal-typescript?type=dev)
7+
[![GitHub Release](https://img.shields.io/github/release/un-ts/babel-preset-proposal-typescript)](https://github.com/un-ts/babel-preset-proposal-typescript/releases)
128

139
[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
1410
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
@@ -36,18 +32,15 @@ So that you can use babel to transform proposals which are current in stage 0-2
3632
## Enabled proposal plugins
3733

3834
1. [async-do-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-async-do-expressions)
39-
2. [class-properties](https://www.npmjs.com/package/@babel/plugin-proposal-class-properties)
40-
3. [class-static-block](https://www.npmjs.com/package/@babel/plugin-proposal-class-static-block)
41-
4. [do-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-do-expressions)
42-
5. [function-bind](https://www.npmjs.com/package/@babel/plugin-proposal-function-bind)
43-
6. [function-sent](https://www.npmjs.com/package/@babel/plugin-proposal-function-sent)
44-
7. [json-strings](https://www.npmjs.com/package/@babel/plugin-proposal-json-strings)
45-
8. [partial-application](https://www.npmjs.com/package/@babel/plugin-proposal-partial-application)
46-
9. [pipeline-operator](https://www.npmjs.com/package/@babel/plugin-proposal-pipeline-operator)
47-
10. [private-property-in-object](https://www.npmjs.com/package/@babel/plugin-proposal-private-property-in-object)
48-
11. [record-and-tuple](https://www.npmjs.com/package/@babel/plugin-proposal-record-and-tuple)
49-
12. [throw-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-throw-expressions)
50-
13. [v8intrinsic](./src/v8intrinsic.ts) - [Further Detail](https://babeljs.io/blog/2019/09/05/7.6.0#v8-intrinsic-runtime-functions-parsing-10148httpsgithubcombabelbabelpull10148)
35+
2. [do-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-do-expressions)
36+
3. [function-bind](https://www.npmjs.com/package/@babel/plugin-proposal-function-bind)
37+
4. [function-sent](https://www.npmjs.com/package/@babel/plugin-proposal-function-sent)
38+
5. [json-strings](https://www.npmjs.com/package/@babel/plugin-proposal-json-strings)
39+
6. [partial-application](https://www.npmjs.com/package/@babel/plugin-proposal-partial-application)
40+
7. [pipeline-operator](https://www.npmjs.com/package/@babel/plugin-proposal-pipeline-operator)
41+
8. [record-and-tuple](https://www.npmjs.com/package/@babel/plugin-proposal-record-and-tuple)
42+
9. [throw-expressions](https://www.npmjs.com/package/@babel/plugin-proposal-throw-expressions)
43+
10. [v8intrinsic](./src/v8intrinsic.ts) - [Further Detail](https://babeljs.io/blog/2019/09/05/7.6.0#v8-intrinsic-runtime-functions-parsing-10148httpsgithubcombabelbabelpull10148)
5144

5245
## Install
5346

@@ -63,7 +56,6 @@ npm i -D babel-preset-proposal-typescript
6356

6457
| option | description | defaults |
6558
| ------------------------ | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
66-
| `classLoose` | whether to use loose mode for `class-static-block`, `class-properties` and `private-methods` | `undefined` |
6759
| `decoratorsBeforeExport` | See [Babel Document](https://babeljs.io/docs/en/babel-plugin-proposal-decorators#decoratorsbeforeexport) | `undefined` |
6860
| `decoratorsLegacy` | whether to use legacy decorators semantic | `true` |
6961
| `isTSX` | whether to enable `jsx` plugin with `typescript` | `false`, but `true` for `/\.[jt]sx$/` |
@@ -88,7 +80,7 @@ Note that unlike plugins, the presets are applied in an order of last to first (
8880
### Via CLI
8981

9082
```sh
91-
babel input.ts --presets proposal-typescript >output.ts
83+
babel input.ts --presets proposal-typescript > output.ts
9284
```
9385

9486
### Via Node API

‎babel.config.js ‎babel.config.cjs

File renamed without changes.

‎jest.config.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
import { IS_RECORD_TUPLE_SUPPORTED } from './src/utils'
1+
import compareVersions from 'compare-versions'
2+
3+
const NODE_VERSION = process.versions.node
4+
5+
const IS_RECORD_TUPLE_SUPPORTED = compareVersions.compare(
6+
NODE_VERSION,
7+
'14.6',
8+
'>=',
9+
)
210

311
export default {
12+
extensionsToTreatAsEsm: ['.ts'],
13+
moduleNameMapper: {
14+
'^(\\.{1,2}/.*)\\.js$': '$1',
15+
},
416
transform: {
517
'^.+\\.(m?j|t)s$': 'babel-jest',
618
},

‎package.json

+49-37
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
{
22
"name": "babel-preset-proposal-typescript",
33
"version": "2.2.0",
4+
"type": "module",
45
"description": "Yet another Babel preset for TypeScript, only transforms proposals which TypeScript does not support now.",
56
"repository": "git+https://github.com/rx-ts/babel-preset-proposal-typescript.git",
67
"author": "JounQin <admin@1stg.me>",
78
"license": "MIT",
9+
"packageManager": "yarn@1.22.19",
810
"engines": {
911
"node": ">=6.9.0"
1012
},
11-
"main": "lib/cjs",
12-
"module": "lib/esm",
13-
"es2015": "lib/es2015",
13+
"main": "lib/index.cjs",
14+
"module": "lib/index.js",
15+
"exports": {
16+
"types": "./lib/index.d.ts",
17+
"es2015": "./lib/index.es2015.mjs",
18+
"fesm2015": "./lib/index.es2015.mjs",
19+
"import": "./lib/index.js",
20+
"require": "./lib/index.cjs"
21+
},
22+
"es2015": "lib/index.es2015.mjs",
23+
"fesm2015": "lib/index.es2015.mjs",
1424
"types": "lib",
1525
"files": [
1626
"lib",
@@ -27,53 +37,55 @@
2737
],
2838
"scripts": {
2939
"build": "run-p build:*",
30-
"build:r": "r",
40+
"build:r": "r -f cjs,es2015",
3141
"build:ts": "tsc -p src",
3242
"lint": "run-p lint:*",
3343
"lint:es": "eslint . --cache -f friendly",
3444
"lint:tsc": "tsc -p src --noEmit",
3545
"prepare": "simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
36-
"prerelease": "npm run build",
37-
"pretest": "yarn build:r",
38-
"release": "clean-publish && changeset publish",
39-
"test": "jest"
46+
"prerelease": "yarn build",
47+
"release": "clean-pkg-json && changeset publish",
48+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest"
4049
},
4150
"peerDependencies": {
42-
"@babel/core": "^7.14.1",
43-
"typescript": "^4.3.0"
51+
"@babel/core": "^7.15.0",
52+
"typescript": "^4.7.0"
4453
},
4554
"dependencies": {
46-
"@babel/helper-plugin-utils": "^7.14.5",
47-
"@babel/plugin-proposal-async-do-expressions": "^7.14.5",
48-
"@babel/plugin-proposal-class-properties": "^7.14.5",
49-
"@babel/plugin-proposal-class-static-block": "^7.14.5",
50-
"@babel/plugin-proposal-do-expressions": "^7.14.5",
51-
"@babel/plugin-proposal-function-bind": "^7.14.5",
52-
"@babel/plugin-proposal-function-sent": "^7.14.5",
53-
"@babel/plugin-proposal-json-strings": "^7.14.5",
54-
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
55-
"@babel/plugin-proposal-partial-application": "^7.14.5",
56-
"@babel/plugin-proposal-pipeline-operator": "^7.14.5",
57-
"@babel/plugin-proposal-private-property-in-object": "^7.14.5",
58-
"@babel/plugin-proposal-record-and-tuple": "^7.14.5",
59-
"@babel/plugin-proposal-throw-expressions": "^7.14.5",
60-
"@babel/plugin-syntax-decorators": "^7.14.5",
61-
"@babel/plugin-syntax-typescript": "^7.14.5",
62-
"@bloomberg/record-tuple-polyfill": "^0.0.3",
63-
"compare-versions": "^3.6.0"
55+
"@babel/helper-plugin-utils": "^7.18.9",
56+
"@babel/plugin-proposal-async-do-expressions": "^7.18.6",
57+
"@babel/plugin-proposal-do-expressions": "^7.18.6",
58+
"@babel/plugin-proposal-function-bind": "^7.18.9",
59+
"@babel/plugin-proposal-function-sent": "^7.18.6",
60+
"@babel/plugin-proposal-json-strings": "^7.18.6",
61+
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
62+
"@babel/plugin-proposal-partial-application": "^7.18.9",
63+
"@babel/plugin-proposal-pipeline-operator": "^7.18.9",
64+
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
65+
"@babel/plugin-proposal-record-and-tuple": "^7.18.6",
66+
"@babel/plugin-proposal-throw-expressions": "^7.18.6",
67+
"@babel/plugin-syntax-decorators": "^7.18.6",
68+
"@babel/plugin-syntax-typescript": "^7.18.6",
69+
"@bloomberg/record-tuple-polyfill": "^0.0.4",
70+
"compare-versions": "^4.1.3"
6471
},
6572
"devDependencies": {
66-
"@1stg/lib-config": "^3.0.0",
67-
"@changesets/changelog-github": "^0.4.0",
68-
"@changesets/cli": "^2.16.0",
69-
"@types/babel__core": "^7.1.14",
70-
"@types/jest": "^26.0.23",
71-
"clean-publish": "^2.2.0",
72-
"ts-node": "^10.0.0",
73-
"typescript": "^4.3.3"
73+
"@1stg/lib-config": "^10.1.1",
74+
"@changesets/changelog-github": "^0.4.6",
75+
"@changesets/cli": "^2.24.3",
76+
"@node-loader/babel": "^2.0.1",
77+
"@types/babel__core": "^7.1.19",
78+
"@types/jest": "^28.1.7",
79+
"@types/node": "^18.7.8",
80+
"clean-pkg-json": "^1.0.1",
81+
"core-dts": "^0.0.3",
82+
"jest": "^28.1.3",
83+
"ts-node": "^10.9.1",
84+
"typescript": "^4.7.4",
85+
"yarn-deduplicate": "^5.0.2"
7486
},
7587
"resolutions": {
7688
"babel-preset-proposal-typescript": "link:.",
77-
"prettier": "^2.3.1"
89+
"prettier": "^2.7.1"
7890
}
7991
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/node_modules/@1stg/eslint-config/overrides.js b/node_modules/@1stg/eslint-config/overrides.js
2+
index b2a7d54..8a901fd 100644
3+
--- a/node_modules/@1stg/eslint-config/overrides.js
4+
+++ b/node_modules/@1stg/eslint-config/overrides.js
5+
@@ -88,6 +88,9 @@ const resolveSettings = {
6+
7+
const tsBase = {
8+
files: ['*.cts', '*.mts', '*.ts', '*.tsx'],
9+
+ parserOptions: {
10+
+ project,
11+
+ },
12+
extends: [
13+
'plugin:@typescript-eslint/eslint-recommended',
14+
'plugin:@typescript-eslint/recommended',
15+
@@ -160,7 +163,6 @@ const tsBase = {
16+
],
17+
'@typescript-eslint/prefer-for-of': 2,
18+
'@typescript-eslint/prefer-function-type': 2,
19+
- '@typescript-eslint/prefer-optional-chain': 2,
20+
'@typescript-eslint/prefer-ts-expect-error': 2,
21+
'@typescript-eslint/sort-type-union-intersection-members': 2,
22+
'@typescript-eslint/triple-slash-reference': [
23+
@@ -241,6 +243,7 @@ exports.ts = [
24+
'@typescript-eslint/no-unnecessary-condition': 2,
25+
'@typescript-eslint/no-unnecessary-qualifier': 2,
26+
'@typescript-eslint/no-unnecessary-type-arguments': 2,
27+
+ '@typescript-eslint/prefer-optional-chain': 2,
28+
'@typescript-eslint/prefer-readonly': 2,
29+
'@typescript-eslint/prefer-reduce-type-parameter': 2,
30+
'@typescript-eslint/prefer-string-starts-ends-with': 2,

‎src/index.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
import { ConfigAPI } from '@babel/core'
22
import { declare } from '@babel/helper-plugin-utils'
33
import proposalAsyncDoExpressions from '@babel/plugin-proposal-async-do-expressions'
4-
import proposalClassProperties from '@babel/plugin-proposal-class-properties'
5-
import proposalClassStaticBlock from '@babel/plugin-proposal-class-static-block'
64
import proposalDoExpressions from '@babel/plugin-proposal-do-expressions'
75
import proposalFunctionBind from '@babel/plugin-proposal-function-bind'
86
import proposalFunctionSent from '@babel/plugin-proposal-function-sent'
97
import proposalJsonStrings from '@babel/plugin-proposal-json-strings'
108
import proposalPartialApplication from '@babel/plugin-proposal-partial-application'
119
import proposalPipelineOperator from '@babel/plugin-proposal-pipeline-operator'
12-
import proposalPrivatePropertyInObject from '@babel/plugin-proposal-private-property-in-object'
1310
import proposalRecordAndTuple from '@babel/plugin-proposal-record-and-tuple'
1411
import proposalThrowExpression from '@babel/plugin-proposal-throw-expressions'
1512
import syntaxDecorators from '@babel/plugin-syntax-decorators'
1613
import syntaxTypeScript from '@babel/plugin-syntax-typescript'
1714

18-
import syntaxV8intrinsic from './v8intrinsic'
19-
import { IS_RECORD_TUPLE_SUPPORTED } from './utils'
15+
import { IS_RECORD_TUPLE_SUPPORTED } from './utils.js'
16+
import syntaxV8intrinsic from './v8intrinsic.js'
2017

2118
export interface ProposalTypeScriptOptions {
22-
classLoose?: boolean
2319
decoratorsBeforeExport?: boolean
2420
decoratorsLegacy?: boolean
2521
isTSX?: boolean
@@ -32,7 +28,6 @@ export default declare(
3228
(
3329
api: ConfigAPI,
3430
{
35-
classLoose,
3631
decoratorsBeforeExport,
3732
decoratorsLegacy = true,
3833
isTSX,
@@ -59,18 +54,6 @@ export default declare(
5954
],
6055
syntaxV8intrinsic,
6156
proposalAsyncDoExpressions,
62-
[
63-
proposalClassStaticBlock,
64-
{
65-
loose: classLoose,
66-
},
67-
],
68-
[
69-
proposalClassProperties,
70-
{
71-
loose: classLoose,
72-
},
73-
],
7457
proposalDoExpressions,
7558
proposalFunctionBind,
7659
proposalFunctionSent,
@@ -82,12 +65,6 @@ export default declare(
8265
proposal: pipelineOperator,
8366
},
8467
],
85-
[
86-
proposalPrivatePropertyInObject,
87-
{
88-
loose: classLoose,
89-
},
90-
],
9168
recordTuplePolyfill && [
9269
proposalRecordAndTuple,
9370
{

‎src/utils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { compare } from 'compare-versions'
1+
import compareVersions from 'compare-versions'
22

33
export const NODE_VERSION = process.versions.node
44

5-
export const IS_RECORD_TUPLE_SUPPORTED = compare(NODE_VERSION, '14.6', '>=')
5+
export const IS_RECORD_TUPLE_SUPPORTED = compareVersions.compare(
6+
NODE_VERSION,
7+
'14.6',
8+
'>=',
9+
)

‎test/__snapshots__/class-static-block.spec.ts.snap

-3
This file was deleted.

‎test/__snapshots__/function-bind.spec.ts.snap

-3
This file was deleted.

‎test/__snapshots__/private-property-in-object.spec.ts.snap

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`record-and-tuple 1`] = `"Invalid or unexpected token"`;
3+
exports[`record-and-tuple 1`] = `"Unexpected token ','"`;

‎test/async-do-expressions.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import _ from './async-do-expressions'
2-
import { execute } from './helpers'
1+
import _ from './async-do-expressions.js'
2+
import { execute } from './helpers.js'
33

44
const proposal = 'async-do-expressions'
55

66
test(proposal, async () => {
77
expect(() => execute(proposal)).toThrow(
88
'await is only valid in async function',
99
)
10-
expect(await _()).toEqual([2, 6])
10+
expect(await _).toEqual([2, 6])
1111
})

‎test/async-do-expressions.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
export default () =>
2-
Promise.all([
3-
async do {
4-
const result = await Promise.resolve(1)
5-
result * 2
6-
},
7-
async do {
8-
const result = await Promise.resolve(2)
9-
result * 3
10-
},
11-
])
1+
export default Promise.all([
2+
async do {
3+
const result = await Promise.resolve(1)
4+
result * 2
5+
},
6+
async do {
7+
const result = await Promise.resolve(2)
8+
result * 3
9+
},
10+
])

‎test/class-static-block.spec.ts

-9
This file was deleted.

‎test/class-static-block.ts

-20
This file was deleted.

‎test/do-expressions.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './do-expressions'
2-
import { execute } from './helpers'
1+
import _ from './do-expressions.js'
2+
import { execute } from './helpers.js'
33

44
const proposal = 'do-expressions'
55

‎test/function-bind.spec.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import _ from './function-bind'
2-
import { execute } from './helpers'
1+
import _ from './function-bind.js'
2+
import { execute } from './helpers.js'
33

44
const proposal = 'function-bind'
55

66
test(proposal, () => {
7-
expect(() => execute(proposal)).toThrowErrorMatchingSnapshot()
7+
// Cannot read property 'weight' of undefined
8+
// vs.
9+
// Cannot read properties of undefined (reading 'weight')
10+
expect(() => execute(proposal)).toThrowError(/^Cannot read propert(y|ies) /)
811
expect(_()).toEqual([2, 10, 15])
912
})

‎test/function-sent.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './function-sent'
2-
import { execute } from './helpers'
1+
import _ from './function-sent.js'
2+
import { execute } from './helpers.js'
33

44
const proposal = 'function-sent'
55

‎test/helpers.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
import fs from 'fs'
2-
import path from 'path'
3-
import vm from 'vm'
1+
import fs from 'node:fs'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import vm from 'node:vm'
45

56
import ts from 'typescript'
67

8+
/* istanbul ignore next */
9+
const _dirname =
10+
typeof __dirname === 'undefined'
11+
? path.dirname(fileURLToPath(import.meta.url))
12+
: __dirname
13+
714
export const resolve = (...args: string[]): string =>
8-
path.resolve(__dirname, ...args)
15+
path.resolve(_dirname, ...args)
916

1017
export const read = (file: string): string =>
11-
fs.readFileSync(resolve(file) + '.ts').toString()
18+
fs
19+
.readFileSync(resolve(file) + (/\.[cm]?[jt]s$/.test(file) ? '' : '.ts'))
20+
.toString()
1221

1322
export const execute = (file: string, ...args: number[] | string[]) =>
1423
vm.runInNewContext(ts.transpile(read(file)), { exports: {} })(...args)

‎test/json-strings.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './json-strings'
2-
import { execute } from './helpers'
1+
import { execute } from './helpers.js'
2+
import _ from './json-strings.js'
33

44
const proposal = 'json-strings'
55

‎test/partial-application.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './partial-application'
2-
import { execute } from './helpers'
1+
import { execute } from './helpers.js'
2+
import _ from './partial-application.js'
33

44
const proposal = 'partial-application'
55

‎test/pipeline-operator.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './pipeline-operator'
2-
import { execute } from './helpers'
1+
import { execute } from './helpers.js'
2+
import _ from './pipeline-operator.js'
33

44
const proposal = 'pipeline-operator'
55

‎test/private-property-in-object.spec.ts

-10
This file was deleted.

‎test/private-property-in-object.ts

-7
This file was deleted.

‎test/record-and-tuple.spec.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import { IS_RECORD_TUPLE_SUPPORTED } from '../src/utils'
1+
import { IS_RECORD_TUPLE_SUPPORTED } from '../src/utils.js'
22

3-
import { execute } from './helpers'
3+
import { execute } from './helpers.js'
44

55
const proposal = 'record-and-tuple'
66

77
test(proposal, async () => {
88
expect(() => execute(proposal)).toThrowErrorMatchingSnapshot()
99
if (IS_RECORD_TUPLE_SUPPORTED) {
10+
const module = await import('./record-and-tuple.js')
1011
// eslint-disable-next-line jest/no-conditional-expect
11-
expect((await import('./record-and-tuple')).default).toEqual([
12-
'Record & Tuple proposal',
13-
'tc39',
14-
])
12+
expect(module.default).toEqual(['Record & Tuple proposal', 'tc39'])
1513
}
1614
})

‎test/throw-expressions.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from './throw-expressions'
2-
import { execute } from './helpers'
1+
import { execute } from './helpers.js'
2+
import _ from './throw-expressions.js'
33

44
const proposal = 'throw-expressions'
55

File renamed without changes.

‎test/v8intrinsic.spec.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
import { execSync } from 'child_process'
1+
import { execSync } from 'node:child_process'
22

3-
import { execute, resolve } from './helpers'
3+
import { execute, resolve } from './helpers.js'
44

55
const proposal = 'v8intrinsic'
66

7-
test(proposal, () => {
8-
expect(() => execute(proposal)).toThrowErrorMatchingSnapshot()
9-
// eslint-disable-next-line @typescript-eslint/no-require-imports
10-
expect(() => require('./v8intrinsic')).toThrowErrorMatchingSnapshot()
7+
test(proposal, async () => {
8+
expect(() => execute(proposal + '.cjs')).toThrowErrorMatchingSnapshot()
9+
await expect(
10+
// @ts-expect-error
11+
import('./v8intrinsic.cjs'),
12+
).rejects.toThrowErrorMatchingSnapshot()
1113
expect(
12-
execSync(`node --allow-natives-syntax ${resolve(proposal)}.ts`).toString(),
14+
execSync(
15+
`node --allow-natives-syntax ${resolve(
16+
proposal,
17+
// TODO: make `.ts` working again
18+
)}.cjs`,
19+
).toString(),
1320
).toBe('1')
1421
})

‎tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "@1stg/tsconfig/node"
2+
"extends": "@1stg/tsconfig/node16",
3+
"compilerOptions": {
4+
"types": ["core-dts/src/proposals/stage-0", "jest", "node"]
5+
}
36
}

‎yarn.lock

+7,453-5,620
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.