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:
+14
-11
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user