Skip to content

Instantly share code, notes, and snippets.

@IlyaIvanchikov
Created September 28, 2025 21:07
Show Gist options
  • Select an option

  • Save IlyaIvanchikov/da6df6982b0e7cbe60e0511fc6a50d15 to your computer and use it in GitHub Desktop.

Select an option

Save IlyaIvanchikov/da6df6982b0e7cbe60e0511fc6a50d15 to your computer and use it in GitHub Desktop.
When declaring functions on the top-level of a module,
declare their return types.
```ts
const myFunc = (): string => {
return "hello";
};
```
One exception to this is components which return JSX.
No need to declare the return type of a component,
as it is always JSX.
```tsx
const MyComponent = () => {
return <div>Hello</div>;
};
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment