相关疑难解决方法(0)

参数隐式具有"任何"类型

我正在使用visual studio代码进行打字稿项目,在那里我使用了一些第三方npm js库.其中一些不提供任何ts类型(types.d.ts文件),因此每当我使用参数或变量而不指定其类型时,vs代码的linting显示此错误:参数隐式具有"any"类型. 此外,ts不会编译.

我怎样才能防止这种情况发生?

typescript visual-studio-code typescript-typings

10
推荐指数
4
解决办法
2万
查看次数

变量 'a' 隐式具有 'any[]' 类型

我尝试npm start为我的 angular2 项目运行

但得到这个错误:

  push_quick git:(master) npm start

> angular2-quickstart@1.0.0 start /Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/push_quick
> tsc && concurrently "tsc -w" "lite-server"

app/shared/stringUtils.service.ts(8,9): error TS7005: Variable 'a' implicitly has an 'any[]' type.

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR!
Run Code Online (Sandbox Code Playgroud)

对于这种方法:

@Injectable()
export class StringUtilsService {

  mapToFormParamsString( dict …
Run Code Online (Sandbox Code Playgroud)

typescript angular

7
推荐指数
1
解决办法
2万
查看次数

参数 'e' 隐式具有 'any' 类型 React TypeScript

我正在尝试在 React TypeScript 文件中实现这一点:

export class MainInfo extends Component<IProps>{
  continue = e => {
    e.preventDefault();
    this.props.nextStep();
  };

  render() {
    const { values1, handleChange } = this.props
    return (
      <div>
        <Formik
          validateOnChange={true}
          validationSchema={validationSchema}
          initialValues={{ Title: '', ActivationDate: '', ExpirationDate: '', DirectManager: '', HRBP: '' }}
          onSubmit={(data) => {
            console.log(data)
          }}
Run Code Online (Sandbox Code Playgroud)

但是我收到一个参数 'e' 隐含一个 'any' 类型的 React TypeScript 错误。我应该如何解决这个问题?

编辑:我在另一个文件中有这些,我在这里使用它们作为道具

nextStep = () => {
    const { step } = this.state;
    this.setState({
      step: step + 1
    });
  };

  // Go back to …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs tsx react-props

7
推荐指数
3
解决办法
1万
查看次数

参数“m”隐式具有“any”类型

我在运行项目时遇到错误。

这是代码:

private populateModels() {
    var selectedMake = this.makes.find(m => m.id == this.vehicle.makeId);
    this.models = selectedMake ? selectedMake.models : [];
}
Run Code Online (Sandbox Code Playgroud)

这是错误:

ERROR in [at-loader] ./ClientApp/app/components/vehicle-form/vehicle-form.component.ts:82:40
          TS7006: Parameter 'm' implicitly has an 'any' type.
Run Code Online (Sandbox Code Playgroud)

angular angular5

0
推荐指数
1
解决办法
6355
查看次数

参数“res”隐式具有“any”类型

我正在尝试将 Angular HTML 页面数据发送到 MVC 核心。最后有兴趣得到回应。所以我使用 subscribe 方法,但它显示了这个错误 -

参数“res”隐式具有“any”类型。

这是我的代码

import { Component } from '@angular/core';
import { Patient } from './app.model';
import {HttpClient} from "@angular/common/http"
import { Observable, observable } from 'rxjs';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

    patientObj: Patient = new Patient();

    constructor(public httpClient:HttpClient){}

    Add() { 
        //https://localhost:44331/Patient/SubmitPatient ServerSide Page for display record
        alert(this.patientObj.id);
        var observable=this.httpClient.post("https://localhost:44331/Patient/SubmitPatient", this.patientObj);
    
        observable.subscribe(res=> this.Success(res), res=> this.Error(res));
    }
    
    Success(res) {
        alert(res);
    }
    
    Error(res) {
        alert(res);
    }
}


Run Code Online (Sandbox Code Playgroud)

编辑 …

angular

0
推荐指数
1
解决办法
2万
查看次数