FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Tsickle emits bound `this` generics which trigger jscompiler whitelist conformance checks · Issue #1015 · angular/tsickle · GitHub

This repository was archived by the owner on May 22, 2025. It is now read-only.

Repository navigation

This repository was archived by the owner on May 22, 2025. It is now read-only.

Tsickle emits bound this generics which trigger jscompiler whitelist conformance checks #1015

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL