This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.
Description
m getting a conformance check error with a generic this value:
/**
* d3 inverts the `this` ownership. buildD3Handler reverts that, so that the
* passed method is called in the original context with the d3 value as the
* input.
*/
export function
buildD3Handler<ContextT, SVGEltT extends SVGElement, BoundObjT extends
BoundD3T, HandlerRetT>(
context: ContextT,
targetMethod: (svgElt: SVGEltT, boundObj: BoundObjT) => HandlerRetT,
): d3.ValueFn<SVGEltT, BoundObjT, HandlerRetT> {
return function(this: SVGEltT, node: BoundObjT) {
// Here 'this' is a reference to the D3 DOM Node
return targetMethod.call(context, this, node);
};
}
As far as I can tell, this is sensible:
/**
* d3 inverts the `this` ownership. buildD3Handler reverts that, so that the
* passed method is called in the original context with the d3 value as the
* input.
* @template ContextT, SVGEltT, BoundObjT, HandlerRetT
* @param {ContextT} context
* @param {function(SVGEltT, BoundObjT): HandlerRetT} targetMethod
* @return {?}
*/
function buildD3Handler(context, targetMethod) {
return (/**
* @this {SVGEltT}
* @param {BoundObjT} node
* @return {?}
*/
function (node) {
// Here 'this' is not a reference to TopologyGraphComponent object.
return targetMethod.call(context, this, node);
});
}
But I am getting:
ERROR - Violation: References to "this" that are typed as "unknown" are not allowed. See https://github.com/google/closure-compiler/wiki/Conformance:-Unknown-type-of-%E2%80%9Cthis%E2%80%9D
Reactions are currently unavailable
m getting a conformance check error with a generic this value:
/** * d3 inverts the `this` ownership. buildD3Handler reverts that, so that the * passed method is called in the original context with the d3 value as the * input. */ export function buildD3Handler<ContextT, SVGEltT extends SVGElement, BoundObjT extends BoundD3T, HandlerRetT>( context: ContextT, targetMethod: (svgElt: SVGEltT, boundObj: BoundObjT) => HandlerRetT, ): d3.ValueFn<SVGEltT, BoundObjT, HandlerRetT> { return function(this: SVGEltT, node: BoundObjT) { // Here 'this' is a reference to the D3 DOM Node return targetMethod.call(context, this, node); }; }As far as I can tell, this is sensible:
/** * d3 inverts the `this` ownership. buildD3Handler reverts that, so that the * passed method is called in the original context with the d3 value as the * input. * @template ContextT, SVGEltT, BoundObjT, HandlerRetT * @param {ContextT} context * @param {function(SVGEltT, BoundObjT): HandlerRetT} targetMethod * @return {?} */ function buildD3Handler(context, targetMethod) { return (/** * @this {SVGEltT} * @param {BoundObjT} node * @return {?} */ function (node) { // Here 'this' is not a reference to TopologyGraphComponent object. return targetMethod.call(context, this, node); }); }But I am getting: