Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript compilation opt-in ? #6041

Closed
shavyg2 opened this issue Dec 14, 2018 · 7 comments
Closed

Typescript compilation opt-in ? #6041

shavyg2 opened this issue Dec 14, 2018 · 7 comments
Assignees
Labels

Comments

@shavyg2
Copy link

shavyg2 commented Dec 14, 2018

Is this a bug report?

No

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

create-react-app replaces tsconfig
use typescript without create-react-app compile

Environment

Windows / Linux Subsystem

Steps to Reproduce

  1. create-react-app todo
  2. cd todo
  3. yarn install
  4. add a tsconfig.json file and change files to .tsx
  5. Don't install typescript

Expected Behavior

I wanted react to compilation of my application to be opt-in

Actual Behavior

react decides it should compile my typescript file,
because i have a tsconfig.json

If I remove the tsconfig.json it still complains and tries to compile it and fails as there is no typescript.

The compilation of typescript on the react dev server is very slow and buggy and doesn't reload, most times i get just a white screen until i reload the page. (seperate issue)

I have solved this issue by just using tsc -w and compiling to js and jsx which react pretty quickly will hot-reload.

This has been working very well and i just keep the repo clean of js and jsx files via a gitignore.

Now there seems to be no way for me to opt out of react transpiling my typescript code.

https://facebook.github.io/create-react-app/docs/adding-typescript

@mrmckeb
Copy link
Contributor

mrmckeb commented Dec 15, 2018

Hi @shavyg2, this is currently by design - and I'm sorry you've found the experience frustrating. I want to add that I'm using this in production applications and haven't faced any issues with the implementation being slow or buggy, but it could certainly be improved and we're always looking at ways to do that.

One option could be to keep your TS files outside of src and compile them into src.

How do you propose the configuration might look to opt-out?

@mrmckeb mrmckeb self-assigned this Dec 15, 2018
@shavyg2
Copy link
Author

shavyg2 commented Dec 16, 2018

I don't know why it's slow but others are experiencing it too.
#5820

I fixed it-ish by doing this inside react-scripts in the webpack.dev.config

// TypeScript type checking
    useTypeScript && false &&
      new ForkTsCheckerWebpackPlugin({
        typescript: resolve.sync('typescript', {
          basedir: paths.appNodeModules,
        }),
        async: false,
        checkSyntacticErrors: true,
        tsconfig: paths.appTsConfig,
        compilerOptions: {
          module: 'esnext',
          moduleResolution: 'node',
          resolveJsonModule: true,
          isolatedModules: true,
          noEmit: true,
          jsx: 'preserve',
        },
        reportFiles: [
          '**',
          '!**/*.json',
          '!**/__tests__/**',
          '!**/?(*.)(spec|test).*',
          '!src/setupProxy.js',
          '!src/setupTests.*',
        ],
        watch: paths.appSrc,
        silent: true,
        formatter: typescriptFormatter,
      }),

Now it's not so slow and i am able to use it.

Interms of typescript it should either allow me to use my own tsconfig and never overwrite it.
If my config is incorrect and there is something that will definitely not work it should break and let me fix it, likely using something in the docs.

My app works perfectly fine, but some props are missing in documented places that are not needed.

To enforce typechecking at compile time is to agree that all libraries that can possible be used will have correctly define types across the npm/javascript ecosystem and therefore should be enforced!

Seems too big of a statement.

This could be opt in and so could they actually typescript type checking using the .env

There is already one for SKIP_PREFLIGHT_CHECK=true
this could be SKIP_TYPESCRIPT_CHECK=true

that way i don't have to change that to false everytime to get my project to compile.

@stale
Copy link

stale bot commented Jan 18, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 18, 2019
@BerndWessels
Copy link

This is not stale, it is unresolved. Stalebot should be able to distinguish this :(

@stale stale bot removed the stale label Jan 21, 2019
@Roustalski
Copy link

Roustalski commented Jan 28, 2019

Update:

After playing around with the configuration for a while and bypassing the verify script, the problem still remains.

Repro: https://github.com/Roustalski/broken-inversify

@stale
Copy link

stale bot commented Feb 28, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Feb 28, 2019
@stale
Copy link

stale bot commented Mar 5, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Mar 5, 2019
@lock lock bot locked and limited conversation to collaborators Mar 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants