-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime validation API in "development mode" #2153
Comments
Moving these comments to this thread:
|
It would be neat (and probably insanely slow) if TypeScript had an option to compile its static type-checks to runtime code for debug builds. |
It's a good idea for this use case, but based on my conversations with the team that'll probably never happen :-( |
@trxcllnt its hypothetically possible i would think with the upcoming transforms functionality for TS - see microsoft/TypeScript#6508 for tracking on that RxJS is designed to be modular (cuz its got loads of operators), so there isn't a single place we could swap this out - most (angular) consumers are doing something like: import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/mergeMap' rather than using a single bundle, you can get the bits and pieces you want. I'm 👍 on improving approachability / debuggability, just not at the expense of performance or needing special handling for prod. As we already monkey patch the world, perhaps you could optionally import a file like cc @alexeagle |
@robwormald just to clarify, the initial proposal was using So it's no different whether they use operator patching or not. We would also distribute builds that do not include these checks, for UMD usage. We could also try to detect prod usage of dev builds and log a warning, again like React does. (i have no idea how, but I imagine I could quickly find) |
I've changed topic bit to use as umbrella issue for runtime validation issues. |
@kentcdodds IMO this is a good idea still. Any objection to keeping it open? It’s been almost a year, which is prolly why you closed it, but it’s still valid and something I think should be considered when other more critical things are completed |
Agreed it's still important. I was just wasting my time closing my old issues that I no longer care enough to put more work into 😅 |
@kentcdodds Right on. Definitely feel free to unsubscribe 👍 |
In general, more run time type checking could/should be done. However we'd probably need something more bespoke and compact, if we were going to use a more unified approach. I'm going to close this for now, as it seems that the library is mostly in a good place for this. But will monitor for other issues. |
Inspired by conversations in this PR: #2152
Would be cool to do full runtime validation like React does (it uses
invariant
).PropTypes
is one of the most valuable things available from React. As cool as static type checking is, runtime checking will always be more powerful (and works for anyone regardless of whether they're using a type checker or not).I created
api-check
to do this for one of my libraries and it really reduced the number of beginner issues I received. Everyone was happier.Definitely would want to have the ability to exclude this runtime checking in the production code.
The text was updated successfully, but these errors were encountered: