Trying to generate React bindings in non-tsx files? #213
Comments
@zeh hi!
You should not be seeing that. This one Also, there might be an issue with the latest Thanks |
Hey @nchanged, thanks for the response. Same error on TS 2.1.6 + cleared cache. I managed to get past that error by removing all |
@zeh good one. Thanks. |
@nchanged It definitely compiles. Castings might be uncommon but it's legal TypeScript and I currently use it within my webpack/tsc build with no problem. "blaming" might be a strong word as I'm not sure I'm doing something wrong instead, but it's definitely tripping fusebox. |
Can I kindly ask you to take a look at this piece Do you think it might be somewhat different from the CLI interface? And if you have an idea how to fix it, please share ;-) |
@zeh as a fellow user of fusebox, if you can share an example project I will hack hard at it till I get it to work for you 🌹 |
When transpiling files as modules, the filename is passed to TypeScript so it can interpret it properly. This is necessary to respect the behavior of the command line, especially when deciding whether files should be interpreted as jsx/tsx files, as per [the transpiler reference](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#transpiling-a-single-file). See fuse-box#213.
@nchanged Thanks so much for the link. I see now what the issue is. Because fuse-box is calling As per the API documentation:
The I've submitted a small PR that attempts to do so, so fuse-box will follow tsc's behavior more closely. I've tested it locally and it compiles my offending file without a glitch. Now. With that said, My current webpack/tsc/babel stack was following the command line behavior, and that's why it was working. TL;DR: @basarat Thanks. I was going to do that, but decided to take a look at the source and ended up running into the solution earlier than I expected. |
@zeh stunning! thanks a billion! |
True. I always use |
Apologies if this is not the right place for questions, but I've started porting a site build system I have from Webpack to Fuse-box and ran into a snag. I would appreciate any input.
The project in question uses TypeScript 2.2 + React + Redux + PostCSS. This is my current attempt at a build script:
When I run this, I get this message:
So it's apparently trying to interpret that file as a React file, and tripping on the comma at line 13. But it's not what the file is; it's just a reducer to a Redux store. This is its full contents:
A wild guess is that it's getting tripped by the
<
and>
in the generics method declaration, but that seems... silly.Anyone know what I'm doing wrong? The tsx-ish examples I've found are all over the place and they just mention automatic ts/tsx interpretation.
My tsconfig, for reference:
Update: it seems the part that's tripping the compiler is any
<...>
cast, not the generic method. In the above case, all<ISearch>...
casts cause it to fail. Replacing it by the other casting syntax (... as ISearch
) makes it work.After fixing search.ts above, another file was running into the same problem. This was was the faulty code:
Changing it to this fixes the issue:
So there we go.
The text was updated successfully, but these errors were encountered: