Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

const compile = require('types-assert/compiler').compile; const assert = require('types-assert/assert').assert; // tsファイルをtypes-assertのオブジェクトに変換 const type = compile('type.ts'); const obj1 = { stringProp: "hoge", numProp: 2 }; // 型が正しい場合はスルー assert(obj1, type.Interface1); const obj2 = { stringProp: "hoge", numProp: "2" }; // 型がおかしいのでError assert(obj2, type.Interface1);
この記事は2016年に書かれた古い記事です。当時はまだTypeScript2.0も出ていないころで今とは状況がかなり異なっています。参考にする場合注意してください。 はじめに TypeScriptの型システム Declaration space Open-ended ここまでの確認 型定義ファイルを読み書きできるようになるために declare キーワード 既存のオブジェクトの型定義を拡張する グローバルなオブジェクトに対する宣言 module Export Assignments Relative or Non-relative module imports ES2015形式 実際の定義ファイル 既存の定義ファイルを拡張する declare global { } について Typings について おわりに インターン募集中 はじめに こんにちはアプリケーションエンジニアの id:t_k
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く