riot / cli

Riot.js command line tool
MIT License
46 stars 9 forks source link

riot cli in webstorm not compiling typescript with let or const #26

Closed TimWillis closed 7 years ago

TimWillis commented 7 years ago

I am using riot cli in webstorm(don't think that matters), and I have a riot tag like this -> `

test

` riot doesn't show any compile errors, but returns a js file with the word 'undefined' in it. if I change it to var it works. Other things like arrow functions and other things for typescript work fine as long as no let or const.

GianlucaGuarini commented 7 years ago

have you properly configured typescript http://riotjs.com/guide/compiler/#typescript?

TimWillis commented 7 years ago

As far as I can tell. It is compiling fine for other es6/typescript features except for when I put let or const.

On Mon, Apr 17, 2017 at 4:18 PM, Gianluca Guarini notifications@github.com wrote:

have you properly configured typescript http://riotjs.com/guide/ compiler/#typescript?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/riot/cli/issues/26#issuecomment-294579551, or mute the thread https://github.com/notifications/unsubscribe-auth/AIEUTSVmHXz0pcpj4HDdePLqzF3orGukks5rw8kRgaJpZM4M_f7N .

GianlucaGuarini commented 7 years ago

have you tried compiling via terminal? Could you please post your code?

TimWillis commented 7 years ago

I had tried the terminal before and it gave me the undefined. I swear I had it down to just something like "let x = () => { let y = 1; }" and it was returning undefined in the js file, and when I changed let to var, it worked. But now it is all working, not sure if it was some weird cache issue or what... But it would be nice if it returned an error instead of undefined in the js file to help debug. It looks like what I put as a bug isn't one, it was a bug in my code, I just wasn't getting any compile errors except the undefined in the js file. Sorry for the false bug.

On Mon, Apr 17, 2017 at 4:40 PM, Gianluca Guarini notifications@github.com wrote:

have you tried compiling via terminal? Could you please post your code?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/riot/cli/issues/26#issuecomment-294586378, or mute the thread https://github.com/notifications/unsubscribe-auth/AIEUTSo6vnTXfuFi8HDI6kV61TBs9FQRks5rw85PgaJpZM4M_f7N .

GianlucaGuarini commented 7 years ago

If the compiler does not fail and the error is in your runtime script this is not a bug. The compiler scope is to output vaild javascript without compromising your program logic. In your case the issue was in your code. Good luck

TimWillis commented 7 years ago

OK, I found the issue, I thought I had a bug in my code, but it was something different. The following compiles fine in a ts file: let workbook: any = XLSX.read({}, {type: 'binary'}); But when I put it in a tag file like the following, and either using the webstorm file watcher or the cli it returns the word undefined in the generated js file. Why would it compile in a ts file, but not in the tag file?

`

<script type="typescript">
    let workbook: any = XLSX.read({}, {type: 'binary'});
</script>

`

GianlucaGuarini commented 7 years ago

it should be fixed in riot-cli@3.0.1 thanks for reporting the issue

TimWillis commented 7 years ago

Awesome, thank you!