Closed LoganDark closed 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
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
?
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.
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.
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.
The TypeScript compiler is preventing me from calling
decorationsManager.getDecorations(itemRendererProps.item)
because it's an intersection that includes more than justFileEntry | 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).