-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
概要
KintoneFormFieldProperty.Lookup のフィールド lookup は本当は nullable なのに TypeScript の型が nonnullable になっています。
export type Lookup = {
type: "NUMBER" | "SINGLE_LINE_TEXT";
code: string;
label: string;
noLabel: boolean;
required: boolean;
lookup: { // 本当は null もありうる
relatedApp: {
app: string;
code: string;
};
relatedKeyField: string;
fieldMappings: Array<{ field: string; relatedField: string }>;
lookupPickerFields: string[];
filterCond: string;
sort: string;
};
};ドキュメントによると lookup は null の場合がありますし、実際 null のデータが得られることがありました。
ルックアップフィールドの設定
参照先のアプリにレコード閲覧権限、レコード追加権限、アプリ管理権限のいずれもない場合は「null」が返ります。
https://cybozu.dev/ja/kintone/docs/rest-api/apps/form/get-form-fields/
null の可能性があるのであれば、 TypeScript の型もそうなっているべきです。
我々が開発しているアプリケーションで、 lookup が null であることでエラーが起きました。
型が正しければ未然にエラーが防げたかもしれません。
対象パッケージ
@kintone/rest-api-client
対象バージョン
5.7.0
再現手順
@kintone/rest-api-client を TypeScript で使えば影響を受けます。
期待する挙動
lookup フィールドが nullable になっていることを期待します。
実際の挙動
lookup フィールドが nullable でないので、型が正しいことを期待して書いたコードでエラーが発生しました。
環境
環境に依存しないと思いますが一応書いておきます。
System:
OS: Linux 6.12 Manjaro Linux
CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
Memory: 11.88 GB / 31.26 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 20.12.2 - ~/.anyenv/envs/nodenv/versions/20.12.2/bin/node
Yarn: 1.22.22 - ~/.anyenv/envs/nodenv/versions/20.12.2/bin/yarn
npm: 10.5.0 - ~/.anyenv/envs/nodenv/versions/20.12.2/bin/npm
pnpm: 9.5.0 - ~/.anyenv/envs/nodenv/versions/20.12.2/bin/pnpm
npmPackages:
@kintone/rest-api-client: ^5.6.0 => 5.7.0
typescript: ^5.6.3 => 5.7.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working