所以我有一个 组中的导入源必须按字母顺序排列。 以下文件中的错误:
login.view.tsx
import AbstractComponent from "../abstract-component";
import { LoginController } from "./login.view.controller";
import { UserService } from "../../services/user.service";
import { IBaseProps } from "../../App";
export interface ILoginProps extends IBaseProps {
userService?: UserService;
}
class Login extends AbstractComponent<ILoginProps, object> {
private loginController: LoginController;
constructor(public props: Readonly<ILoginProps>) {
super(props);
this.loginController = new LoginController(this, props);
}
}
我的tsconfig.json是以下内容:
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src"
},
"rules": {
"ordered-imports": [
false
]
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
]
}
我试图用结果更改所有导入的顺序。有人可以帮我吗?
答案 0 :(得分:0)
这不是打字稿的错误,而是tslint的错误。它希望您按字母顺序重新排列导入语句。
我认为是这样(但我不确定,因此请自己尝试其他命令)
public function show(House $house)
{
return view('house.show', compact('house'));
}
如果没有任何效果,请尝试tslint的自动修复命令:
import AbstractComponent from "../abstract-component";
import { IBaseProps } from "../../App";
import { LoginController } from "./login.view.controller";
import { UserService } from "../../services/user.service";
如果使用VSCode,则将光标放在带红色下划线的语句上,然后按tslint --fix
,将建议自动修复。