Error TypeScript TSLint - Type boolean trivially inferred from a boolean lit…
페이지 정보
본문
타입 스크립트에서 변수를 선언하면서 값을 할당하면 TSLint 경고가 발생합니다.
isVisibleFileName: boolean = false;
불리언(boolean) 타입을 지정하지 않아도 true 또는 false로 변수를 초기화하면 컴파일러가 타입을 유추할 수 있게됩니다. 그래서 타입(int, double, string, boolean...)을 지정하지 않아도 됩니다. 이 코드를 아래와 같이 변경하면 TSLint에서 경고를 발생시키지 않습니다. 아무래도, TSLint에서 가이드하는데로 코딩하는게 좋겠죠^^;
isVisibleFileName = false;
참고로, tslint.json에 아래와 같이 추가해주면 경고를 회피할 수 있습니다.
"no-inferrable-types": [true]
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "mia", "camelCase"],
"component-selector": [true, "element", "mia", "kebab-case"],
"no-inferrable-types": [true]
},
"linterOptions": {
"exclude": ["!**/*"]
}
}
추천0 비추천0
- 이전글pgAdmin에서 조회한 결과를 복사할 때 헤더를 포함하는 방법. (Query results grid copy header - PostgreSQL) 22.01.06
- 다음글Can't bind to 'ngModel' since it isn't a known property of 'input'. 22.01.04
댓글목록
등록된 댓글이 없습니다.