타입스크립트 에러 사전'implicitly has any type' 라고 떠요“매개변수에 빨간 줄”
메뉴판 › 타입스크립트 에러 사전 › 타입을 몰라서 any › 'this implicitly has type any' 라고 떠요
error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
전
class C {
v = 1;
m() { return function() { return this.v; }; }
}후
class C {
v = 1;
m() { return () => this.v; }
}왜 이렇게 되나
- 일반 function 안의 this 는 타입이 없어 any 로 막힌다
됐는지 보는 법
this 가 의도한 객체를 가리키고 빨간 줄이 없으면 성공.
같은 묶음 · 타입을 몰라서 any
타입스크립트 에러 사전 · 타입을 몰라서 any