Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use array shorthand syntax #33135

Closed
dannyskoog opened this issue Oct 14, 2019 · 9 comments
Closed

Use array shorthand syntax #33135

dannyskoog opened this issue Oct 14, 2019 · 9 comments
Labels
area: core Issues related to the framework runtime feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Milestone

Comments

@dannyskoog
Copy link
Contributor

馃殌 feature request

Relevant Package

All

Description

Typescript offers 2 array syntax:

Shorthand: T[] (read only variant readonly T[])
Generic: Array<T> (read only variant ReadonlyArray<T>)

Currently we're using both, although the shorthand has a HUGE majority in the code-base. And since I'm a big fan of unification it would be preferable to settle for just one of them - specifically for the shorthand one IMHO.

Shorthand pros:

  • It's by far the most used syntax (of the two) throughout the code-base
  • It's shorter to write
  • It's similar to many other programming languages' syntax
  • It doesn't change type when made read only (by utilizing Typescript's readonly keyword)

Describe the solution you'd like

Add TS lint rules that enforce usage of the shorthand:

"array-type": [
  true,
  "array"
],
"ban-types": [
  true,
  [
    "ReadonlyArray<.+>",
    "Use 'readonly T[]' instead."
  ]
],

Describe alternatives you've considered

Keep using both

@santoshyadavdev
Copy link
Contributor

For adding rules , you can add this feature request in https://github.com/mgechev/codelyzer

@dannyskoog
Copy link
Contributor Author

@santoshyadav198613 this issue is for Angular's internal source code, not external consumers' ones

@mhevery mhevery added feature Issue that requests a new feature area: core Issues related to the framework runtime labels Oct 14, 2019
@ngbot ngbot bot added this to the Backlog milestone Oct 14, 2019
@MrJithil
Copy link
Contributor

Hi @dannyskoog ,
This is not the feature provided by Angular. The TypeScript providing both the ways to declare the array.

To unifying these, please consider to raise a feature request in TypeScript.

@mhevery, Please consider closing the issue, if the above answer sounds relevant.

Disclaimer : in my perspectives, it is good to have multiple ways to declare an array

@dannyskoog
Copy link
Contributor Author

dannyskoog commented Oct 17, 2019

@MrJithil thanks. And I鈥檓 very well aware of everything you鈥檙e saying.

The purpose of this issue is to discuss whether we are interested in unifying the array syntax throughout the Angular codebase or not.

And the feature issue template was just the most suitable one out of all available templates :)

Given that, I still think it brings value to keep this one open a little longer in order for people to get the chance to chip in.

@dannyskoog
Copy link
Contributor Author

@mhevery Given the low activity of this issue I believe it's reasonable to close it. What do you think?

@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 24, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Jun 24, 2021
@pkozlowski-opensource pkozlowski-opensource added core: binding & interpolation Issue related to property/attribute binding or text interpolation and removed core: binding & interpolation Issue related to property/attribute binding or text interpolation labels Jul 20, 2021
@petebacondarwin
Copy link
Member

Closing as this request is just to change the typings of the internal code base for Angular - it has no impact on external application developers - and there is not much value in constraining this way of defining arrays.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

6 participants