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 examples are broken #4528

Closed
EugeneDraitsev opened this issue Jun 3, 2018 · 1 comment
Closed

Typescript examples are broken #4528

EugeneDraitsev opened this issue Jun 3, 2018 · 1 comment
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@EugeneDraitsev
Copy link

EugeneDraitsev commented Jun 3, 2018

Bug report

Describe the bug

I tried to launch with-jest-typescript example, but seems like it's broken.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. run yarn create next-app --example with-jest-typescript with-jest-typescript-app
  2. cd with-jest-typescript-app
  3. yarn dev
  4. go to http://localhost:3000/ and try to updated the page
    You will able to see error: TypeError: Cannot read property 'extensions' of null

Also yarn test is broken too. It fails with error

 Test suite failed to run

Expected behavior

All works fine

Screenshots

image
image

System information

  • OS: macOS 10.13,4
  • Browser chrome 66.0.4
  • Version of Next.js: 6.0.3

Updated:

Same for with-typescript-app

  1. run yarn create next-app --example with-typescript with-typescript-app
  2. cd with-jest-typescript-app
  3. yarn dev
  4. go to http://localhost:3000/ and try to updated the page

You will able to see another error:

Error: [BABEL] /Users/eudr1/environment/with-typescript-app/pages/index.tsx: .overrides is not allowed in preset options
@EugeneDraitsev EugeneDraitsev changed the title with-jest-typescript example is broken typescript examples is broken Jun 3, 2018
@EugeneDraitsev EugeneDraitsev changed the title typescript examples is broken Typescript examples are broken Jun 3, 2018
@timneutkens timneutkens added help wanted good first issue Easy to fix issues, good for newcomers labels Jun 3, 2018
timneutkens pushed a commit that referenced this issue Jun 6, 2018
Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution back to next.js, by upgrading the with-jest-typescript example to next 6.0.0.

The steps I followed were:

1. `npx babel-upgrade --write` which added babel-core@^7.0.0-bridge.0 to allow jest's babel 6 to play nice with next's babel 7
2. Remove `ts-jest` and replace with `babel-jest` to use babel to transform the typescript code, as is done when the dev and production builds run
3. Update the babelrc to use commonjs modules in test mode to be compatible with jest

Also, I removed the `NODE_ENV=test` on the jest task, because jest sets the env to test anyways, and I'm on windows where this code is incorrect. The other option is to use `cross-env` but I felt it was simpler to just remove the environment override.

To my knowledge, this PR would help on the following issues:

#3663 #4227 #4531 #4528 #4239
lependu pushed a commit to lependu/next.js that referenced this issue Jun 19, 2018
Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution back to next.js, by upgrading the with-jest-typescript example to next 6.0.0.

The steps I followed were:

1. `npx babel-upgrade --write` which added babel-core@^7.0.0-bridge.0 to allow jest's babel 6 to play nice with next's babel 7
2. Remove `ts-jest` and replace with `babel-jest` to use babel to transform the typescript code, as is done when the dev and production builds run
3. Update the babelrc to use commonjs modules in test mode to be compatible with jest

Also, I removed the `NODE_ENV=test` on the jest task, because jest sets the env to test anyways, and I'm on windows where this code is incorrect. The other option is to use `cross-env` but I felt it was simpler to just remove the environment override.

To my knowledge, this PR would help on the following issues:

vercel#3663 vercel#4227 vercel#4531 vercel#4528 vercel#4239
@programbo
Copy link
Contributor

@timneutkens This issue was fixed by de6bf4e...

HOWEVER

I did just learn that I needed to update create-next-app in order for it to install the latest version of the example. Not sure if the example package.json not bumping the version from 1.0.0 has anything to do with CNA happily installing a months old version of the example.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants