You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-10Lines changed: 43 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,14 +163,16 @@ _(See more advanced `tryCatch` usage examples and API reference further down.)_
163
163
## Installation
164
164
165
165
```bash
166
+
# 1. Install the utility (prod dependency):
167
+
npm i @maxmorozoff/try-catch-tuple
168
+
169
+
# 2. Install ts plugin (dev dependencies):
170
+
166
171
# If using the build transformer, ts-patch is also required
167
-
npm i -D @maxmorozoff/try-catch-tuple @maxmorozoff/try-catch-tuple-ts-plugin ts-patch typescript
172
+
npm i -D @maxmorozoff/try-catch-tuple-ts-plugin ts-patch typescript
168
173
169
174
# Or for utility + LSP only:
170
-
npm i -D @maxmorozoff/try-catch-tuple @maxmorozoff/try-catch-tuple-ts-plugin typescript
171
-
172
-
# Or for utility only:
173
-
npm i -D @maxmorozoff/try-catch-tuple typescript
175
+
npm i -D @maxmorozoff/try-catch-tuple-ts-plugin typescript
174
176
```
175
177
176
178
## Configuration (`tsconfig.json`)
@@ -222,16 +224,47 @@ Configure the tooling under `compilerOptions.plugins`.
222
224
223
225
## Usage
224
226
225
-
**1. IDE (Language Service Plugin):**
227
+
### 1. IDE (Language Service Plugin)
226
228
229
+
-**Select Workspace TypeScript Version:** Ensure your editor is using the workspace's TypeScript version instead of the built-in one (e.g., VS Code: `TypeScript: Select TypeScript Version`).
227
230
-**Restart TS Server:** After configuring the plugin, **restart the TypeScript Server** (e.g., VS Code: `TypeScript: Restart TS server`).
228
231
- Errors will be underlined, and Quick Fixes will be available.
229
232
230
-
**2. Build (Transformer):**
233
+
### 2. Build (Transformer)
234
+
235
+
#### Method 1: Live Compiler
236
+
237
+
The live compiler patches on-the-fly, each time it is run.
238
+
239
+
**Via commandline:** Simply use `tspc` (instead of `tsc`)
240
+
241
+
**With tools such as ts-node, webpack, ts-jest, etc:** specify the compiler as `ts-patch/compiler`
242
+
243
+
#### Method 2: Persistent Patch
244
+
245
+
Persistent patch modifies the typescript installation within the `node_modules` path. It requires additional configuration
246
+
to remain persisted, but it carries less load time and complexity compared to the live compiler.
247
+
248
+
1. Install the patch
249
+
250
+
```shell
251
+
# For advanced options, see: ts-patch /?
252
+
ts-patch install
253
+
```
254
+
255
+
2. Add `prepare` script (keeps patch persisted after npm install)
256
+
257
+
`package.json`
258
+
```jsonc
259
+
{
260
+
/* ... */
261
+
"scripts": {
262
+
"prepare":"ts-patch install -s"
263
+
}
264
+
}
265
+
```
231
266
232
-
-**Install `ts-patch`:**`npm i -D ts-patch` (if needed).
Copy file name to clipboardExpand all lines: packages/ts-plugin/README.md
+36-17Lines changed: 36 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,13 @@ The primary goal is to prevent developers from incorrectly handling the results
26
26
27
27
## Installation
28
28
29
+
Add the following packages to your _development_ dependencies:
30
+
29
31
```bash
30
32
# If using the build transformer, ts-patch is also required
31
33
npm i -D @maxmorozoff/try-catch-tuple-ts-plugin ts-patch typescript
32
34
# Or for LSP only:
33
-
#npm i -D @maxmorozoff/try-catch-tuple-ts-plugin typescript
35
+
npm i -D @maxmorozoff/try-catch-tuple-ts-plugin typescript
34
36
```
35
37
36
38
## Configuration (`tsconfig.json`)
@@ -104,32 +106,49 @@ This is the preferred way if using both, as configuration is shared.
104
106
}
105
107
```
106
108
107
-
108
109
## Usage
109
110
110
-
**1. IDE (Language Service Plugin):**
111
+
### 1. IDE (Language Service Plugin)
112
+
113
+
-**Select Workspace TypeScript Version:** Ensure your editor is using the workspace's TypeScript version instead of the built-in one (e.g., VS Code: `TypeScript: Select TypeScript Version`).
114
+
-**Restart TS Server:** After configuring the plugin, **restart the TypeScript Server** (e.g., VS Code: `TypeScript: Restart TS server`).
115
+
- Errors will be underlined, and Quick Fixes will be available.
116
+
117
+
### 2. Build (Transformer)
118
+
119
+
#### Method 1: Live Compiler
120
+
121
+
The live compiler patches on-the-fly, each time it is run.
122
+
123
+
**Via commandline:** Simply use `tspc` (instead of `tsc`)
111
124
112
-
-**Restart TS Server:** After adding/changing the plugin configuration in `tsconfig.json`, you **must restart the TypeScript Server** in your editor.
113
-
-_VS Code:_ Open the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`) and run `TypeScript: Restart TS server`.
114
-
- You should now see errors/warnings underlined in your code and have Quick Fixes available.
125
+
**With tools such as ts-node, webpack, ts-jest, etc:** specify the compiler as `ts-patch/compiler`
115
126
116
-
**2. Build (Transformer):**
127
+
#### Method 2: Persistent Patch
117
128
118
-
-**Install `ts-patch`:** (If not already done) `npm i -D ts-patch`
119
-
-**Patch TypeScript:** Run `npx ts-patch install` (or `yarn ts-patch install`) in your project root. This only needs to be done once or after updating TypeScript/ts-patch.
120
-
-**Run Build:** Use `tspc` instead of `tsc` in your build scripts/commands.
129
+
Persistent patch modifies the typescript installation within the `node_modules` path. It requires additional configuration
130
+
to remain persisted, but it carries less load time and complexity compared to the live compiler.
121
131
122
-
```bash
123
-
# Example command
124
-
npx tspc -p tsconfig.json
132
+
1. Install the patch
125
133
126
-
# Example package.json script
134
+
```shell
135
+
# For advanced options, see: ts-patch /?
136
+
ts-patch install
137
+
```
138
+
139
+
2. Add `prepare` script (keeps patch persisted after npm install)
140
+
141
+
`package.json`
142
+
```jsonc
143
+
{
144
+
/* ... */
127
145
"scripts": {
128
-
"build": "tspc -p tsconfig.json"
146
+
"prepare":"ts-patch install -s"
129
147
}
130
-
```
148
+
}
149
+
```
131
150
132
-
Build errors/warnings from the transformer will appear in the `tsc` output.
151
+
For advanced options, see: [ts-patch docs](https://github.com/nonara/ts-patch?tab=readme-ov-file#usage)
0 commit comments