reactjs - 使用 DTO 的接口时遇到问题
问题描述
我在全局级别有文件夹 dto 来保存我的界面,但是当我想在前端获取它时我遇到了问题。我导入 DTO 但不能从那里使用接口。
DTO
export namespace DTO {
export interface IUser {
id: number;
firstName: string;
lastName: string;
age: number;
country: string;
speaks: ILanguage[];
learn: ILanguage[];
isOnline: boolean;
isFriend: boolean;
photoUrl: string;
}
}
tsconfig
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"baseUrl": ".",
"paths": {
"dto": ["../dto/index"]
}
},
"include": ["src", "../dto"]
}
在 fontend 我得到它但不能使用
import { DTO } from 'dto';
export interface Test extends DTO.IUser
但有一个错误
Parsing error: ',' expected