-
Notifications
You must be signed in to change notification settings - Fork 492
CRA 2.0 #431
Comments
@samuelcastro The best what you can do is to install And next time please refrain from opening new issues when you are able to find the PR and you see there is a discussion going in there. To maintainers: I recommend to keep this issue open, or these wil just pile up because people are lazy. |
On a related note, given facebook/create-react-app#4837 provides typescript support via babel, it'd be nice to have a comparison of the benefits of continuing to use |
Is there then any need for further development of this project? |
That's what I've been wondering, I'm switching to CRA with native babel7/typescript support. |
@benneq I think it's a safe bet to choose CRA2 for a new project. However, note that it's not released yet so you have to either wait or somehow get it from a master. |
It's been published under the
...and then follow the instructions to add typescript. |
@osdiab Could you please share your experience with switching to CRA? Does everything work in your project without issue? |
There are a couple stumbling points. One is that with react-scripts-ts you can refer to your code as an absolute import like import x from “src/path/to/module”; to keep that working Second, Babel 7 resolves modules a little differently than tsc does; I wasn’t using esModuleInterop and allowSyntheticDefaultImports before, but cra will automatically add a few config settings to tsconfig.json when you run react-scripts start, including that. So some imports, like import * as color from “color”, instead As an aside it only flashes the fact that it modifies your tsconfig.json for like 1 second when running react-scripts start, so if you don’t catch that I can see it being pretty confusing. Otherwise everything else seems fine! On the nice side, my build seems to be happening significantly faster (though it’s not a big deal to me since I haven’t dropped it in a large project yet, just a tiny static website) |
@osdiab did you just checkout master? I checked npm and it doesn't look like there's a release for 2.1 yet. Ah, I see you're using 2.0.6 -> https://github.com/osdiab/mitaka-house/blob/1fa40cb4ea82332de865cd44b8108a1b46a8605a/package.json#L22 |
@osdiab Thanks for sharing valuable intel. Regarding "paths" there was a question from @borisowsky (facebook/create-react-app#4837 (comment)) and he was just ignored. I guess we don't get rid of react-app-rewired that easily. Using tsconfig-paths-webpack-plugin should solve the issue with typescript paths setting. I am wondering where are those forced tsconfig settings coming from. Looking to the changeset of that PR I don't see it would be setting |
Seems like 2.1 will be out later today |
@MikelArnaiz That announcement was for the new version of react-scripts which supports Typescript using babel 7's TS support -- not for this package. |
@MikelArnaiz But that's what we are talking about in couple last comments ;) This package might not be needed anymore. |
create-react-app v2 typescript demo |
@RayLuxembourg That's not much of the demo since it does not contain much of the code. I assume you have just executed CLI. Are there any custom modifications? I am a bit surprised about |
@FredyC the react.d.ts is auto generated along with tsconfig via the cli. |
TypeScript is now officially supported as of Create React App 2.1. Read the release notes to get started! |
Looks like upon trying to install |
What do you mean by "absolute imports"? |
Like importing from the src dir by referring to files by “src/path/to/module” as opposed to “../../path/to/module”, which you can usually achieve in typescript using the paths and baseUrl config options, as well as aliases in webpack |
Oh okay, didn't know that this was possible. I actually don't care about imports at all as long as it works. The IDE provides tools for auto import and refactoring. I see no reason to make imports "look pretty". Or is there any other benefit? |
@benneq What IDE are you using? VSCode? Some extension for auto import? It's just that default autoimport is rather wonky sometimes and does not work as expected. In these cases, it's super helpful to have a shorter path to type :) |
VSCode and IntelliJ IDEA / WebStorm. I never had problems with auto imports yet. |
Just to give my experience with 2.1 last night. I tried converting a project over because giving up aliased imports doesn't bother me too much. However, the linting is not where I'd want it to be. It's currently using ESLint instead of TSLint. I did see that there is an issue started to switch to TSLint so I will not attempt to migrate again until that point. There was a comment on one of CRA issue threads about not wanting to support no-any. We also extend tslint-immutable at work. If we can configure both in tslint.json after the fact we'll be switching |
@whengely Same here, I tried converting my project from |
@shobhitg You still can use tslint, just include it manually like:
|
@samuelcastro if I do that I am sure it would help vscode provide linting errors, but will my build system ( |
@shobhitg You can call your custom |
It does support enums, just not the const ones which don't actually generate any runtime code so that's even more surprising that it doesn't work, but who cares, CRA-TS is the way to go for now :) |
@samuelcastro @shobhitg Another alternative is to try to use typescript-tslint-plugin in your tsconfig.json. It has a different VS Code plugin (mentioned in the Readme), but is how I've preferred to use tslint for a while anyway. (Some of tslint's rules work better in Typescript plugin form, and overall it's a good experience.) |
Any thoughts when will we be able to support CRA 2.0?
There is this PR #409, just wondering what's remaining to get it through.
Thanks.
The text was updated successfully, but these errors were encountered: