-
-
Notifications
You must be signed in to change notification settings - Fork 925
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.53.0
What command did you run?
npm exec oxlint -- -c=.oxlintrc.json
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
The following code triggers two oxlint warnings:
export const widgetSettingsDeserializer = new JsonInterfaceDeserializer<WidgetSettings, SupportedWidget>(
raw => raw.widgetSpecificationId as SupportedWidget
);Specifically the lambda passed to the JsonInterfaceDeserializer constructor is reported as a problem twice:
╭─[some-file.ts:22:3]
21 │ export const widgetSettingsDeserializer = new JsonInterfaceDeserializer<WidgetSettings, SupportedWidget>(
22 │ raw => raw.widgetSpecificationId as SupportedWidget
· ───
23 │ );
╰────
help: Define an explicit argument type for each argument.
⚠ typescript-eslint(explicit-module-boundary-types): Missing return type on function
╭─[some-file.ts:21:14]
20 │
21 │ export const widgetSettingsDeserializer = new JsonInterfaceDeserializer<WidgetSettings, SupportedWidget>(
· ──────────────────────────
22 │ raw => raw.widgetSpecificationId as SupportedWidget
╰────
help: Define an explicit return type for the function.
This is a false positive since the inner arrow function is not part of the exported api, but just an argument to the exported fully typed class instance.
This can be proofed changing it to this code, which is technically exactly the same and doesn't trigger a linter warning:
const widgetSettingsDeserializerInternal = new JsonInterfaceDeserializer<WidgetSettings, SupportedWidget>(
raw => raw.widgetSpecificationId as SupportedWidget
);
export const widgetSettingsDeserializer = widgetSettingsDeserializerInternal;My guess is that the rule parser sees the untyped function argument as part of the full export statement and thus wrongly assumes this being part of the api.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet