-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
I have built some helper methods to help assemble instances in our common patterns. With the recent introduction of #47, and the fact that none of the Base
types are exposed (related: #29 (comment)), I no longer have a way to access/reuse the types of the properties within OrganizationBase
model.
With the latest release including #47, I get:
error TS2339: Property 'image' does not exist on type 'Organization'.
5 image: SchemaOrganizationNoRef['image'] | Identified
e.g.
import { Organization as SchemaOrganizationNoRef } from 'schema-dts'
import { Identified } from './Identified'
interface Reffed {
image: SchemaOrganizationNoRef['image'] | Identified
/**
* URL of a logo that is representative of the organization.
*
* Additional image guidelines:
*
* The image must be 112x112px, at minimum.
* The image URL must be crawlable and indexable.
* The image must be in .jpg, .png, or. gif format.
*/
logo: SchemaOrganizationNoRef['logo'] | Identified
}
/**
* Allow given properties to be refs
*/
type SchemaOrganization = Omit<SchemaOrganizationNoRef, keyof Reffed> & Reffed
interface Required {
address: SchemaOrganizationNoRef['address']
legalName: SchemaOrganizationNoRef['legalName']
name: SchemaOrganizationNoRef['name']
/**
* URL of the organization eg. https://google.com
*/
url: SchemaOrganizationNoRef['url']
}
/**
* Declare our `Organization` as a stricter set of properties
*
* @see https://schema.org/Organization
*/
export type Organization = Omit<SchemaOrganization, keyof Required> & Required & Identified
export const buildOrganization = (
o: Omit<Organization, '@id' | '@type'>,
uniqueName = 'organization',
): Organization => ({
// '@context': 'https://schema.org',
'@id': `${o.url}/#${uniqueName}`,
'@type': 'Organization',
...o,
})
for completeness:
export interface Identified {
/**
* preferably url e.g. https://alienfast.com/#organization
*/
'@id': string
}
export function ref<I extends Identified>(i: I): Identified {
return { '@id': i['@id'] }
}
How should I be referencing the declared type of something like Organization['image']
?
robert-gruner
Metadata
Metadata
Assignees
Labels
No labels