Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
safu9 opened this issue Jun 28, 2022 · 2 comments
Open

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

safu9 opened this issue Jun 28, 2022 · 2 comments
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen

Comments

@safu9
Copy link

safu9 commented Jun 28, 2022

Versions

  • @kintone/dts-gen: 6.1.3
  • TypeScript: 4.7.4

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

  • Text (kintone.fieldTypes.SingleLineText)
  • Text Area (kintone.fieldTypes.MultiLineText)
  • Number (kintone.fieldTypes.Number)
  • Drop-down (kintone.fieldTypes.DropDown)
  • Date (kintone.fieldTypes.Date)
  • Time (kintone.fieldTypes.Time)
  • Date and time (kintone.fieldTypes.DateTime)
  • Link (kintone.fieldTypes.Link)

Fields that can be null

  • Rich Text (kintone.fieldTypes.RichText)

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
Copy link
Author

safu9 commented Jun 28, 2022

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

@tasshi-me tasshi-me added bug Something isn't working pkg: dts-gen @kintone/dts-gen labels Jun 30, 2022
@ueokande
Copy link
Member

ueokande commented Jul 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen
Projects
None yet
Development

No branches or pull requests

3 participants