Migrating

Follow only the instructions for your current version of tc:

VersionChanges for all usersChanges for TypeScript only
3.x🚨 Breaking❓ Possibly breaking
2.x🆗 No impacts⚠️ Breaking
1.x🆗 No impacts⚠️ Breaking

Migrating from 3.x

Usage

  • Breaking: tc and tcs have been merged back into one function, with tc automatically handling Promises as with versions prior to 3.x.
    • To fix: Replace all instance of tcs with tc.
  • Breaking: tc is only provided as a default export, no longer a const export.
    • To fix: Replace import { tc } from '@replygirl/tc' with import tc from '@replygirl/tc'

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 T and U to restrict the return values of your callbacks.
  • Breaking: TcCallback, TcErrorHandler, TcResult, TcReturn, and MaybePromise are no longer exported.
    • To fix:
      • Replace TcCallback<T> with Parameters<typeof tc<T>>[0]
      • Replace TcErrorHandler<T> with Parameters<typeof tc<T>>[1]
      • Replace TcResult<T> with AsyncReturnType<typeof tc<T>> (requires type-fest)
      • Replace TcReturn<T> with ReturnType<typeof tc<T>>
      • Replace MaybePromise<T> with Promise<T> | T

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 T and U to restrict the return values of your callbacks.
  • Breaking: The IsAsync type parameter has been replaced. The second type parameter is now U, the return type of your catch callback, if you supplied one.
    • To fix: Remove the second type parameter from every call to tc.
  • Breaking: TcCallback, TcErrorHandler, TcResult, TcReturn, and MaybePromise are no longer exported.
    • To fix:
      • Replace TcCallback<T> with Parameters<typeof tc<T>>[0]
      • Replace TcErrorHandler<T> with Parameters<typeof tc<T>>[1]
      • Replace TcResult<T> with AsyncReturnType<typeof tc<T>> (requires type-fest)
      • Replace TcReturn<T> with ReturnType<typeof tc<T>>
      • Replace MaybePromise<T> with Promise<T> | T