(a.ts)
export var 이름 = 'kim';
export var 나이 = 30;
(b.ts)
import {이름, 나이} from './a'
console.log(이름)
TypeScript에서도 자바스크립트처럼 export/import를 사용할 수 있다.
import * from './a';
console.log(이름);
console.log(나이);
물론 *을 사용해서 다 가져오는 것도 가능하다.
(a.ts)
export type Name = string | boolean;
export type Age = (a :number) => number;
(b.ts)
import {Name, Age} from './a'
let 이름 :Name = 'kim';
let 함수 :Age = (a) => { return a + 10 }
type 또한 가져오는 것이 가능하다.