typescript에서 import {..} from "./foo.js" 하기

김민석·2021년 6월 26일
0

typescript

목록 보기
3/4
import { Invoice } from './classes/Invoice.ts';

invoice라를 class를 import 한다고 가정

//Invoice.ts
export class Invoice {
  constructor(
    public client: string,
    readonly details: string,
    private amount: number
  ) {}

  format() {
    return `${this.client} owes $${this.amount} for ${this.details}`;
  }
}

import 할 땐 .js 확장자로 해주기.

컴파일 된 상태에서는 js를 import 할 것이기 때문이다..

0개의 댓글