반응형
TypeScript 인터페이스 구성 방법
인터페이스 정의를 타이프 스크립트로 정리하는 권장 방법을 알고 싶습니다.내 프로젝트에서 나는 많은 다른 수업을 듣는다.각 클래스에는 컨피규레이션인터페이스를 설정할 수 있습니다.현재 이 모든 인터페이스 정의를 1개의 파일로 수집했습니다.Interfaces.ts
다양한 장소에서 파일을 참조합니다.
더 좋은 방법이 있을까요?
예: https://github.com/blendsdk/blendjs/blob/devel/blend/src/common/Interfaces.ts
세계적인
TypeScript 팀은 다음과 같은 파일을 사용합니다.types.ts
: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/types.ts
프로젝트(https://github.com/alm-tools/alm/blob/master/src/common/types.ts 등)에서도 같은 작업을 하고 있습니다.
대안
재사용률이 높은 부분이 속하는 것은 괜찮습니다.types
단, 특정 유형으로 오염시키지 마십시오.특정 유형은 참조에 더 가까울 수 있습니다. 예를 들어 반응 스타일 소품이 반응 구성요소 옆에 속합니다(같은 파일에 속함).
리액트 컴포넌트 프로펠러 타입 / 리액트 컴포넌트
앱의 구성은 다음과 같습니다.
|-- app
|-- components
|-- directives
|-- services
|-- interfaces
|-- <feature/component name>
|-- <interface name>.interface.ts
내 프로젝트는 이렇게 구성되어 있다.
src/
└── ts
├── enums
│ ├── app_enums.ts
│ └── db_enums.ts
├── interfaces
│ ├── app_interfaces.ts
│ ├── db_interfaces.ts
│ └── global_interfaces.ts
└── types
└── app_types.ts
언급URL : https://stackoverflow.com/questions/36633033/how-to-organize-typescript-interfaces
반응형
'source' 카테고리의 다른 글
system.net을 사용하여 json 응답을 얻는 방법.웹 요청은 c#에 있습니까? (0) | 2023.02.10 |
---|---|
클릭 시 앵글을 사용하여 텍스트 입력 지우기JS (0) | 2023.02.10 |
JSON 개체에서 날짜를 가져오는 방법 (0) | 2023.02.10 |
Chrome이 잘못된 MIME 유형으로 인해 AJAX 스크립트 실행을 거부함 (0) | 2023.02.10 |
WordPress의 "wp_nav_menu" 서브메뉴에서 클래스 및 요소를 태그에 추가하는 방법 (0) | 2023.02.10 |