Binding element 'index' implicitly has an 'any' type

前端 未结 3 1606
礼貌的吻别
礼貌的吻别 2021-02-12 23:33

Using the demo project of angular2-mdl as a guide I ported the tab component and tried to implement it as follow:

import { Component } from \'@angular/core\';

@         


        
相关标签:
3条回答
  • 2021-02-13 00:12

    use any or specific type of the variable like ( numbers,string,etc )

    public tabChanged(index:any): void {
        this.activeIndex = index;
    }
    
    0 讨论(0)
  • 2021-02-13 00:19

    It is a check of the type script compiler. You can either remove the check or specify explicitly the any type in the declaration (answer from @Thyagu). In the tsconfig.json file, you could change the line

    "noImplicitAny": false,
    

    to

    "noImplicitAny": true,
    
    0 讨论(0)
  • 2021-02-13 00:23

    for an object, you need to declare the type as

    {index} : {index:any}
    
    0 讨论(0)
提交回复
热议问题