Lợi ích của tính năng ‘import’ trong TypeScript là gì?

{{FormatNumbertoThousand(model.total_like)}} lượt thích
135 lượt xem
Typescript master
  • import cho phép chúng ta chuyển thông tin bổ sung nội dòng (additional information inline), trong câu lệnh import module.
  • Đây là một cú pháp được sử dụng bởi runtime để đảm bảo rằng một lần import có định dạng mong đợi.

Lưu ý: Tính năng này hoạt động với cả normal importdynamic import.

// normal import
import json from "./myModule.json" assert { type: "json" };

// dynamic import
import("myModule1.json", { assert: { type: "json" } });
{{login.error}}