Typescript v8 natives 语法 预期表达 [英] Typescript v8 natives syntax Expression expected
本文介绍了Typescript v8 natives 语法 预期表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当 v8 中的 --allow-natives-syntax
标志被设置时,使用 Typescript 4.1.2 是否可以编译引用函数的代码?
Using Typescript 4.1.2 is it possible to compile code that references the functions one calls when the --allow-natives-syntax
flag in v8 is set?
例如:
function foo(bar: ()=>void)): void {
%OptimizeFunctionOnNextCall(bar); // --> TS1109; Expression expected
}
//@ts-ignore
和 //@ts-expect-error
都没有消除这个错误
Neither //@ts-ignore
nor //@ts-expect-error
silence this error
推荐答案
我没有样板来测试 v8 原生,所以我不知道它是否有效,但你可以尝试下一段代码
I don't have boilerplate to test v8 natives, so I don't know if it works, but You can try next piece of code
function foo(bar: () => void): void {
//@ts-ignore
((void 0) %OptimizeFunctionOnNextCall(bar));
}
不要评判我)我只是想帮忙)
Don't judge me) I'm just trying to help)
这篇关于Typescript v8 natives 语法 预期表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文