Typescript error with Model

オープン
#9,444 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
28/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
typescript

調査の方向性

まず、Where の TypeScript 定義と、例で使用されているリポジトリの find エントリーポイントを追跡し、ネストされた配列プロパティがどのように表現されているかに注目します。意図されたクエリの動作を確認し、示されている "urls.id" 条件の回帰テストを追加します。完了条件は、サポート対象のクエリが報告されたエラーなしで型チェックを通ることです。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the bug

I am getting type error in find function.

@model({settings: {strict: false}})
export class URLS extends Model {
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  id?: string;

  @property({
    type: 'string',
    required: true,
  })
  title: string;
}

@model({settings: {strict: false}})
export class Links extends Entity {
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  id?: string;

  @property({
    type: 'array',
    itemType: 'object',
  })
  urls?: URLS[]
}

Error occurring in below

await this.linksRepository.find({
    where: {
        "urls.id": id
    }
})

Error:

Type '{ "urls.id": any; }' is not assignable to type 'Where<Links> | undefined'.
  Object literal may only specify known properties, and '"urls.id"' does not exist in type 'Where<Links>'.
Logs

No response

Additional information

No response

Reproduction

NA

主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
1日 23時間
マージ済み PR(30日)
44

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

loopbackio/loopback-next のほかの issue

loopbackio/loopback-next の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。