Open haihovu opened 7 months ago
We use @balena/odata-parser in one of our projects, and the transpiler tsc is complaining about these:
tsc
node_modules/@balena/odata-parser/odata-parser.d.ts:57:2 - error TS2411: Property '$select' of type 'SelectOption | undefined' is not assignable to 'string' index type 'string | number | boolean | NumberBind | BooleanBind | TextBind | DateBind | { properties: PropertyPat h[]; } | ExpandOption | OrderByOption | { ...; }'. 57 $select?: SelectOption; ~~~~~~~ ...
Looking at odata-parser.d.ts I can see that ODataOptions was defined as:
odata-parser.d.ts
ODataOptions
export interface ODataOptions { $select?: SelectOption; $filter?: FilterOption; $expand?: ExpandOption; $orderby?: OrderByOption; $top?: number; $skip?: number; $count?: boolean; $inlinecount?: string; $format?: FormatOption; [key: string]: // User defined options, do not start with $ or @ | string // Parameter aliases (start with @) | NumberBind | BooleanBind | TextBind | DateBind // known $ options | SelectOption | ExpandOption | OrderByOption | FormatOption | number | boolean; }
Note that all properties are optional, and as such the part below should include a undefined as follows:
undefined
export interface ODataOptions { $select?: SelectOption; $filter?: FilterOption; $expand?: ExpandOption; $orderby?: OrderByOption; $top?: number; $skip?: number; $count?: boolean; $inlinecount?: string; $format?: FormatOption; [key: string]: // User defined options, do not start with $ or @ | string // Parameter aliases (start with @) | NumberBind | BooleanBind | TextBind | DateBind // known $ options | SelectOption | ExpandOption | OrderByOption | FormatOption | number | boolean | undefined; <--- This is needed }
If I made that change in the d.ts tsc was happy.
In order to get around this we currently have to use const parser = require('@balena/odata-parser') instead of import {parse} from '@balena/odata-parser'.
const parser = require('@balena/odata-parser')
import {parse} from '@balena/odata-parser'
We use @balena/odata-parser in one of our projects, and the transpiler
tsc
is complaining about these:Looking at
odata-parser.d.ts
I can see thatODataOptions
was defined as:Note that all properties are optional, and as such the part below should include a
undefined
as follows:If I made that change in the d.ts
tsc
was happy.