fix: use declare module syntax for type definitions

- Change from standalone .d.ts to module augmentation style
- Now properly declares types for the CSV module path
- Fixes TypeScript module resolution

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
hyper
2026-03-31 15:25:58 +08:00
co-authored by Qwen-Coder
parent 69b419256c
commit 452b600487
2 changed files with 26 additions and 20 deletions
+14 -11
View File
@@ -57,17 +57,19 @@ module.exports = {
```typescript
// data.schema.d.ts
export interface data_schema {
name: string;
age: number;
active: boolean;
scores: number[];
declare module "./data.schema.csv" {
export interface data_schema {
name: string;
age: number;
active: boolean;
scores: number[];
}
export type RowType = data_schema;
const data: data_schema[];
export default data;
}
export type RowType = data_schema;
declare const data: data_schema[];
export default data;
```
### Importing in TypeScript
@@ -79,7 +81,8 @@ import data from './data.schema.csv';
// data: { name: string; age: number; active: boolean; scores: number[] }[]
// 如果启用了 emitTypes,也可以显式导入类型:
// import type { RowType } from './data.schema.csv';
import type { RowType } from './data.schema.csv';
```
## Options