ArpNetworking / sbt-typescript

A plugin for SBT that uses sbt-web to compile typescript resources.
Apache License 2.0
60 stars 26 forks source link

DeserializationException: Expected String as JsString, but got... #10

Closed blast-hardcheese closed 9 years ago

blast-hardcheese commented 9 years ago

I know 1.5.0 is still alpha, but hopefully this is helpful test data:

moment.locale('en', {
    longDateFormat : {
        LL: "MMMM Do YYYY",
    }
});

gives me

DeserializationException: Expected String as JsString, but got
    {
        "category": 1, 
        "next": {
            "category": 1, 
            "next": {
                "category": 1, 
                "next": {
                    "category": 1, 
                    "messageText": "Property 'L' is missing in type '{ LL: string; }'.", 
                    "code": 2324
                }, 
                "messageText": "Type '{ LL: string; }' is not assignable to type 'MomentLongDateFormat'.", 
                "code": 2322
            }, 
            "messageText": "Types of property 'longDateFormat' are incompatible.", 
            "code": 2326
        }, 
        "messageText": "Argument of type '{ longDateFormat: { LL: string; }; }' is not assignable to parameter of type 'MomentLanguage'.", 
        "code": 2345
    }

        at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:237) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:230) ~[na:na]
        at scala.Option.map(Option.scala:145) ~[scala-library-2.11.4.jar:na]
        at play.PlayReloader$$anon$1.play$PlayReloader$$anon$$taskFailureHandler(PlayReloader.scala:230) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2.apply(PlayReloader.scala:90) ~[na:na]
        at play.PlayReloader$$anon$1$$anonfun$reload$2.apply(PlayReloader.scala:90) ~[na:na]
        at scala.util.Either$LeftProjection.map(Either.scala:377) ~[scala-library-2.11.4.jar:na]
        at play.PlayReloader$$anon$1.reload(PlayReloader.scala:90) ~[na:na]
        at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:122) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:120) ~[play_2.11-2.3.7.jar:2.3.7]
Caused by: spray.json.DeserializationException: Expected String as JsString, but got {"messageText":"Argument of type '{ longDateFormat: { LL: string; }; }' is not assignable to parameter of type 'MomentLanguage'.","category":1,"code":2345,"next":{"messageText":"Ty
pes of property 'longDateFormat' are incompatible.","category":1,"code":2326,"next":{"messageText":"Type '{ LL: string; }' is not assignable to type 'MomentLongDateFormat'.","category":1,"code":2322,"next":{"messageText":"Property 'L' is missing in type '{ LL: stri
ng; }'.","category":1,"code":2324}}}}
        at spray.json.package$.deserializationError(package.scala:23) ~[na:na]
        at spray.json.BasicFormats$StringJsonFormat$.read(BasicFormats.scala:126) ~[na:na]
        at spray.json.BasicFormats$StringJsonFormat$.read(BasicFormats.scala:119) ~[na:na]
        at spray.json.JsValue.convertTo(JsValue.scala:32) ~[na:na]
        at com.typesafe.sbt.jse.SbtJsTask$JsTaskProtocol$LineBasedProblemFormat$$anonfun$read$4.apply(SbtJsTask.scala:110) ~[na:na]
        at com.typesafe.sbt.jse.SbtJsTask$JsTaskProtocol$LineBasedProblemFormat$$anonfun$read$4.apply(SbtJsTask.scala:110) ~[na:na]
        at scala.Option.fold(Option.scala:157) ~[scala-library-2.11.4.jar:na]
        at com.typesafe.sbt.jse.SbtJsTask$JsTaskProtocol$LineBasedProblemFormat$.read(SbtJsTask.scala:110) ~[na:na]
        at com.typesafe.sbt.jse.SbtJsTask$JsTaskProtocol$LineBasedProblemFormat$.read(SbtJsTask.scala:105) ~[na:na]
        at spray.json.JsValue.convertTo(JsValue.scala:32) ~[na:na]
legacycode commented 9 years ago

What happens, if you remove the comma at the end of the line "YYYY" as follows:

moment.locale('en', {
    longDateFormat : {
        LL: "MMMM Do YYYY"
    }
});
blast-hardcheese commented 9 years ago

Same error, actually. The error, as I read it, is that I'm missing the rest of the desired definitions for that option, in particular "L"

The main reason for the concern is that sbt-typescript doesn't even give line numbers for what's going on, so it was lucky that this code was close to the beginning of the file.

fernandezpablo85 commented 9 years ago

This is a known issue, related to #8

My workaround is to run tsc from the command line manually for this cases to get a better error description.

fernandezpablo85 commented 9 years ago

handy command:

 tsc  --out killme app/assets/javascripts/*/**.ts && rm killme

from your project root.

blast-hardcheese commented 9 years ago

Ah, no big deal. Thank you for your work!

fernandezpablo85 commented 9 years ago

I'm not the author just a (really) humble contributor :smile: , I'll try to get at least a failing test this weekend so @BrandonArp (the author) hopefully can work it out.