728x90 TypeScriptPatterns1 Builder 패턴을 적용한 JS 객체 배열 (with typescript) Enum과 string 으로 구성된 객체가 있을때 interface 를 다음과 같이 정의할 수 있다. enum Fruit { APPLE = 'APPLE', BANANA = 'BANANA', } interface MyInterface { A: string; B: string; fruit: Fruit; } 아래와 같은 방식으로 객체를 선언할 수 있다. import { MyInterface, Fruit } from './MyInterface'; const myObject: MyInterface = { A: 'Hello', B: 'World', fruit: Fruit.APPLE, }; console.log(myObject); Builder 패턴을 적용하여 MyInterface 객체 배열을 생성하려면 아래와 같이.. 2023. 4. 6. 이전 1 다음 728x90