모듈인
a.ts와b.ts가 동일한 이름의 변수인 shared을 내보내지만 문제 되지 않는다.
모듈인c.ts는 가져온 shared 변수와 c.ts에서 직접 정의한 shared의 변수 이름이 같기 때문에 충돌해서 변수재정의 오류가 발생한다.// a.ts export const shared = "Cher"; // b.ts export const shared = "Cher"; // c.ts import { shared } from "./a"; export const shared = "Cher"; // a.ts에서 shared를 import해서 이미 존재하는 변수이기 때문에 오류 발생
스크립트인
a.ts와b.ts는 동일한 파일에 동일한 이름의 변수가 선언된 것처럼 충돌하게 된다.// a.ts // cannot redeclare block-scoped variable 'shared' const shared = "Cher"; // cannot redeclare block-scoped variable 'shared' // b.ts const shared = "Cher";