Migrated to React 0.14.3#63
Conversation
|
Thanks @johnnyreilly! This isn't an optimization as much as it is us trying to give the user more control over this. If we didn't perform this step, there'd be no way to say "I only need the typings from this import." On the other hand, with the current behavior, you can always force an import by
Actually, would you mind shortening your fix to one of the above forms just because it's a bit cleaner? |
|
Done. I had to use approach 2 as approach 1 didn't work. Any idea why that might be? |
|
That's weird - approach 1 didn't work? I pulled down the changes and tried using an |
|
Curious - ts-loader is doing the TSC invoking so @jbrantly might have a view. |
|
Try approach 1 on the repo and run |
There was a problem hiding this comment.
nope Can't find variable: React results
|
Just one comment, using |
|
@johnnyreilly I've never run into the issue I don't think because my JSX is always within a React component (so extending I wonder if the lack of |
|
Hi @mhegazy
I did try this but it didn't work I'm afraid. Please feel free to prove me wrong! |
|
I've repro'd the issue on my side as well, it's just that somewhere in the pipeline, the |
|
Import can't get no respect? That makes Aretha sad 😄 |
|
The difference between This actually makes sense to me. When I think of I don't think there is an actual bug here, although it's a bit of a weird situation. This is handled correctly with I think the correct course of action is to either use |
|
👍 |
|
thanks! |
|
Pleasure. When Babel fix the sourcemaps in v6 I intend to upgrade the sample to use Babel 6 instead of v5. Just waiting on a PR to be merged here: |
This PR ports react 0.13.3 to 0.14.3 which should handle the issues raised in #61
All works fine / tests pass. One quirk; I'm having to capture the React variable in each of the JSX tests and in the
main.tsxlike so:These files do not directly use the imported
Reactand so, without the workaround, React is not loaded. I think this is the TypeScript compiler performing an optimisation here; saying "well, they didn't use React directly so they must not need it". I initially thought this was a problem with ts-loader but came to the conclusion it was probably tsc related. Take a look at this demo in the playground. You can see that React is not considered a dependency by TypeScript unless the__react = Reactis uncommented.@jbrantly would you be able to advise if there is a better way around this than what I've done here? (I know you pretty much handled the port of React typings to 0.14 so I thought it might be worth asking.)
Just to be clear, the PR is safe to merge but it would be good to find out if the workaround could be replaced with something a little nicer. I suspect it can't