In the App.tsx taken from the fountain-webapp typescript MVC sample (http://fountainjs.io/), the import contains the following line:
import {IDispatch} from '~react-redux~redux';
Visual Studio 2017 underlines this line ("cannot find module") however it does work in the browser. I've never seen this syntax before and don't know what it's attempting to do?
There's an open ticket mentioning it here: https://github.com/FountainJS/generator-fountain-react/issues/70
The (~) tilde operator takes any number and inverts the binary digits, for example, if the number is (100111) after inversion it would be (011000).
Introduction to the JavaScript import() The import() allows you to dynamically import a module when needed. Here is how the import() works: The import() accepts a module specifier ( moduleSpecifier ) that has the same format as the module specifier used for the import statement.
The “double tilde” (~~) operator is a double NOT Bitwise operator. Use it as a substitute for Math. floor(), since it's faster.
Tilde (~
) used in conjunction with webpack means that a lookup is performed against node_modules
to resolve the path.
In other words, it is a predefined alias that resolves to node_modules
.
import { IDispatch } from '~react-redux~redux';
is equivalent to
import { IDispatch } from 'relative_path_to_node_modules/react-redux~redux';
EDIT: Unfortunately, I can't cite any documentation about this, it is based on experience, you're welcome to edit this post with a more accurate description.
Now I've noticed the ~redux
part as well, so you might want to check out the other answer, because I'm puzzled there as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With