tsc

Expect at least one argument for variadic method in TypeScript

旧巷老猫 提交于 2020-12-12 08:58:11
问题 I have a method like so: getValues(...args: Array<string>) : Array<any> { return args.map(k => { return this.shared.get(k); }); } I use the method like this: const c = b.getValues(); // compiles it's actually incorrect in my case to pass no arguments, it only makes sense if at least one argument is passed. Is there a way to tell TypeScript that at least one argument needs to be passed? 回答1: You can add an overload that has a mandatory parameter to force callers to specify at least one value,

Typescript noEmit use case

社会主义新天地 提交于 2020-12-08 05:26:29
问题 What is the use case for noEmit in Typescript? I'm interested because I want to see if I can use this for development where I'll compile and run the compiled code without outputting them onto the file system which would be more efficient. Edit: Perhaps this would be straight forward: "Can I use noEmit tag in typescript to compile and run the code without outputting them onto the file system? If so, how would I do that?" 回答1: It's used when tsc is used only for type checking, not for

Typescript noEmit use case

六眼飞鱼酱① 提交于 2020-12-08 05:26:21
问题 What is the use case for noEmit in Typescript? I'm interested because I want to see if I can use this for development where I'll compile and run the compiled code without outputting them onto the file system which would be more efficient. Edit: Perhaps this would be straight forward: "Can I use noEmit tag in typescript to compile and run the code without outputting them onto the file system? If so, how would I do that?" 回答1: It's used when tsc is used only for type checking, not for