Skip to content

Commit bf2cb79

Browse files
committed
feat: run typescript files
1 parent 0b3c1c5 commit bf2cb79

File tree

3 files changed

+126
-132
lines changed

3 files changed

+126
-132
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ Build package with `tsup` for production.
5656
yarn build
5757
```
5858

59+
### ▶️ Running files written in TypeScript
60+
61+
To run a `.ts` file through Node.js you can simply the `ts` shorthand script in `package.json`.
62+
63+
```console
64+
yarn ts ./path/to/file.ts
65+
```
66+
67+
This is useful for running scripts, starting a server, or any other code you want to run while remaining type-safe.
68+
5969
### 🖇️ Linking
6070

6171
Often times you want to `link` this package to another project when developing locally, circumventing the need to publish to NPM to consume it.

package.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"storybook": "storybook dev -p 6006",
2323
"build-storybook": "storybook build",
2424
"release": "yarn build && yarn release-it",
25-
"link:self": "yarn yalc publish && yarn link"
25+
"link:self": "yarn yalc publish && yarn link",
26+
"ts": "node node_modules/.bin/ts-node -r tsconfig-paths/register -O '{\"module\": \"commonjs\", \"moduleResolution\": \"classic\", \"resolveJsonModule\": false }' --transpile-only --project ./tsconfig.json"
2627
},
2728
"types": "./dist/index.d.ts",
2829
"exports": {
@@ -75,16 +76,16 @@
7576
"@storybook/react": "7.6.7",
7677
"@storybook/react-webpack5": "7.6.7",
7778
"@storybook/testing-library": "0.2.2",
78-
"@testing-library/jest-dom": "^6.0.0",
79-
"@testing-library/react": "^14.0.0",
79+
"@testing-library/jest-dom": "6.0.0",
80+
"@testing-library/react": "14.0.0",
8081
"@types/node": "20.10.6",
8182
"@types/react": "18.2.46",
8283
"@types/react-dom": "18.2.18",
8384
"@types/react-test-renderer": "18.0.7",
8485
"@typescript-eslint/eslint-plugin": "6.17.0",
8586
"@typescript-eslint/parser": "6.17.0",
86-
"@vitejs/plugin-react": "^4.0.3",
87-
"@vitest/coverage-v8": "^1.0.0",
87+
"@vitejs/plugin-react": "4.0.3",
88+
"@vitest/coverage-v8": "1.0.0",
8889
"babel-loader": "9.1.3",
8990
"concurrently": "8.2.2",
9091
"eslint": "8.56.0",
@@ -96,12 +97,12 @@
9697
"eslint-plugin-prettier": "5.1.2",
9798
"eslint-plugin-react": "7.33.2",
9899
"eslint-plugin-react-hooks": "4.6.0",
99-
"eslint-plugin-sort-class-members": "^1.18.0",
100+
"eslint-plugin-sort-class-members": "1.18.0",
100101
"eslint-plugin-storybook": "0.6.15",
101102
"eslint-plugin-typescript-sort-keys": "3.1.0",
102103
"eslint-plugin-unused-imports": "3.0.0",
103104
"husky": "8.0.3",
104-
"jsdom": "^23.0.0",
105+
"jsdom": "23.0.0",
105106
"lint-staged": "15.2.0",
106107
"prettier": "3.1.1",
107108
"prop-types": "15.8.1",
@@ -110,9 +111,11 @@
110111
"react-test-renderer": "18.2.0",
111112
"release-it": "17.0.1",
112113
"storybook": "7.6.7",
114+
"ts-node": "10.9.2",
115+
"tsconfig-paths": "4.2.0",
113116
"tsup": "8.0.1",
114117
"typescript": "5.3.3",
115-
"vitest": "^1.0.0",
118+
"vitest": "1.0.0",
116119
"yalc": "1.0.0-pre.53"
117120
},
118121
"peerDependencies": {

0 commit comments

Comments
 (0)