Skip to content

chore: format #491

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

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ const el2 = <MyArrayComponent />; // throws an error
Unfortunately just annotating the function type will not help so if you really need to return other exotic types that React supports, you'd need to perform a type assertion:

```tsx
const MyArrayComponent = () => Array(5).fill(<div />) as any as JSX.Element;
const MyArrayComponent = () => (Array(5).fill(<div />) as any) as JSX.Element;
```

[See commentary by @ferdaber here](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/issues/57).
Expand Down Expand Up @@ -1787,16 +1787,14 @@ This was done [on purpose](https://github.com/DefinitelyTyped/DefinitelyTyped/pu
```tsx
type Props = { children: React.ReactNode; type: "submit" | "button" };
export type Ref = HTMLButtonElement;
export const FancyButton = React.forwardRef(
(
props: Props,
ref: React.Ref<Ref> // <-- here!
) => (
<button ref={ref} className="MyClassName" type={props.type}>
{props.children}
</button>
)
);
export const FancyButton = React.forwardRef((
props: Props,
ref: React.Ref<Ref> // <-- here!
) => (
<button ref={ref} className="MyClassName" type={props.type}>
{props.children}
</button>
));
```

</details>
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/patterns_by_usecase.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ function isString(a: unknown): a is string {
[Read more about User-Defined Type Guards in the Handbook](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards).

### Narrowing using `extends`

See this quick guide: https://twitter.com/mpocock1/status/1500813765973053440?s=20&t=ImUA-NnZc4iUuPDx-XiMTA

## Props: One or the Other but not Both

Use the `in` keyword, function overloading, and union types to make components that take either one or another sets of props, but not both:
Expand Down
2 changes: 1 addition & 1 deletion docs/migration/from-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ title: From Flow
- [Ecobee's brief experience](https://mobile.twitter.com/alanhietala/status/1104450494754377728)
- [Migrating a 50K SLOC Flow + React Native app to TypeScript](https://blog.usejournal.com/migrating-a-flow-react-native-app-to-typescript-c74c7bceae7d)
- [How we migrated 400K+ lines of code from Flow to TypeScript at Factorial](https://labs.factorialhr.com/posts/how-we-migrated-400k-lines-of-code-from-flow-to-typescript)
[entria]: https://medium.com/entria/incremental-migration-to-typescript-on-a-flowtype-codebase-515f6490d92d "Incremental Migration to TypeScript on a Flowtype codebase"
[entria]: https://medium.com/entria/incremental-migration-to-typescript-on-a-flowtype-codebase-515f6490d92d "Incremental Migration to TypeScript on a Flowtype codebase"