Ts支持和JS一样的导出语法 主要是 ES模块
// @filename: animal.tsexport type Cat = { breed: string; yearOfBirth: number };export interface Dog {breeds: string[];yearOfBirth: number;}// @filename: app.tsimport { Cat, Dog } from "./animal.js";type Animals = Cat | Dog
// @filename: animal.tsexport type Cat = { breed: string; yearOfBirth: number };// 'createCatName' cannot be used as a value because it was imported using 'import type'.export type Dog = { breeds: string[]; yearOfBirth: number };export const createCatName = () => "fluffy";// @filename: valid.tsimport type { Cat, Dog } from "./animal.js";export type Animals = Cat | Dog;// @filename: app.tsimport type { createCatName } from "./animal.js";const name = createCatName();
// @filename: app.tsimport { createCatName, type Cat, type Dog } from "./animal.js";export type Animals = Cat | Dog;const name = createCatName();
