babel/preset-typescript
TypeScript and Babel 7 | TypeScript
モチベーション
すでにBabelをつかっているが
TypeScriptの型チェックがしたい
問題
すでにBabelを利用している人にとっては
rewiring a build that’s already working can be a daunting task.
そこでつくられたのがこのモジュール
注意点
As we mentioned above, the first thing users should be aware of is that Babel won’t perform type-checking on TypeScript code; it will only be transforming your code, and it will compile regardless of whether type errors are present. While that means Babel is free from doing things like reading .d.ts files and ensuring your types are compatible, presumably you’ll want some tool to do that, and so you’ll still need TypeScript. This can be done as a separate tsc --watch task in the background, or it can be part of a lint/CI step in your build. Luckily, with the right editor support, you’ll be able to spot most errors before you even save.
Babel自体はType-checkをしないので、型にエラーが有ってもコンパイルは行われる!
Babelがd.tsを読んだり型チェックをする保証はない
このことはドキュメントには書いてない?と思ったらちらっと書いてあった
https://babeljs.io/docs/en/babel-preset-typescript
This preset includes the following plugins:
@babel/plugin-transform-typescript
plugin-transform-typescriptを見ると
Does not type-check its input. For that, you will need to install and set up TypeScript.
https://babeljs.io/docs/en/babel-plugin-transform-typescript
参考:@babel/preset-typescriptを使ってTypeScriptを変換する - Qiita
そういうことが公式ドキュメントみても、なんとなくしかわからなくてつらいkadoyau.icon