riot / cli

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

Typescript failing due to not using d.ts files. #27

Closed TimWillis closed 5 years ago

TimWillis commented 7 years ago

I have some d.ts files, and I use them for my ts files. When I use a global variable like '_' in lodash in my tag files like so: `

test

` It fails because it doesn't know what lodash is with error: "Cannot find name ". I don't know how to get it to recognize my d.ts files. If I use declare var ; it compiles fine. But I don't want to have to create the d.ts files inside my tag files. Also, compiling from a regular ts file works fine.

Not sure if this is a bug or a feature request, or if I don't know how to properly add in the d.ts files, but couldn't find anything in the docs or SO.

I looked into typescript simple and noticed the heading "Ignore semantic errors" - Thought it may lead to the solution.

GianlucaGuarini commented 7 years ago

@TimWillis I don't use typescript and I don't know how to help you on that. What I would you recommend is to use technology that you can easier debug and understand: typescript needs to parse and understand your code and relying on globals makes not really sense if you want to keep using it

TimWillis commented 7 years ago

@GianlucaGuarini I understand and thank you for the response. But definition files are a huge part of typescript(https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types repository for types), and while I try to avoid globals as much as possible there is a need for a few such as lodash. Typescript adds a lot of value namely in intellisense and catching bugs due to type issues. The type definition for lodash is 530 kb, so including it in the tag itself is not feasible. I am not sure why the riot compiler is hanging, and the normal typescript compiler compiles just fine. I will take a look at the riot compiler and see if I can figure it out. If I can I will go ahead and fix it and do a pull request.

GianlucaGuarini commented 5 years ago

I have provided with Riot.js@4 a typescript example https://github.com/riot/examples/tree/gh-pages/typescript. I am sorry for the delay but now the issue should be solved. Thank you for your feedback