JavaScript/typescript/error:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第39行: 第39行:
* A required parameter cannot follow an optional parameter.
* A required parameter cannot follow an optional parameter.
*: 必选参数不能位于可选参数后
*: 必选参数不能位于可选参数后
* Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'.

2020年8月31日 (一) 03:29的版本

标题文字

  • Property 'call' does not exist on type 'object'
    在项目中,我使用了 await this.axios.call(this.context, { 抛出此错误,axios 的设定是
    interface HttpInterface {
      axios: object;
      context?: Record<string, unknown>;
    }
    
    如果改成 axios: any 可消除错误,又或者这样设置
    interface AxiosPropertyCall {
      call: any
    }
    
    interface HttpInterface {
      axios: AxiosPropertyCall;
      context?: Record<string, unknown>;
    }
    
    await this.axios.call(this.context
    
  • Property 'username' has no initializer and is not definitely assigned in the constructor.
    缺少初始化
    username: AccountInterface['username']
      password: AccountInterface['password']
      verify?: AccountInterface['verify']
      constructor(props:any) {
        super(props)
        this.username = ''
        this.password = ''
        this.verify = ''
      }
    
  • Type 'Login' has no properties in common with type 'HttpParamInterface'.
    两个类之间没有共同属性
  • Cannot find name 'T'
  • Type 'string | number' is not assignable to type 'string'.
    使用 tostring()
  • A required parameter cannot follow an optional parameter.
    必选参数不能位于可选参数后
  • Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'.