Uh oh!
There was an error while loading. Please reload this page.
TypeScript support - #2815
Conversation
| try { | ||
| return require('react-scripts-plugin-typescript').tsc; | ||
| } catch (e) { | ||
| return require('typescript'); |
There was a problem hiding this comment.
This would only happen post eject, where throwing would happen if the user had malformed node_modules; by default this will "work". We could add a helpful message, I suppose.
| }, | ||
| }; | ||
| module.exports = applyPlugins(base, ['typescript'], { path, paths }); |
There was a problem hiding this comment.
Maybe expand the whitelisted plugins into multiple lines starting from the first plugin, to minimize future diffs?
module.exports = applyPlugins(base, [
'typescript',
], { path, paths });
Diff:
module.exports = applyPlugins(base, [
'typescript',
+ 'sass',
], { path, paths });Versus:
-module.exports = applyPlugins(base, ['typescript'], { path, paths });+module.exports = applyPlugins(base, [+ 'typescript',+ 'sass',+], { path, paths });There was a problem hiding this comment.
This is controlled by prettier, but I agree that it's a good idea.
We're going to be adding more meta information (and probably move where this is) -- we will need plugin name and plugin version supported: { name: 'typescript', version: '1.x' }.
Once this is turned into an object it'll probably break onto single lines.
| pushExclusiveLoader, | ||
| } = require('react-dev-utils/plugins'); | ||
| function apply(config, { path, paths }) { |
There was a problem hiding this comment.
Just curious: is there any reason this isn't just const path = require('path'), but passed into the plugin instead?
There was a problem hiding this comment.
When inlining the plugin during eject the transform is not smart enough to pull required dependencies/packages; so for now required packages must be passed in.
There was a problem hiding this comment.
Ah makes sense! Is react-dev-utils/plugins a little special then, that you're able to require it just above?
There was a problem hiding this comment.
Yeah! Those methods get removed entirely when ejecting -- that package should be the only package that is ever required inside the plugin(s).
There was a problem hiding this comment.
davidwparker
commented
Aug 11, 2017
@Timer - good stuff here. Question- is there a time we think the plugin system #2784 is going to be added? And if so, how do you think something like this will compare to https://github.com/wmonk/create-react-app-typescript ? Keep up the good work, thanks! |
zhenwenc
commented
Aug 15, 2017
I am using Welcome to have a look and give it a try zc-react-scripts |
@davidwparker I think the |
stunaz
commented
Oct 14, 2017
@Timer any news on this? Or it has to land after plugin system? |
bootstraponline
commented
Nov 7, 2017
Is there a plan to have this merged? TypeScript support would be awesome. |
qinyang1980
commented
Nov 24, 2017
(create react app + typescript + antd) without eject and without using Babel. |
js2me
commented
Feb 2, 2018
@qinyang1980 it's repository supports tree shaking of typescript files in build application? Just I heard so react-create-app doesn't support that feature in building |
brunolemos
commented
Jul 29, 2018
I made an alternative PR adding TypeScript using Babel 7: #4837 |
devuxer
commented
Oct 4, 2018
@Timer, Do you have a status update on this? Is it still planned? Is there an ETA? |
bugzpodder
commented
Oct 5, 2018
@devuxer please follow along here: |
Timer
commented
Oct 5, 2018
We're very interested in bringing TypeScript support. I will either finish this PR or merge #4837 provided everything works properly. |
Timer
commented
Oct 18, 2018
Closing in favor of #4837. |
Timer
commented
Oct 30, 2018
TypeScript is now officially supported as of Create React App 2.1. Read the release notes to get started! |
This includes PR #2784.
Here's an example of a working plugin, which enables TypeScript support for development, production, and testing.
Click here to see the diff without PR #2784.