Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在TypeScript中禁用TS2554_Typescript - Fatal编程技术网

在TypeScript中禁用TS2554

在TypeScript中禁用TS2554,typescript,Typescript,如何禁用TS2554的类型脚本检查?我希望在我的项目中以这种方式利用JavaScript的动态性 src/server.ts:14:1 - error TS2554: Expected 2 arguments, but got 1. 14 two('hello'); ~~~~~~~~~~~~ src/server.ts:10:19 10 function two(one, two) { ~~~ An argument

如何禁用TS2554的类型脚本检查?我希望在我的项目中以这种方式利用JavaScript的动态性

src/server.ts:14:1 - error TS2554: Expected 2 arguments, but got 1.

14 two('hello');
   ~~~~~~~~~~~~

  src/server.ts:10:19
    10 function two(one, two) {
                         ~~~
    An argument for 'two' was not provided.


Found 1 error.

将第二个参数设为可选。如下图所示:

function two (one: string, two?: string) {
  ...
} 

two("hello")
或者,您可以在错误前一行中使用
@ts ignore
,使Typescript静音。或者在文件开头使用
@ts nocheck

@ts-ignore
two("hello")

是否需要禁用类型检查?你不能把它变成一个例子吗?这能回答你的问题吗?