The type returned by extract seems to be thought as a discriminated union, but the way it's written, it doesn't actually work as one.
This means it for example is not possible to access the html property of a response with type: 'video', even after checking that the type is indeed 'video'.
import { extract } from '@extractus/oembed-extractor'
const data = await extract('https://vimeo.com/6428069');
switch(data.type) {
case 'video':
console.log(data.html)
break;
}
I also notice there's a lot of optional fields on all the types in this project. Would be good if they could be non-optional, so we don't have to constantly check whether something is there or not.
The type returned by
extract
seems to be thought as a discriminated union, but the way it's written, it doesn't actually work as one.This means it for example is not possible to access the
html
property of a response withtype: 'video'
, even after checking that thetype
is indeed'video'
.Exampe on TS Playground
I also notice there's a lot of optional fields on all the types in this project. Would be good if they could be non-optional, so we don't have to constantly check whether something is there or not.