matrix-org / matrix-org/matrix-js-sdk

IPreviewUrlResponse in client.d.ts has invalid types

Open
#2,448 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.2k
Forks
704
Avg merge
1d 20h
Merged PRs (30d)
40

Description

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'.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the IPreviewUrlResponse declaration around line 305 of lib/client.d.ts and reproduce the reported TypeScript compiler error with the current declarations. Check the optional properties against the index signature and confirm that the declaration compiles without TS2411 in a consuming TypeScript project.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.