2022年10月1日に開催された #postdev での発表です
2022年10月1日に開催された #postdev での発表です
Learn how to unleash the full potential of the Turing Complete type system of TypeScript! Introduction Type-level TypeScript is an online course to take your TypeScript skills from intermediate to advanced. It will give you a solid understanding of the type system's fundamentals and guide you through its most advanced features. You will find everything you need to become a TypeScript Expert — not
Ezno is an experimental compiler I have been working on and off for a while. In short, it is a JavaScript compiler featuring checking, correctness and performance for building full-stack (rendering on the client and server) websites. This post is just an overview of some of the features I have been working on which I think are quite cool as well an overview on the project philosophy ;) It is still
TypeScriptでは、型レベル計算を用いて関数型から引数の型や返り値の型を取り出すことができます。この操作を簡単に行うためのParametersやReturnTypeという組み込み型も用意されています。 しかし、オーバーロードされた関数型の場合は普通のやり方が通用しません。そこで、この記事ではオーバーロードされた関数型から引数の型や返り値の型を取り出す方法を解説します。 復習: 関数型から引数の型や返り値の型を取り出す方法 普通の関数型の場合、Conditional Typesとinferを用いることで、パターンマッチの要領で関数型からその一部分を抜き出すことができます。 type Func = (left: number, right: number) => string; // [left: number, right: number] 型 type Params = Func e
Managing dependencies of multiple projects across multiple repositories can be time-consuming and error-prone. A monorepo, on the other hand, is a code management or architectural concept that consolidates all the isolated codebases of multiple projects into a single mega repository rather than managing them individually. Monorepos can be advantageous when used with the proper tools. Hence, many o
TypeScript is one of the most loved programming languages, yet I often see teams miss opportunities to leverage it. In this post, we’ll explore an approach to writing pragmatic API contracts in TypeScript that eliminate an entire class of bugs. What & Why A “contract” here is simply a common specification of what data the API sends and receives. When the client and server both reference the same T
TypeScriptではデザインパターンとしてtagged unionによる直和がよく使われます。このときパターンマッチに相当する処理はswitchで行われますが、そこで直和に対する分岐が網羅的であることの保証を実行時と型検査時の両方で賢く行う方法がこれまでも模索されてきました。 今回、ヘルパー関数を導入せずにいくつかの問題を同時に解決する賢い方法を思い付いたので共有します。 コード これだけです。 // switch (action.type) { ... default: throw new Error(`Unknown type: ${(action as { type: "__invalid__" }).type}`); // .. } 以下、より詳しく説明します。 問題 TypeScriptではオブジェクトに type プロパティーを用意し、決まった文字列を入れることで直和を実現
はじめに こんにちは猫です。 反響がけっこうあったので、用途を深掘ってみようと思います。が、先に訂正があります。 ReactElement<Props>で特定のコンポーネントを指定できると思っていたのですが、色々試したところコンポーネントの指定までは難しいようでした。早とちりですいません。 JSXに書かれたコンポーネントはJSX.Elementとなるため、詳細なPropsの型まではチェックしてくれないようです(ReactElement以外のFunctionComponentElementなど他の型も試したのですが、結果は変わらず)。 そのため、この記事では現状可能なことをまとめておきたいと思います。 Reactのchildren propsについて まず@types/reactのv18からFunctionComponentなどに含まれていた暗黙的なchilrenが削除され、明示的に指定する
皆さんこんにちは。今回はTypeScriptの更新先取りシリーズです。TypeScriptの次のバージョンでは、以下のPRの更新が入ると思われます。もちろんPRの著者はAndersさんです。このPRではTypeScriptの根幹を成す機能の一つである「型の絞り込み」が改善されます。特に、unknown型と{}型の取り扱いが修正されている点が注目に値します。 型引数に対する推論が抱えていた既存の問題 {}型は、「nullとundefined以外の任意の値」という意味を持つ型です。この型は形としては空のオブジェクト型ですが、JavaScriptではnullとundefined以外のプリミティブ(文字列や数値など)に対してもプロパティアクセスをしてもエラーにならないという仕様を考慮して、{}型には文字列や数値などのプリミティブも含まれています。 従来型引数に対する推論が抱えていた問題とは、任意の
Refine is a type-refinement and validator combinator library for mixed / unknown values in Flow or TypeScript. Getting StartedRefine is published as @recoiljs/refine on NPM. To get started learning about Refine, check out the documentation on the core concepts of Utilities and Checkers. Why would I want to use Refine?Refine is useful when your code encounters unknown TypeScript type or mixed Flo
こんにちは。先日発売された『プロを目指す人のためのTypeScript入門』は、発売日の最新バージョンであるTypeScript 4.6に対応しています。 そこで、この記事では読者に向けたアフターサポートとして、本の発売時から現在までに増えた機能や変わったところをご紹介します。 現在のTypeScript最新版は4.9です。 TypeScript 4.7での更新 公式アナウンス: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/ Node.js向けES Modulesサポートの追加 TypeScript 4.7最大の話題はこちらです。本書の第1章では、tsconfig.jsonの設定項目について次のように説明しました。 現在のところnode16とnodenextには違いがありません。将来のNode.js
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く