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

create-react-app v3 doesn't show TypeScript errors in overlay #2090

Open
karlhorky opened this issue Jun 24, 2019 · 9 comments
Open

create-react-app v3 doesn't show TypeScript errors in overlay #2090

karlhorky opened this issue Jun 24, 2019 · 9 comments

Comments

@karlhorky
Copy link

karlhorky commented Jun 24, 2019

🐛 bug report

Description of the problem

TypeScript errors in a create-react-app sandbox are not displayed in the browser in the error overlay:

Screen Shot 2019-06-24 at 18 43 49

As a counter-example, the CRA errors in the overlay displayed locally:

Screen Shot 2019-06-24 at 18 37 50

I didn't find the original PR introducing this in CRA, but I found this PR discussing the feature: facebook/create-react-app#7091

Edit: Maybe this is the original PR? facebook/create-react-app#5903

This code from the PR looks like it could plausibly be the async handling of TypeScript errors (with modifying the webpack compilation stats and sending the errors and warnings to the webpack socket):

const messages = await tsMessagesPromise;
clearTimeout(delayedMsg);
statsData.errors.push(...messages.errors);
statsData.warnings.push(...messages.warnings);

// Push errors and warnings into compilation result
// to show them after page refresh triggered by user.
stats.compilation.errors.push(...messages.errors);
stats.compilation.warnings.push(...messages.warnings);

if (messages.errors.length > 0) {
  devSocket.errors(messages.errors);
} else if (messages.warnings.length > 0) {
  devSocket.warnings(messages.warnings);
}

How has this issue affected you? What are you trying to accomplish?

If possible, I would like to see TypeScript error messages in the error overlay in the browser (like in normal CRA locally).

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox PROD-1561199685-a102c8493
Browser Chrome 75.0.3770.100
Operating System macOS 10.14.5

Ref (maybe related?): #1303

@karlhorky
Copy link
Author

Well, after trolling around with the TypeScript compiler today, I've found a hacky way to show the errors in the browser.

Kapture 2019-06-25 at 17 29 22

I've got it running here:

https://codesandbox.io/s/create-react-app-v3-with-typescript-overlay-errors-colix

References for what I was trying to do (type checking TypeScript code in create-react-app and Jest tests):

https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler

microsoft/TypeScript#29226 (comment)

https://gist.github.com/teppeis/6e0f2d823a94de4ae442

dsherret/ts-morph#358 (comment)

https://stackoverflow.com/questions/52969177/typescript-createprogram-throwing-ts-sys-is-undefined (with the error "Cannot read property 'useCaseSensitiveFileNames' of undefined")


Note that there are still significant problems with this approach:

  • If not filtered out, all the errors with the DOM APIs appear:
    Cannot find global type 'Array'.
    Cannot find global type 'Boolean'.
    Cannot find name 'console'. Do you need to change your target library? Try changing the lib compiler option to include 'dom'.
    etc..

@github-actions
Copy link

github-actions bot commented Sep 4, 2020

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Sep 4, 2020
@karlhorky
Copy link
Author

not stale

@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Dec 20, 2020
@karlhorky
Copy link
Author

not stale

@github-actions github-actions bot removed the stale label Dec 21, 2020
@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Mar 25, 2021
@karlhorky
Copy link
Author

hello stalebot

@github-actions github-actions bot removed the stale label Mar 26, 2021
@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Jun 25, 2021
@karlhorky
Copy link
Author

bot

@github-actions github-actions bot removed the stale label Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants