-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
array-type configuration differs from Visual Studio Code preview #25
Comments
I agree that the first one is nicer. The point of the rule was to prevent things like |
I tend towards using extra types if unions are more complex. Thinking about that maybe a rule for disallowing non plain unions would be better than a specific array-type based on their content? type A = string | string[]
type B = Array<A>
type C = readonly A[] And this would be disallowed as the unions are not at the top level type B = Array<string | string[]>
type C = readonly (string | string[])[] Maybe this could be configurable to allow union of simple types like this: There is no rule like that currently existing nor an issue suggesting such rule. |
That’s what the array-simple config does exactly: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/array-type.md XO’s config already uses array-simple so if it still doesn’t work correctly it should be reported to TS-ESLint. It’s not something XO can fix anyway. |
The preview in Visual Studio Code automatically uses
readonly T[]
overReadonlyArray<T>
.When looking on Previews of functions and parameters I get familiar with this style of writing parameters. The current rules want me to write a different style.
I havnt looked into Visual Studio Codes Preview Logic or why they do it that way. I only want to start a discussion about it.
These two following methods are accepting the same parameter but the preview of these is the same. The first one produces this xo error:
Array type using T[] is forbidden for non-simple types. Use Array<T> instead. @typescript-eslint/array-type
What are other opinions about changing the rule
array-type
towards simple arrays?The text was updated successfully, but these errors were encountered: