kintone / js-sdk

A monorepo for Kintone development tools :wrench:
MIT License
117 stars 54 forks source link

Type definitions of field values in dts-gen is not accurate #1593

Open safu9 opened 2 years ago

safu9 commented 2 years ago

Versions

Current Behavior

Types of some field values are defined as string, but can be undefined according to the document. Also we are allowed to assign null to the fields.

Fields that can be undefined and null

Fields that can be null

Expected Behavior

Types of these field values shoud be defined as string | undefined | null or string | null, not string.

Steps to reproduce the issue

When strict option in tsconfig is true, this code should not have any error, but do.

const field : kintone.fieldTypes.SingleLineText = { value: null };

This code should have a error at value.trim(), but don't.

const trimedValue = field.value.trim();
safu9 commented 2 years ago

If needed, I will cretae a PR for this issue.

ueokande commented 2 years ago

@safu9 Thank you for your reporting. Replacing a type string to string | null can occur a breaking change, as SDK users must introduce a null-check before getting a value. Our team will consider the directionality of implementation.

Thank you.