import type 与 import 的区别

287 阅读1分钟

import type 与 import 的区别

TypeScript 3.8

import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there’s no remnant of it at runtime.

import type 是用来协助进行类型检查和声明的,在运行时是完全不存在的。