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

feat(useExplicitFunctionReturnType): support typed function expressions #4174

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

kaykdm
Copy link
Contributor

@kaykdm kaykdm commented Oct 4, 2024

Summary

related: #2017

This PR introduces the ability to detect typed function expressions in the useExplicitFunctionReturnType rule.

todos:

  • A function with a type assertion using as or <>
const asTyped = (() => '') as () => string;
const castTyped = <() => string>(() => '');
  • A variable declarator with a type annotation
type FuncType = () => string;
const arrowFn: FuncType = () => 'test';
  • A function as a default parameter with a type annotation
type CallBack = () => void;
const f = (gotcha: CallBack = () => { }): void => { };
  • A class property with a type annotation
type MethodType = () => void;
  class App {
     private method: MethodType = () => { };
}
  • A function as a property or a nested property of a typed object
const x: Foo = { prop: () => {} }
const x = { prop: () => {} } as Foo
const x = <Foo>{ prop: () => {} }
const x: Foo = { bar: { prop: () => {} } }

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 4, 2024
Copy link

codspeed-hq bot commented Oct 4, 2024

CodSpeed Performance Report

Merging #4174 will degrade performances by 33.19%

Comparing kaykdm:support-typed-function-expressions (acf69c8) with main (055b0db)

Summary

❌ 1 regressions
✅ 104 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main kaykdm:support-typed-function-expressions Change
big5-added_15586211152145260264.json[uncached] 547 µs 818.8 µs -33.19%

Copy link
Member

@Conaclos Conaclos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made it! Thanks for your amazing contribution 💗

@Conaclos Conaclos merged commit 2f0d5c7 into biomejs:main Oct 7, 2024
11 of 12 checks passed
@kaykdm kaykdm deleted the support-typed-function-expressions branch October 8, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants