Migrating
Follow only the instructions for your current version of tc:
| Version | Changes for all users | Changes for TypeScript only |
|---|---|---|
| 3.x | 🚨 Breaking | ❓ Possibly breaking |
| 2.x | 🆗 No impacts | ⚠️ Breaking |
| 1.x | 🆗 No impacts | ⚠️ Breaking |
Migrating from 3.x
Usage
- Breaking:
tcandtcshave been merged back into one function, withtcautomatically handlingPromises as with versions prior to 3.x.- To fix: Replace all instance of
tcswithtc.
- To fix: Replace all instance of
- Breaking:
tcis only provided as a default export, no longer a const export.- To fix: Replace
import { tc } from '@replygirl/tc'withimport tc from '@replygirl/tc'
- To fix: Replace
TypeScript
- Possibly breaking:
tc's return types are more precise to match runtime behavior. TypeScript may require you to handle some previously unhandled possibilities.
Migrating from 2.x
TypeScript
- Type parameters are properly inferred.
tc's return type should be determined based on the callbacks you supply.- You can pass
TandUto restrict the return values of your callbacks.
- Breaking:
TcCallback,TcErrorHandler,TcResult,TcReturn, andMaybePromiseare no longer exported.- To fix:
- Replace
TcCallback<T>withParameters<typeof tc<T>>[0] - Replace
TcErrorHandler<T>withParameters<typeof tc<T>>[1] - Replace
TcResult<T>withAsyncReturnType<typeof tc<T>>(requirestype-fest) - Replace
TcReturn<T>withReturnType<typeof tc<T>> - Replace
MaybePromise<T>withPromise<T> | T
- Replace
- To fix:
Migrating from 1.x
TypeScript
- Type parameters are properly inferred.
tc's return type should be determined based on the callbacks you supply.- You can pass
TandUto restrict the return values of your callbacks.
- Breaking: The
IsAsynctype parameter has been replaced. The second type parameter is nowU, the return type of yourcatchcallback, if you supplied one.- To fix: Remove the second type parameter from every call to
tc.
- To fix: Remove the second type parameter from every call to
- Breaking:
TcCallback,TcErrorHandler,TcResult,TcReturn, andMaybePromiseare no longer exported.- To fix:
- Replace
TcCallback<T>withParameters<typeof tc<T>>[0] - Replace
TcErrorHandler<T>withParameters<typeof tc<T>>[1] - Replace
TcResult<T>withAsyncReturnType<typeof tc<T>>(requirestype-fest) - Replace
TcReturn<T>withReturnType<typeof tc<T>> - Replace
MaybePromise<T>withPromise<T> | T
- Replace
- To fix: