Lint code change errors but not sure how to proceed

updated.

I updated the code like this, but still I get the following error

Error The  type 'String' is not assigned to the type 'string'. "string" is primitive, but "String" is a wrapper object. Prefer to use 'string' if possible

updated code

    public sportsService: string;

  constructor( sportsService: String) {
    this.sportsService = sportsService;
  }
  • I am new to tslint and typescript.
  • I am trying to fix this error. The "waterService" property cannot be declared in the constructor

  • the constructor occurs on this line (public sportsService: SPORTSService) {}

  • You can tell me how to fix it.

  • I did some research, but could not find a solution.
  • providing the code below.
  • even looked at this link and tried, but could not continue.

https://github.com/Microsoft/tslint-microsoft-contrib

'waterService'

/** Trees for contract and title. */
import {
  Component,
  Inject,
  OnInit,
  EventEmitter,
  ViewChild,
  Input,
  Output
}
from '@angular/core';
import {
  SPORTSService
}
from '../../services/sports.service';
import {
  KendoGridComponent
}
from '../grid/grid.component';
import {
  KendoDialog
}
from '../shared/kendoDialog/kendodialog';
import {
  ProgressCircle
}
from '../shared/progress/progress-circle';

declare let $: any;



@Component({
  selector: 'player',
  template: `<div id="windowcontainer"></div>`
})

export class player implements OnInit {

  private henInfoPopUpWindow;
  private airDate;
  private airTime;
  private showTitle;


  @Input() kendoCommandObj: any;




  constructor(public sportsService: SPORTSService) {}

  private kendocommand = {
    edit: {
      createAt: "bottom"
    },
    group: false,
    reorder: true,
    disableFreeze: true,
    resize: true,
    sort: true,
    autoBind: true,
    filter: false,
    pager: {
      messages: {
        //display: "Showing {0} to {1} of {2} entries"
      }
    },
    model: {},
    columns: [],
    pagesize: 50,
    getComponentUrl: "swimming",
    searchFields: [],
    mandatoryFields: [],
    saveStatus: false
  };


  @Output() applyAPTInfo: EventEmitter < any > = new EventEmitter < any > ();
  @Output('mouseCount') getTreeEvent = new EventEmitter<number>();

  ngOnInit() {
    this.mouseType = 'hen';
    let that = this;
    let attributes=this.sportsService.getSeesionStorageValue();
+4
2

TSLint , (.. accessor, public private).

"no-parameter-properties": true

-, , :

class Example {
    constructor(private name: string) {}
}

:

class Example {
    private name: string;
    constructor(name: string) {
        this.name = name;
    }
}

, TypeScript!

Fix

:

"no-parameter-properties": false

2

String . - TSLint, , String, number, boolean .., .

let x: String; // <-- interface String

let y: string; // <-- primitive type string

, JavaScript, , :

let x = 'A literal string value here'; // <-- literal

let y = new String('String object'); // <-- object
+2

Source: https://habr.com/ru/post/1686272/


All Articles