如何让闭包编译器停止省略对象参数?

时间:2013-12-10 13:18:03

标签: javascript google-closure-compiler

我正在使用闭包编译器。我编译了一个包含函数返回对象的库。编译器说返回的对象不一致。

~~~~x.js:52: ERROR - inconsistent return type
found   : {a: number, b: number, c: number, d: number, ...}
required: {a: number, b: number, c: number, d: number, ...}

我无法找出有什么不同......

是否有任何选项可以显示...中省略的内容?

1 个答案:

答案 0 :(得分:1)

不,目前没有选项;我们真的应该做得更好,以显示记录类型的差异。但是,您可以通过执行以下操作来缩小问题范围:

var y = problemValue;
/** @type {ExpectedType} */
var x = /** @type {ExpectedType} */({});

// check each property
x.a = y.a;
x.b = y.b;

在大多数情况下,这将显示无法分配并导致问题的属性。

相关问题