Typescript v8 natives syntax Expression expected

 ̄綄美尐妖づ 提交于 2021-01-29 06:01:16

问题


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?

For example:

function foo(bar: ()=>void)): void {
    %OptimizeFunctionOnNextCall(bar); // --> TS1109; Expression expected
}

Neither //@ts-ignore nor //@ts-expect-error silence this error


回答1:


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)



来源:https://stackoverflow.com/questions/65185710/typescript-v8-natives-syntax-expression-expected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!