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

Uncaught TypeError if Json.Decode is not imported (module loading order problem?) #686

Closed
RobertWalter83 opened this Issue Aug 9, 2016 · 4 comments

Comments

Projects
None yet
5 participants
@RobertWalter83

RobertWalter83 commented Aug 9, 2016

I experience an issue which might be related to #683.

I created a SSCCE to illustrate the problem.

Im working on Windows 10. I use Elm 0.17.1, core 4.0.3.

Description:
I have a port module where I have defined all my app's ports. If this module does not import "Json.Decode", I get an Uncaught TypeError exception:
ex

I am aware of this discussion. I do not use elm-webpack-loader.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Aug 9, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Aug 9, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@RobertWalter83 RobertWalter83 changed the title from Module loading order problem? to Uncaught TypeError if Json.Decode is not imported (module loading order problem?) Aug 9, 2016

@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby Aug 10, 2016

Member

It appears that the presence of a port module alone doesn't inform the compiler of the need to import Json.Decode. Here's a succinct SSCCE for which you can examine the generated code and note the absence of Json.Decode

port module Main exposing (..)

port example : (String -> msg) -> Sub msg

value =
    1
Member

lukewestby commented Aug 10, 2016

It appears that the presence of a port module alone doesn't inform the compiler of the need to import Json.Decode. Here's a succinct SSCCE for which you can examine the generated code and note the absence of Json.Decode

port module Main exposing (..)

port example : (String -> msg) -> Sub msg

value =
    1
@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Aug 29, 2016

Member

@lukewestby, feel free to close issues and open nicer ones if you figure things out like this! I did this with #703.

Member

evancz commented Aug 29, 2016

@lukewestby, feel free to close issues and open nicer ones if you figure things out like this! I did this with #703.

@evancz evancz closed this Aug 29, 2016

@lzrski

This comment has been minimized.

Show comment
Hide comment
@lzrski

lzrski Nov 29, 2017

Also running into this issue with React Native talking to Elm program via ports. The error is

Can't find variable _elm_lang$core$Json_Decode$string

Adding import Json.Decode solves the problem. See relevant code here.

lzrski commented Nov 29, 2017

Also running into this issue with React Native talking to Elm program via ports. The error is

Can't find variable _elm_lang$core$Json_Decode$string

Adding import Json.Decode solves the problem. See relevant code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment