fix: change format of output .d.ts files

This commit is contained in:
hyper
2026-03-31 16:12:17 +08:00
parent 525ae262fd
commit d056145462
4 changed files with 35 additions and 61 deletions
+10 -17
View File
@@ -57,32 +57,25 @@ module.exports = {
`emitTypes: true` 时,loader 会自动生成 `.d.ts` 类型定义文件:
```typescript
// data.schema.d.ts
declare module "./data.schema.csv" {
export interface data_schema {
name: string;
age: number;
active: boolean;
scores: number[];
}
// data.csv.d.ts
type Table = {
name: string;
age: number;
active: boolean;
scores: number[];
}[];
export type RowType = data_schema;
const data: data_schema[];
export default data;
}
declare const data: Table;
export default data;
```
### Importing in TypeScript
```typescript
import data from './data.schema.csv';
import data from './data.csv';
// TypeScript 会自动推断类型:
// data: { name: string; age: number; active: boolean; scores: number[] }[]
// 如果启用了 emitTypes,也可以显式导入类型:
import type { RowType } from './data.schema.csv';
```
## Options