zikaari / aspen-decorations

Styling engine for Aspen
MIT License
2 stars 1 forks source link

Can't call getDecorations on NewFilePromptHandle and friends #14

Closed LoganDark closed 3 years ago

LoganDark commented 3 years ago

The TypeScript compiler is preventing me from calling decorationsManager.getDecorations(itemRendererProps.item) because it's an intersection that includes more than just FileEntry | Directory. Maybe you should expand the definition of getDecorations, if it supports those, or just document the fact that getDecorations doesn't support those (if it doesn't, of course).

LoganDark commented 3 years ago

Had to read the source to discover that the typings are in fact correct. Would be nice if this were documented as TypeScript prevents people from using the examples verbatim

zikaari commented 3 years ago

Yes, prompt handles do not support decorations.

because it's an intersection that includes more than just FileEntry | Directory

Do you mean you get red squiggly lines and you're having to typecast it as FileEntry | Directory?

LoganDark commented 3 years ago

Do you mean you get red squiggly lines and you're having to typecast it as FileEntry | Directory?

Yes to the first part and no to the second part. I don't make type casts that aren't valid, so I'm just checking itemType and not calling getDecorations unless it's ItemType.File or ItemType.Directory.

Yes, prompt handles do not support decorations.

This should be documented.

zikaari commented 3 years ago

This library itself is agnostic of any concept except for Directory and FileEntry, especially prompt handles since that is strictly a "UI" concept that lives within react-aspen.

The fact that you got red squiggly lines telling you that Parameter of type xyz is not assignable to type Directory | FileEntry is documentation in itself. It is essentially letting you know about what is supported and what is not right on-the-fly.

Also, in the next major release of react-aspen (in about a month or 2), prompt handles will be re-worked, so this might just not be relevant then.

LoganDark commented 3 years ago

The fact that you got red squiggly lines telling you that Parameter of type xyz is not assignable to type Directory | FileEntry is documentation in itself. It is essentially letting you know about what is supported and what is not right on-the-fly.

Then I guess this issue will be documentation if anyone in the future is curious about this.