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

odata-parser.d.ts causing eslint problems #79

Open
haihovu opened this issue Apr 2, 2024 · 1 comment
Open

odata-parser.d.ts causing eslint problems #79

haihovu opened this issue Apr 2, 2024 · 1 comment

Comments

@haihovu
Copy link

haihovu commented Apr 2, 2024

We use @balena/odata-parser in one of our projects, and the transpiler tsc is complaining about these:

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:


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:

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.

@haihovu
Copy link
Author

haihovu commented Apr 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant