Next.js: Next complied success even if typescript type check error

Created on 27 Feb 2019  路  9Comments  路  Source: vercel/next.js

Examples bug report

Typescript type check error show on IDE but still complied success

Example name

custom-server-typescript

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

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

  1. Do anything to make typescript complain but still a valid js code (E.g let a: string = 1)

Expected behavior

Throw error on type check error

Screenshots

image

System information

  • OS: Windows
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: 8.0.1

Additional context

good first issue example

Most helpful comment

I will be fixing this as part of updating almost all of the examples

All 9 comments

May you try to use with-ts-node example?

May you try to use with-ts-node example?

Crash on the first try. Even if this work I still need some babel plugin for the project and this example doesn't use babel

Setting "strict": true in tsconfig.json seems that it reports errors only in server/index.ts

I will be fixing this as part of updating almost all of the examples

@zeit/next-typescript uses @babel/plugin-transform-typescript which does not type check input.

Does not type-check its input. For that, you will need to install and set up TypeScript.

If you want to see errors in your terminal then you can set up fork-ts-checker-webpack-plugin.

Or if you completely want to prevent build, you can use awesome-typescript-loader or ts-loader

I don't think this is a bug: babel-typescript only strip types but does not run type checking at all, so this is the intended behavior.

As @azizhk said, if you want the build to fail, you'll need to use fork-ts-checker-webpack-plugin

I'm using fork-ts-checker-webpack-plugin, I see errors in the console, but the build does not fail. I followed the example guide to set it up.

Screen Shot 2019-05-13 at 12 36 40 PM

This has been implemented in the latest Next.js canary version. You can try it by installing next@canary!

Was this page helpful?
0 / 5 - 0 ratings