-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
I noticed when updating to v3 and using the package's internal types, undefined values passed to expand() result in an error. The current types do not reflect the actual behavior of the JavaScript code, which accepts null and undefined and converts it to an empty string (see test below). Updating the PrimitiveValue type to include undefined would fix this issue:
// proposed fix
export type PrimitiveValue = string | number | boolean | null | undefined;url-template/lib/url-template.d.ts
Lines 1 to 5 in ee27eb9
| export type PrimitiveValue = string | number | boolean | null; | |
| export interface Template { | |
| expand(context: Record<string, PrimitiveValue | PrimitiveValue[] | Record<string, PrimitiveValue | PrimitiveValue[]>>): string; | |
| } |
url-template/test/url-template-test.js
Lines 74 to 77 in ee27eb9
| test('expand variables that are undefined or null', () => { | |
| assert('{undef}', ''); | |
| assert('{null}', ''); | |
| }); |
Metadata
Metadata
Assignees
Labels
No labels