You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Realized how to use this in my own projects recently, and now I see that this is what I was looking for a while back to have for the DataTransferItem type. It's API is set up to work great with discriminated unions, but for some reason the standard library doesn't discern the different values against the kind property, while it does mention it in the JSDoc comments also.
I made a demo to try and add this functionality myself, but the types don't seem to apply for some reason. It might be that I'm trying to re-assign DataTransferItem with a type declaration instead of an interface one, I'm not completely sure. Either way, this is essentially the shape of what it would look like to enable the discriminated union checking using the kind attribute on the DataTransferItem object.
The base type definitions for DataTransfer and it's related APIs are in the DOM API types lib (lib.dom.d.ts), so I think it also may not be applying because of that, since I'm using declare global {} to wrap my custom types. I haven't tried overriding types in other lib definitions yet, so I think it also could be that.
The text was updated successfully, but these errors were encountered:
Added some more established function return types, and looked into additional type checking capabilities for the `DataTransferItem` type.
BenjaminAster/Better-TypeScript#3
Had the Service Worker TypeScript-ready again, but realized that would be a bit too much to change all at once, and I didn't want to implement too many things to where it would break something unexpectedly again.
I don't really think it's possible to completely reassign existing types and interfaces in TypeScript; at least not without causing some error messages in either lib.dom.d.ts or in the custom ones. If you can somehow get it to work, show me and I can add it to Better-TypeScript.
Currently TypeScript doesn't have a way to distinguish between if a `DataTransferItem` has a file or a string (at the type level). This is my proper fallback to get this behavior working.
It doesn't seem to be possible to override the types from `lib.dom.d.ts`, is it?
BenjaminAster/Better-TypeScript#3
Realized how to use this in my own projects recently, and now I see that this is what I was looking for a while back to have for the
DataTransferItem
type. It's API is set up to work great with discriminated unions, but for some reason the standard library doesn't discern the different values against thekind
property, while it does mention it in the JSDoc comments also.I made a demo to try and add this functionality myself, but the types don't seem to apply for some reason. It might be that I'm trying to re-assign
DataTransferItem
with atype
declaration instead of aninterface
one, I'm not completely sure. Either way, this is essentially the shape of what it would look like to enable the discriminated union checking using thekind
attribute on theDataTransferItem
object.https://basarat.gitbook.io/typescript/type-system/discriminated-unions
The base type definitions for
DataTransfer
and it's related APIs are in the DOM API types lib (lib.dom.d.ts
), so I think it also may not be applying because of that, since I'm usingdeclare global {}
to wrap my custom types. I haven't tried overriding types in other lib definitions yet, so I think it also could be that.The text was updated successfully, but these errors were encountered: