1
프로젝트에서 작업하고 타이프 스크립트로 다음을 수행하는 개발자를 봅니다.클래스는 언제 인터페이스를 구현해야합니까?
export class Ledger implements ILedger {
LedgerID: number;
CashAmmount: number;
Units: number;
public static someFunction {
// an ajax call for example to a controller
}
}
export interface ILedger {
LedgerID: number;
CashAmmount: number;
Units: number;
}
올바른 방법 일 경우 궁금합니다. 클래스에 구현이 없으면 무의미한 것처럼 보입니다. 그런 다음 React 구성 요소에는 인터페이스 또는 때때로 클래스에 대한 참조가 있습니다. 몇 가지 규칙을 설정하고 싶지만이 상황에서 적절한 관행이 무엇인지에 대한 도움을 원했습니까?