Releases: alexreardon/tiny-invariant
Releases · alexreardon/tiny-invariant
1.3.3
1.3.2
- added jsdoc to function signature for improved IDE usage #177 (thanks @DarkPurple141 for originally raising and pushing for this)
- upgraded all dev dependencies to latest #178
1.3.1
1.3.0
Improved support for Node.js + ESM
Thanks to a heroic effort by @pkerschbaum tiny-invariant now supports EcmaScript Modules (ESM) usage in Node.js #145. Thanks so much @pkerschbaum 👏
This resulted in a
minorrelease as it a backwards compatible change that adds new functionality
Other
1.2.0
New: Get message function
The message provided to invariant can now be a function that returns a string
- export default function invariant(condition: any, message?: string): asserts condition;
+ export default function invariant(condition: any, message?: string | (() => string)): asserts condition;Using a function that returns a string is helpful in cases where your message is expensive to create. By using a function you only need to create the message when you need it.
import invariant from 'tiny-invariant';
invariant(value, () => getExpensiveMessage());Keep in mind, that ideally the second argument to invariant is stripped away entirely in production builds.
We have a guide on how to do remove messages for production builds
1.1.0
- Now
TypeScriptnative! (flowusage still supported ❤️) - Leverages the new
[email protected]assertskeyword to correctly narrow types (caused a feature release)
const user: Person | null = getPerson();
invariant(user, 'expected user to be populated');
// the type of `user` is now narrowed to 'Person' rather than `Person | null`1.0.6
1.0.5
- Upgrading to
[email protected]#40 - Upgrading all dev dependencies #41
1.0.4
1.0.3
- moving to
flow0.85 - bumping dev deps