Question babel-plugin-flow-runtime: overwrite assert: false
See original GitHub issueAccording to the documentation assert: true should be turned off during production builds.
For an UMD library with an public API it would be beneficial if assertions could be scoped to specific public methods. That would allow getting the the benefits of run time type checking for the library consumer without getting the overall performance penalty.
Here’s an example, where I’d like to get assertions for the public filter
method (taken from a tcomb babel-plugin-transform-flow-strip-types implementation).
...
const FilterLogic = enums.of(['or', 'and'], 'FilterLogic')
type FilterExpression = {
field: string,
operator: string,
value: any
}
type FilterGroup = {
logic: FilterLogic,
filters: Array<FilterExpression | FilterGroup>
}
export default class Collections {
...
// Would it be possible to turn on assertion for .filter?
// maybe by using a decorator like @guarded?
filter (options?: FilterGroup) {
if (!options) {
return toJS(this.$filter)
}
this.$filter = options
this.data = []
return this.read()
}
...
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Better alternatives to assert(false) in C/C++ - Stack Overflow
My compiler recognizes that the program finishes once assert(false) has been reached. However, whenever I compile with -DNDEBUG for ...
Read more >Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >Programming With Assertions - Oracle Help Center
An assertion is a statement in the Java programming language that enables ... Another problem with using assertions for argument checking is that...
Read more >console.assert() - Web APIs | MDN
The console.assert() method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.
Read more >Throw error if condition false - MATLAB assert - MathWorks
Error using assert Assertion failed. The expression evaluates as false. The assertion fails and MATLAB throws an error.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Added pragma like
// @flow-runtime assert, decorate
and suppression types / comments in v0.0.7, docs here - https://codemix.github.io/flow-runtime/#/docs/pragmasThis looks excellent. Thanks for adding.