Question

I'm working with closure compiler. I've compiled a library with functions returning objects. The compiler said that the returning object is inconsistent.

~~~~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, ...}

I can't find out what's different ...

Are there any options to show what's omitted in ...?

Was it helpful?

Solution

No, there isn't currently an option; we really should do a better job showing the differences in record types. You can, however, narrow down the issue by doing something like:

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

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

In most cases, this will show you property that is not assignable and causing the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top