Skip to content

Add any desired non-function type alias uses to core libraries. #44967

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

Closed
leafpetersen opened this issue Feb 11, 2021 · 9 comments
Closed

Add any desired non-function type alias uses to core libraries. #44967

leafpetersen opened this issue Feb 11, 2021 · 9 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. language-nonfunction-type-aliases Issues related to non-function type aliases P2 A bug or feature request we're likely to work on

Comments

@leafpetersen
Copy link
Member

This issue tracks support of the non-function type alias feature. See the enclosing meta-issue for details.

@lrhn anything we want to do here?

cc @franklinyow @lrhn @natebosch @mit-mit

@lrhn
Copy link
Member

lrhn commented Feb 11, 2021

I'd love typedef any = Object?; in dart:core. Should probably be Any to avoid conflicts, though.

We could defined typedef JsonMap = Map<String, Object?>;, maybe also typedef JsonList = List<Object?>;.

Other than that, I'm not sure there's anything which belongs in the platform libraries.

(Other people have requested capitalized Int and Bool, others have requested lower-case string. Not something I think we should do in the platform libraries).

@lrhn
Copy link
Member

lrhn commented Feb 12, 2021

Does anybody else have an idea for a typedef that would belong in the core platform libraries (core, async, convert, collection, math or typed_data)?

I'll collect ideas here (no promises to actually add them):

  • typedef Any = Object?; in dart:core. (Probably the only "shorthand" we'll allow for a type which is already easy to write).
  • typedef JsonMap = Map<String, Object?>; typedef JsonList = List<Object?>; in dart:convert.
  • Alternative: typedef JsonMap<T extends Object?> = Map<String, T>;. That will allow you to write JsonMap<JsonMap<JsonList>>. Probably not worth it.
  • typedef Int = int; typedef Double = double; typedef Num = num; typedef Bool = bool; in dart:core (for consistency).
  • typedef string = String; in dart:core (for a different kind of consistency).
  • typedef Nullable<T> = T?; (for people who like C#).

@eernstg eernstg added the language-nonfunction-type-aliases Issues related to non-function type aliases label Feb 23, 2021
@mit-mit mit-mit added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Feb 24, 2021
@franklinyow
Copy link
Contributor

Do we know how much work we're doing here?

@franklinyow franklinyow added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Mar 25, 2021
@leafpetersen
Copy link
Member Author

I think nothing is planned here.

@mit-mit
Copy link
Member

mit-mit commented Mar 30, 2021

@leafpetersen not even typedef JsonMap = Map<String, Object?>; typedef JsonList = List<Object?>; in dart:convert ?

That one seemed obvious. But I could be missing something?

@mit-mit mit-mit reopened this Mar 30, 2021
@natebosch
Copy link
Member

The JsonMap and JsonList typedefs do add some clarity, I don't feel strongly one way or the other on adding those in dart:convert. I would push back against the other proposals in this thread. If anyone wants to feel like they are writing C# I would prefer that they publish a package with Nullable<T> and whichever capitalizations of the core types make sense to them. @lrhn - do you feel strongly one way or the other on the Json types?

@lrhn
Copy link
Member

lrhn commented Mar 30, 2021

I personally don't care about JsonX types. I'd like the Any type, but that's the only one I'd use myself.
There has been absolutely no visible interest about any of these types, so I'm fine with doing nothing.

@franklinyow franklinyow added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Mar 30, 2021
@franklinyow
Copy link
Contributor

Lowering this to P2 per discussion above. Seems like a borderline p2 or p3 issue

@natebosch
Copy link
Member

@mit-mit - I don't think we're likely to get any clear consensus on these to the point where we'd take action. Should we close again?

@leafpetersen leafpetersen removed this from the March Beta Release milestone Apr 1, 2021
@mit-mit mit-mit closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. language-nonfunction-type-aliases Issues related to non-function type aliases P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

6 participants