[英]Import sources within a group must be alphabetized. Typescript
So I have the Import sources within a group must be alphabetized. 因此,我必须按字母顺序在组中的“ 导入”源。 error in the following file:
以下文件中的错误:
login.view.tsx 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);
}
}
My tsconfig.json is the following: 我的tsconfig.json是以下内容:
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"
]
}
I tried to change the order of all the imports with results. 我试图更改所有导入结果的顺序。 Can anyone help me out?
谁能帮我吗?
This is not a typescript's error, but tslint's one. 这不是打字稿的错误,而是tslint的错误。 It wants you to rearrange the import statements in alphabetical order.
它希望您按字母顺序重新排列导入语句。
I think, like this (but I am not sure, so try different orders yourself): 我认为是这样的(但我不确定,因此请自己尝试其他命令):
import AbstractComponent from "../abstract-component";
import { IBaseProps } from "../../App";
import { LoginController } from "./login.view.controller";
import { UserService } from "../../services/user.service";
If nothing works, try tslint's auto fix command: 如果没有任何效果,请尝试tslint的自动修复命令:
tslint --fix
If you use VSCode, then put the cursor on the red-underlined statements and press ctrl + .
如果使用VSCode,则将光标放在带红色下划线的语句上,然后按
ctrl + .
, it will suggest auto fix. ,它将建议自动修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.