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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TS Utility Types #90

Open
giffeler opened this issue Jan 19, 2022 · 2 comments
Open

Support TS Utility Types #90

giffeler opened this issue Jan 19, 2022 · 2 comments

Comments

@giffeler
Copy link

giffeler commented Jan 19, 2022

TypeScript provides several utility types to facilitate common type transformations. These utilities are available globally.

interface Todo {
  title: string;
  description: string;
  completed: boolean;
  createdAt: number;
}

class MyTodo implements omit<Todo, "createdAt"> {
…
}

Utility Types should be considered in the presentation of the class diagrams. Currently, they are incorrectly listed as independent instances.

@adrian-burlacu-software
Copy link
Contributor

adrian-burlacu-software commented Apr 15, 2022

Agreed. I took a look at the page: https://www.typescriptlang.org/docs/handbook/utility-types.html

The first three are somewhat OK -- i.e. Partial, Required, Readonly but the text description lacks the actual utility type. After Record<Keys, Type> it gets muddy what should or should not happen.

Mostly an issue with Utility types that have 2 type parameters -- i.e. why did the TS API even not reverse this Record<Keys, Type> to be Record<Type, Keys>.
Again, the single parameter Utility types need to specify their text better: some come out any, unknown or the parameter type.

@adrian-burlacu-software
Copy link
Contributor

adrian-burlacu-software commented Apr 15, 2022

@bafolts
I would actually treat this as a bug than an enhancement because it doesn't respect the JavaScript coding API.
My suggestion is to create a Components.Type class, move the Type.Filename property there, and nest them.

I might look into fixing this later this year when I get a chance.
Also, I'm wondering if maybe it would help to possibly generate and load the typings .d.ts files to do all this analysis...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants