Error TS6138 - Property xxxx is declared but its value is never read

我有一段 TypeScript 代码:

export class AppModule {
    
    
  constructor(private s: ActiveCartService){
    
    
    if( s === undefined){
    
    
      console.log(s);
    }
    s.isStable().subscribe((data) => console.log('isStable: ' , data));
  }
}

引起如下错误消息:

Error TS6138 - Property xxxx is declared but its value is never read

解决方法:

修改 tsconfig.json:

将下列参数改成 false 即可:

 "noUnusedLocals": false,
 "noUnusedParameters": false,

问题解决:

猜你喜欢

转载自blog.csdn.net/i042416/article/details/124218458