matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

IPreviewUrlResponse in client.d.ts has invalid types

Open Half-Shot opened this issue 3 years ago • 1 comments

The current (18.1.0) exported types for the interface are as follows:

export interface IPreviewUrlResponse {
    [key: string]: string | number;
    "og:title": string;
    "og:type": string;
    "og:url": string;
    "og:image"?: string;
    "og:image:type"?: string;
    "og:image:height"?: number;
    "og:image:width"?: number;
    "og:description"?: string;
    "matrix:image:size"?: number;
}

However, the undefined values do not satisfy the index constraint which leads to Typescript complaining that:

node_modules/matrix-js-sdk/lib/client.d.ts:305:5 - error TS2411: Property '"og:image:type"' of type 'string | undefined' is not assignable to 'string' index type 'string | number'.

Half-Shot avatar Jun 10 '22 11:06 Half-Shot

Cannot reproduce this on replit

https://replit.com/@t3chguy/WhimsicalAnxiousLinks#index.ts

t3chguy avatar Jun 13 '22 13:06 t3chguy