gpt4 book ai didi

javascript - JSC_NOT_FUNCTION_TYPE 谷歌闭包编译器

转载 作者:行者123 更新时间:2023-12-03 12:43:53 26 4
gpt4 key购买 nike

有没有办法消除警告

JSC_NOT_FUNCTION_TYPE expressions are not callable

使用 google 闭包编译器打包 javascript 时?

var require = function(){};

var a=typeof require=="function"&& require;

function hello(name) {
var x = 2;
alert(a(x));
alert('Hello, ' + name);
}
hello('User X');

运行闭包编译器的在线帮助工具:http://closure-compiler.appspot.com/home

最佳答案

问题是,如果 require 不是函数,则 a 可能不是函数:

var a=typeof require=="function"&& require;

相反,您可以使用

var a=typeof require=="function" ? require : function(){};

关于javascript - JSC_NOT_FUNCTION_TYPE 谷歌闭包编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23411984/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com