我扩展了函数原型但是typescript无法识别它.
Function.prototype.proc = function() {
var args, target, v;
var __slice = [].slice;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
target = this;
while (v = args.shift()) {
target = target(v);
}
return target;
};
// generated by coffee-script
var foo: (number) => (string) => number
= (a) => (b) => a * b.length;
console.log(foo.proc("first", "second"))
Run Code Online (Sandbox Code Playgroud)
结果:tsc -e
The property 'proc' does not exist on value of type 'Function'
Run Code Online (Sandbox Code Playgroud)
我该如何扩展这个对象?
在某些情况下,我不想在webpack 4中使用webpack转换来动态导入.
我们可以用一些选项做到这一点吗?
async componentDidMount() {
const { default: Greeting } = await import("/components/Greeting.js");
this.setState({ component: Greeting });
}
Run Code Online (Sandbox Code Playgroud)
这/components/Greeting.js是在服务器上预编译的.它在chrome中没有正确的webpack工作.
webpack正在尝试编译并发出错误
Uncaught (in promise) Error: Cannot find module '/components/Greeting.js'
at webpackMissingModule
Run Code Online (Sandbox Code Playgroud)