openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

DateTimeFormatterBuild.appendValue() 3 arguments: undefined must not be null #279

Closed m-jung closed 11 months ago

m-jung commented 11 months ago

Calling DateTimeFormatterBuild.appendValue() with 3 arguments results in an NullPointerException undefined must not be null

Expected Behavior

The Documentation / TypeScript Definitions should correspond with the actual behavior.

Current Behavior

js-joda.d.ts defines appendValue() with one required and three optional arguments: appendValue(field: TemporalField, width?: number, maxWidth?: number, signStyle?: SignStyle): DateTimeFormatterBuilder; But using three arguments results in an NullPointerException as the call delegates to _appendValues4(), which requires SignStyle as fourth argument.

Possible Solution

The TypeScript Definition should either state that one, two or four arguments are reuqired.

appendValue(field: TemporalField): DateTimeFormatterBuilder;
appendValue(field: TemporalField, width: number): DateTimeFormatterBuilder;
appendValue(field: TemporalField, width: number, maxWidth: number, signStyle: SignStyle): DateTimeFormatterBuilder;

or DateTimeFormatterBuilder should implement _appendValues3() taking three arguments.

Steps to Reproduce (for Bugs)

new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR, 3, 4)

Context

The intention was to build an formatter which allows to parse either three or four digit years.

Your Environment

The affected Version is @js-joda/core@5.5.3

florian-h05 commented 11 months ago

We cannot do anything about issues in upstream dependencies, please open an issue at the js-joda GitHub repo: https://github.com/js-joda/js-joda/issues.

florian-h05 commented 11 months ago

Once the bug is fixed upstream, please let me know so we can upgrade js-joda.

m-jung commented 11 months ago

Sorry, my bad. I've meant to open this issue for js-joda in the first place. For documentation, the same issue at js-joda: https://github.com/js-joda/js-joda/issues/689