为什么 React 不使用接口编译我的本地模块?

Why does React not compile my local module with an Interface?

我有一个由 React 和后端模块使用的共享模块。它包含两个文件:index.tspackage.json.

Package.json

{
  "name": "app-shared",
  "version": "1.0.0",
  "license": "ISC"
}

index.ts 中只有导出接口,如下所示:

export interface Student extends StudentDto {
    ref: any;
    id: string;
    areAllPaid: boolean;
}

我已经安装在我的React应用中,可以导入界面了。但是当我 运行 React 应用程序出现以下编译错误时:

Failed to compile.

../shared/index.ts 4:7
Module parse failed: Unexpected token (4:7)
File was processed with these loaders:
 * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
You may need an additional loader to handle the result of these loaders.
| $RefreshSetup$(module.id);
| 
> export interface Student extends StudentDto {
|     ref: any;
|     id: string;

这个问题与 webpack 有关,但在我的 Git 仓库中没有任何地方是 webpack 配置文件。我也在其他模块中使用这个共享模块并且它工作正常。

我认为共享模块需要更多代码才能与 Webpack 和 React 一起工作。我错过了什么?

文件名必须是index.d.ts