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
Update 2013-11-05: I take a look at the C code of typeof to better explain why typeof null results in 'object'. In JavaScript, typeof null is 'object', which incorrectly suggests that null is an object (it isn’t, it’s a primitive value, consult my blog post on categorizing values for details). This is a bug and one that unfortunately can’t be fixed, because it would break existing code. Let’s expl
datalist experiment By using <datalist>, you can define a list of suggestions you want the user to select from. Users can optionally select from your suggestions as well as typing it by themselves. Options can be tagged with datalist and referenced from the input element using list attribute by its id. See examples below. input[type=text] datalist For text type, datalist simply suggests list of wo
「機密情報を含むJSONには X-Content-Type-Options: nosniff をつけるべき - 葉っぱ日記」の補足編です。 結局、よくわからないんだけど。 よくわからない場合は、とにかく全てのレスポンスに X-Content-Type-Options: nosniff をつけましょう。 機密情報を含むJSONにX-Content-Type-Options:nosniffをつける理由はわかったけど、「あらゆる」コンテンツにつける理由はなぜ? 機密情報を含まなくても、<script>のような文字列を含むコンテンツをIEで直接開いた場合にはXSSにつながる可能性もあります。どのようなコンテンツにX-Content-Type-Options:nosniffが必要かを考えるくらいであれば、全てのコンテンツに付与したほうが間違いがなくていいでしょう、ということです。 IEのためだけの問
#grid v5 Wed, 3 Nov 2010: This is a little tool we created for our Analog holding page. It inserts a layout grid in web pages, allows you to hold it in place, and toggle between displaying it in the foreground or background. To see it in action, hit G on your keyboard. Download Download #grid from GitHub Features Adaptable for all layout widths and alignments Adaptable for any vertical rhythm valu
サーバサイド(特にNode.js)とクライアントサイド両方で動かしたいものは最近はこんな感じで書いている。 CommonJSのwiki見ててそこに紹介されてるソースコードで(どれだったか忘れたけど。。)やってたのを見ていいなーと思って真似っこした。 (function(define) { define([], function() { 'use strict'; /** * @constructor */ var SomeClass = function() { // initialize }; /** * @type {string} * @private */ SomeClass.prototype.hoge_ = 'hoge'; /** * @return {string} */ SomeClass.prototype.getHoge = function() { return th
JavaScript QRCode reader for HTML5 enabled browser. 2011 Lazar Laszlo http://lazarsoft.info Try it online: http://webqr.com This is a port of ZXing qrcode scanner, http://code.google.com/p/zxing. Usage: Include the scripts in the following order: <script type="text/javascript" src="grid.js"></script> <script type="text/javascript" src="version.js"></script> <script type="text/javascript" src="dete
JavaScriptの演習がてら、Greasemonkeyをいじったんですが、createEventとinitMouseEventを使ったらめちゃくちゃ簡単になることが分かって凄く嬉しくなった。createEventはDOM2にあるけどinitMouseEventはGeckoのDOMメソッドぽい。でもまぁ、Greasemonkeyをいじるぶんにはそれで十二分。 document.createEvent – MDC event.initMouseEvent – MDC 以下、自分用のちょっとしたメモ。 document.createEvent 「document.createEvent」は、指定されたタイプのイベントを生成するメソッド。 var evt = document.createEvent("MouseEvents"); 生成したイベントは「element.dispatchEvent
続き書きました: http://uupaa.hatenablog.com/entry/2012/11/02/154337 今朝方ピコーン*1 があったので頑張って1日で実装してみました。 ピコーンの内容は ・今あるソースコードを汚さずに、動的な型チェックのための仕組みを後付で追加する事ってできないかな? ・同時にパフォーマンス・チューニングに必要な情報も取れるのではないか ・宣言と実装を分離する方法があるのではないか ・今まではできなかった、戻り値の動的な型チェックもできるのではないか です。 監視対象の関数のIN/OUTで、呼び出し階層をネストした状態で吐き出すトレース機能 監視対象の関数の呼び出し回数と、実行時間の統計情報 宣言にもとづく引数の動的な型チェックと、戻り値の動的な型チェック などを prof.js として実装してみました。スライドはこちら http://www.slide
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く