简体   繁体   English

在TypeScript中创建const对象时遇到问题

[英]Problem creating const object in TypeScript

I'm getting the following error when trying to compile my code on Angular 7.2.0 with TypeScript version 3.2.2: 尝试使用TypeScript版本3.2.2在Angular 7.2.0上编译我的代码时遇到以下错误:

error TS1005: ',' expected.**… 错误TS1005:“,”预期。**…

It is linked to the line where I try to declare a const object. 它链接到我尝试声明const对象的行。

addAppareil(name: string status: string) {
    const appareilObject = {
      id: 0,
      name: '',
      status: ''
    };
  }

I don't get why it isn't correct, I've tried a lot of ways to do this but nothing worked good and nothing on the web that matches my problem. 我不明白为什么它是不正确的,我已经尝试了很多方法来做到这一点,但是没有任何效果很好,并且网络上没有任何问题与我相匹配。

You forget to put comma in arguments: 您忘记在参数中加上逗号:

addAppareil(name: string, status: string) { // <---- In This Line

 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM