Next.js: with-typescript example not transpiling any ts files, giving 404

Created on 26 Jun 2019  路  5Comments  路  Source: vercel/next.js

Examples bug report

Example name

with-typescript

Describe the bug

Getting 404 when I visit http://localhost:3000.

To Reproduce

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

  1. npx create-next-app --example with-typescript with-typescript-app
  2. cd with-typescript-app
  3. npm install
  4. npm run dev or npm run build && npm start
  5. Visit localhost:3000

Expected behavior

Expected to not get a 404 error.

Screenshots

image

image

System information

  • OS: MacOS Mojave
  • Browser: Google Chrome
  • Version of Next.js: 8.1

Additional context

It seems to me like the problem is that the index.js file is not being generated. Are the .babelrc and next.config.js files missing from the with-typescript example?

next.config.js

const withTypescript = require('@zeit/next-typescript')
module.exports = withTypescript()

.babelrc

{
  "presets": [
    "next/babel",
    "@zeit/next-typescript/babel"
  ]
}

When I manually add these two files (following this README: https://github.com/zeit/next-plugins/tree/master/packages/next-typescript) it works just fine:

image

image

Most helpful comment

I had this issue and running next@^8.1.1-canary.57 solved the issue.

All 5 comments

I had this issue and running next@^8.1.1-canary.57 solved the issue.

Yes, with-typescript example is using new typescript support out of the box. This support is only in the latest canary and not in the stable version. You can read more about it here: https://github.com/zeit/next.js#typescript

@huv1k
I updated my version of next to the latest canary, v8.1.1-canary.60, but it still asked me to install Typescript:

image

It works fine after that. Is this behaviour expected?

Shouldn't the package.json be updated in the example? At least the README.md should mention this.

I don't mind making the PR, just curious if the maintainers are waiting until the feature is merged into stable before updating the package.json.

Hey @jplew, I updated example so it reflects the latest canary. Thx for heads up 馃憤

thanks @huv1k, looks great. This one needs to be updated eventually too: https://github.com/zeit/next.js/tree/canary/examples/custom-server-typescript

Was this page helpful?
0 / 5 - 0 ratings