typed-unmaintained
typed-unmaintained copied to clipboard
Import errors in node
TypeError: prelude_1.prop is not a function
I tried using Maybe's for the first time in my life, and wanted to do a simple console.log
. I got a similar result with ap
via @typed/prelude
:
https://github.com/marcusnielsen/mostjs-labs/blob/master/src/index.ts#L11
const log = (maybe) => prelude_1.ap(prelude_1.toMaybe(console.log), maybe);
TypeError: prelude_1.ap is not a function
I was guessing it's my fault since I've never used ap
, Maybe
, or this framework before. But seeming this issue, maybe it's the same bug? Any advice for moving forward?
Hey @marcusnielsen there seems to be some sort of issue with the way TypeScript compiles ES2015 modules to commonjs. If you're interested in Maybe
in particular, I'd suggest using @typed/maybe
directly until we can figure out this issue here.
EDIT: Heres a webpackbin doing what is in your error message. https://www.webpackbin.com/bins/-KxPOhHcGP9jecQJZ6Ot
Additionally if you're using something like webpack to bundle your application, you can add module
or jsnext:main
to resolve.mainFields
to use the ES2015 build instead and avoid this bug.
Using @typed/maybe
worked out well! (I'm using tsc without webpack.)
Thanks for the help, I just did my first Maybe
and ap
, and it feels awesome 🎉
I'm thinking that going forward we could just have yarn add @typed/prelude
be a convenient shortcut for yarn add @typed/either @typed/functions @typed/lenses @typed/list @typed/logic @typed/math @typed/maybe @typed/objects @typed/strings
but not re-export these packages from itself, but instead requiring explicit imports from the other @typed/*
packages.
What do you think?
I am much in favor of explicit imports. A convenient shortcut using @typed/prelude
is preferable to re-exports.