From fc57ab394984115648d921a7c4088e2663bfb54b Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Sun, 1 Oct 2023 12:08:42 +0200 Subject: [PATCH] feat: typed redirects on entities --- src/types/entity.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/types/entity.ts b/src/types/entity.ts index 04923350..b76d3381 100644 --- a/src/types/entity.ts +++ b/src/types/entity.ts @@ -31,12 +31,11 @@ export type GuidAltSyntax = `${EntityId|Lowercase}-${string}` export type Hash = string -export type Entity = (Property | Item | Lexeme | MediaInfo) +export type Entity = Property | Item | Lexeme | MediaInfo export type EntityPageTitle = NamespacedEntityId | ItemId export type Entities = Record -export interface Property extends EntityInfo { - id: PropertyId, +export interface Property extends EntityInfo { type: 'property' datatype?: DataType labels?: Labels @@ -45,8 +44,7 @@ export interface Property extends EntityInfo { claims?: Claims } -export interface Item extends EntityInfo { - id: ItemId, +export interface Item extends EntityInfo { type: 'item' labels?: Labels descriptions?: Descriptions @@ -55,8 +53,7 @@ export interface Item extends EntityInfo { sitelinks?: Sitelinks } -export interface Lexeme extends EntityInfo { - id: LexemeId, +export interface Lexeme extends EntityInfo { type: 'lexeme' lexicalCategory: ItemId language: ItemId @@ -66,21 +63,21 @@ export interface Lexeme extends EntityInfo { senses?: Sense[] } -export interface MediaInfo extends EntityInfo { - id: MediaInfoId, +export interface MediaInfo extends EntityInfo { type: 'mediainfo' labels?: Labels descriptions?: Descriptions statements?: Claims } -export interface EntityInfo { +export interface EntityInfo { pageid?: number ns?: number title?: string lastrevid?: number modified?: string - redirects?: { from: string, to: string } + redirects?: { from: T; to: T } + id: T } export interface SimplifiedEntityInfo { @@ -100,7 +97,7 @@ export interface SimplifiedItem extends SimplifiedEntityInfo { export interface SimplifiedProperty extends SimplifiedEntityInfo { type: 'property' - datatype: DataType, + datatype: DataType labels?: SimplifiedLabels descriptions?: SimplifiedDescriptions aliases?: SimplifiedAliases