TypeScript の型チェックを厳格化したいが既存の型エラーが多すぎて、やむなく緩い型チェックにしている方へ改善の助けになりそうなツールを作ったので紹介です。 🔧 作ったもの プロジェクトのコードベースを走査して、型エラーがあるコードすべてに@ts-expect-error or @ts-ignoreのコメントを追加する suppress-ts-errors という CLI ツールを作りました。 以下の GIF のように npx 経由で簡単に利用できます。 さらに、ts、tsx だけでなくVue SFC のスクリプト部分へのコメント追加にも対応しています。 コードはこちらです。⭐ を貰えると泣いて喜びます。 なぜ作った? 現職のプロジェクトにて型チェックを厳格化できていない(strict: trueにできていない)という状況を改善したいと思ったからです。 型チェックのルールを修正する
Total TypeScript VSCode Extension Learn more on our official docs page. Learn TypeScript from within your IDE. Get helpful hints on syntax, and get translations of TypeScript's most cryptic errors. Download the VSCode Extension
2章はプログラミング初心者に式と文という概念を伝えるのによさそう。コンパイラの概念が透けてみえるようになる。 let を避けろというコラムわかる。 BigInt の解説するんだ。 全体的にJSの言語仕様をTSという側面から解釈しつつ学ぶ、という構成になってる。この構成が初学者に伝わるかというと、完全なJS初学者には無理で他のプログラミング言語の経験は多少要求される。 3章 object への型注釈の文法解説が結構しんどく感じた。文法的に似てるがそれ故に混乱する。そういえば自分も複雑なインラインの型書いてると、今型なのかインスタンスなのか、結構間違ってる気がするので、言語自体が抱える特徴かもしれない。 type と interface の使い分け、今となっては何が何だかわからない気がした。type がない時代があってそれ以降は〜と書いてあるけど、昔の type はジェネリクスとれなくて、途中
This article is inspired by the talk How the TypeScript compiler compiles◹, you should really check it out for a more in-depth understanding about the TypeScript’s compiling process. At a high level, the TypeScript compiler is a tool to help us analyze and compile the TypeScript code into JavaScript (*.js), as well as some type definition files (*.d.ts) or source maps (*.js.map). If the source fil
概要 TypeScriptは、JavaScriptに静的型付けの機能を加えたオープンソースのプログラミング言語です。本書では、根幹となるJavaScriptの仕様・機能とともに、TypeScript独自の仕様・機能を解説します。TypeScriptの基礎知識はこれ一冊だけで学べます。 静的型付き言語は世にいくつもありますが、TypeScriptの型システムは他に類を見ない高い表現力を持っています。本書の読者が、型の有効性を理解しTypeScriptらしいコードを書けるようになるために、本書では、プログラムの安全性を高める基本的な型の扱い方から、TypeScriptの「高い表現力」の源となっているリテラル型・ユニオン型・keyof 型の扱い方まで幅広く取り上げます。また、わかりにくい機能や型安全を脅かす危険な機能についてもごまかさず、歴史的経緯や目的・用途を踏まえたうえで最善の扱い方を説明し
みなさんこんにちは。今日は、TypeScriptの新しいコンパイラオプション(おそらく4.7で導入)であるmoduleSuffixesについての話題がTwitterで見られました。 moduleSuffixesについて詳しくはこちらをご参照ください。 これについては、「モジュール解決がさらに複雑化する」などいくつかの方向性から否定的な意見が見られました。しかし、筆者が考えてみたところ、正当性のある機能追加だと納得できたので考えをご紹介します。 3行でまとめると これまで通りランタイムの挙動に影響しないから大丈夫だよ pathsが怖くないならmoduleSuffixesも怖くないよ TypeScriptはJavaScript環境に追随するよ moduleSuffixesとは では、moduleSuffixesはどんなコンパイラオプションなのかという解説をまず少しします。これはTypeScri
…という話を現場でしました。 こんにちは、クレスウェア株式会社の奥野賢太郎 ( @okunokentaro ) です。TypeScript をお使いのみなさんは、Falsy 値(フォルシーち)というものをご存知ですか。TypeScript や JavaScript を長年使っている読者であれば「そんなもの常識だろう」となるかもしれませんが、TypeScript からの入門者だったり、他言語から TypeScript へ移ってきたような「JavaScript 未経験の TypeScript 経験者」が近年現れ始めており、筆者には案外これが常識とも言い切れなくなっているという感覚があります。 この Falsy 値、もちろん知っているに越したことはないかもしれませんが、TypeScript 全盛となったこの時代にただでさえ他に覚えるべきことが多いなか、果たしてこれはずっと常識のままなのでしょうか
// Comments are kept :) type ComplexType map[string]map[uint16]*uint32 type UserRole = string const ( UserRoleDefault UserRole = "viewer" UserRoleEditor UserRole = "editor" // Line comments are also kept ) type UserEntry struct { // Instead of specifying `tstype` we could also declare the typing // for uuid.NullUUID in the config file. ID uuid.NullUUID `json:"id" tstype:"string | null"` Preference
Published on 04 March, 2022Last updated on 19 February, 2023 See discussions on Hacker News This post has been translated into Korean and Chinese. TypeScript's never type is very under-discussed, because it's not nearly as ubiquitous or inescapable as other types. A TypeScript beginner can probably ignore never type as it only appears when dealing with advanced types, such as conditional types, or
Update 2022-03-10: I’m quoting a few insightful tweets at the end of this blog post. The ECMAScript proposal “Types as comments” (by Gil Tayar, Daniel Rosenwasser, Romulo Cintra, Rob Palmer, and others) is about adding type annotations to JavaScript (there is also an accompanying blog post). Such type annotations would look similar to TypeScript’s and Flow’s annotations and are completely ignored
Today we’re excited to announce our support and collaboration on a new Stage 0 proposal to bring optional and erasable type syntax to JavaScript. Because this new syntax wouldn’t change how surrounding code runs, it would effectively act as comments. We think this has the potential to make TypeScript easier and faster to use for development at every scale. We’d like to talk about why we’re pursuin
This repo is a corpus of notes from many engineers over time on different systems inside the TypeScript codebase. It is not meant as a "one true" source of authoritative documentation for the TypeScript compiler API, but as a way to ease contributions to the microsoft/TypeScript repo. If you're already familiar with the TypeScript codebase and want to help out, we're open to external folks sending
「branded types」という名前はTypeScript特有の概念のようで他での実例は見かけないmrsekut.icon
Recently, we’ve been making heavy use of TypeScript at Atomic Object. We love the great tooling and instant feedback we get with the language’s powerful type system. TypeScript’s structural type system gives us a lot of powerful tools for making invalid states unrepresentable, thereby pointing out bugs at compile time instead of runtime. However, one challenge we’ve faced with TypeScript in applyi
I’m porting the TypeScript Type Checker tsc to Go, and not Rust. As the creator of SWC, an extensible Rust platform, this might sound strange. Let me explain. Why port tsc?# As TypeScript continues to rise in adoption, large projects are facing a dilemma: type checking is one of the slowest parts of their workflow. Developers want type safety without the tradeoff of slower iteration cycles. The Ty
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く