Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Typescript errors don't break build #33

Open
benjamingeorge opened this issue Jan 28, 2019 · 7 comments
Open

Typescript errors don't break build #33

benjamingeorge opened this issue Jan 28, 2019 · 7 comments

Comments

@benjamingeorge
Copy link

When using @babel/preset-typescript with babel-loader (webpack), a typescript error does not break the build. It compiles no matter what which renders typescript useless. When using just webpack and ts-loader I get the desired result of seeing errors in the terminal and a broken build when there is a typescript issue. Is this the intended behavior using typescript and babel in webpack ?

@benjamingeorge benjamingeorge changed the title Typescript errors don't error in build Typescript errors don't break build Jan 28, 2019
@johnknoop
Copy link

@benjamingeorge That is the intended behaviour. Babel just strips all the ts-stuff out. That's why you need the manual typechecking as well.

@gilamran
Copy link
Contributor

gilamran commented Feb 1, 2019

Sounds like a bad plan... Would you want to build your C#/C++ project without type checking?
In my opinion, TypeScript should stop the build on error.

@juanpicado
Copy link

Does anyone know whether there is a way to break the build or display warnings in build time (webpack)?

@frankandrobot
Copy link

frankandrobot commented Apr 24, 2019

Good question @juanpicado, is the solution to use babel-loader with ts-loader? Or something else?

Update: related: https://stackoverflow.com/questions/54675587/babel-typescript-doesnt-throw-errors-while-webpack-build . They recommend: https://github.com/Realytics/fork-ts-checker-webpack-plugin

@juanpicado
Copy link

@frankandrobot I've been testing that plugin for a while and seems run the type checking in parallel and not in sync with the webpack process. Sometimes throws errors before webpck finish the hot reload build. It helps, but not the definitive solution.

@MonkeyDo
Copy link

Here's another plugin that can achieve the same result: fork-ts-checker-webpack-plugin

@nyngwang
Copy link

nyngwang commented Apr 7, 2022

@gilamran: If you are a JS library maintainer, do you want to see your library fails to build during the migration? I don't think you get the point of what @johnknoop was saying.

[...] When using just webpack and ts-loader I get the desired result of seeing errors in the terminal and a broken build when there is a typescript issue. [...]

This is just an additional feature that ts-loader provides. The point of TypeScript is you don't need to do it right at once.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants