-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
I have an @record
type with a template parameter which is not yet used.
I can't get an object literal to infer to that type when calling a method with an inferred type parameter.
/** @constructor @template T */
function EventType() {}
/** @struct @record @template MODEL */
function ChangeEventArgs() {};
/** @const {number} */
ChangeEventArgs.prototype.reason;
/**
* @param {!EventType<T>} type
* @param {T} args
* @template T
*/
function notify(type, args){}
/** @const {!EventType<!ChangeEventArgs<string>>} */
const eventType = new EventType();
notify(eventType, {reason: 0});
/** @const {!ChangeEventArgs<string>} */
const works = {reason: 0};
input0:21: WARNING - actual parameter 1 of notify does not match formal parameter
found : EventType<ChangeEventArgs<string>>
required: EventType<(ChangeEventArgs<string>|{reason: number})>
notify(eventType, {reason: 0});
^
Activity
[-]Templated @record types fail inference with other templates[/-][+]@record type with unused template parameter fails type inference[/+]dimvar commentedon Jun 10, 2016
FYI, this works correctly in the new type inference.