6
がfunction.applyを使用しているときにクロージャがパラメータをタイプチェックしないのはなぜですか?
/**
* @param {string} a
* @param {string} b
*/
var f = function(a, b){
// ...
}
/**
* @param {string} a
* @param {boolean} c
*/
var h = function(a, c){
f.apply(this, arguments); // no compile error
f.apply(this, [a, c]); // no compile error
f.call(this, a, c); // compile error: does not match formal parameter
}
下記参照なぜ閉鎖は、呼び出しを使用している場合にのみエラーが発生して適用されませんか?
閉包を行う方法はありますか?私が適用を使用していてもパラメータをチェックしますか?
明示的にアレイを入力できますか? – Bergi
@Bergiそれを行う方法があるなら、私はそれを知らない。 – oldergod