How can I prevent the warning 'Property MyProp1 never defined on MyObject'?

后端 未结 5 1944
既然无缘
既然无缘 2021-01-11 10:43

I have some HTML that contains a JSON string. In the on DOM ready callback, I have something like this:

MyObject = JSON.parse($(\'#TheJsonString\').         


        
5条回答
  •  长发绾君心
    2021-01-11 11:19

    To suppress this warning for a specific function, you can use the @suppress annotation:

    /**
     * @suppress {missingProperties}
     */
    function useJsonObject() { ... }
    

    To turn off this warning globally, use the jscomp_off compiler flag to turn off the missingProperties class of warnings.

提交回复
热议问题