You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,6 @@ Cheatsheet for using React with TypeScript.
34
34
- It also has miscellaneous tips and tricks for pro users.
35
35
- Advice for contributing to DefinitelyTyped.
36
36
- The goal is to take _full advantage_ of TypeScript.
37
-
-[The Migrating Cheatsheet](https://react-typescript-cheatsheet.netlify.app/docs/migration) helps collate advice for incrementally migrating large codebases from JS or Flow, **from people who have done it**.
38
-
- We do not try to convince people to switch, only to help people who have already decided.
39
-
- ⚠️This is a new cheatsheet, all assistance is welcome.
40
37
-[The HOC Cheatsheet](https://react-typescript-cheatsheet.netlify.app/docs/hoc) specifically teaches people to write HOCs with examples.
41
38
- Familiarity with [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html) is necessary.
42
39
- ⚠️This is the newest cheatsheet, all assistance is welcome.
@@ -2433,8 +2430,6 @@ npm install -g dts-gen
2433
2430
dts-gen -m <your-module>
2434
2431
```
2435
2432
2436
-
There are other automated JS to TS conversion tools and migration strategies - see [our MIGRATION cheatsheet](https://react-typescript-cheatsheet.netlify.app/docs/migration/from_js).
In case of typing untyped class components, there's almost no difference in approach except for the fact that after declaring the types, you export the extend the type using `class UntypedClassComponent extends React.Component<UntypedClassComponentProps, any> {}` where `UntypedClassComponentProps` holds the type declaration.
2542
2537
2543
-
For instance, [sw-yx's Gist on React Router 6 types](https://gist.github.com/sw-yx/37a6a3d248c2d4031801f0d568904df8) implemented a similar method for typing the then untyped RR6.
For more information on creating type definitions for class components, you can refer to this [post](https://templecoding.com/blog/2016/03/31/creating-typescript-typings-for-existing-react-components) for reference.
2560
-
2561
2552
#### Frequent Known Problems with TypeScript
2562
2553
2563
2554
Just a list of stuff that React developers frequently run into, that TS has no solution for. Not necessarily TSX only.
@@ -2943,7 +2934,7 @@ If you're looking for information on Prettier, check out the [Prettier](https://
2943
2934
9. bangbang checks `if (!!nonboolean)`
2944
2935
10. `!= null` to check for `null` and `undefined`
2945
2936
- [Ultimate React Component Patterns with TypeScript 2.8](https://levelup.gitconnected.com/ultimate-react-component-patterns-with-typescript-2-8-82990c516935)
2946
-
- [Basarat's TypeScript gitbook has a React section](https://basarat.gitbook.io/typescript/tsx/react) with an [Egghead.io course](https://egghead.io/courses/use-typescript-to-develop-react-applications) as well.
2937
+
- [Basarat's TypeScript gitbook has a React section](https://basarat.gitbook.io/typescript/tsx/react).
2947
2938
- [Palmer Group's TypeScript + React Guidelines](https://github.com/palmerhq/typescript) as well as Jared's other work like [disco.chat](https://github.com/jaredpalmer/disco.chat)
- [TypeScript React Starter Template by Microsoft](https://github.com/Microsoft/TypeScript-React-Starter) A starter template for TypeScript and React with a detailed README describing how to use the two together. Note: this doesn't seem to be frequently updated anymore.
@@ -2993,7 +2984,6 @@ It is worth mentioning some resources to help you get started:
2993
2984
- Anders Hejlsberg's overview of TS: https://www.youtube.com/watch?v=ET4kT88JRXs
2994
2985
- Marius Schultz: https://blog.mariusschulz.com/series/typescript-evolution with an [Egghead.io course](https://egghead.io/courses/advanced-static-types-in-typescript)
2995
2986
- Basarat's Deep Dive: https://basarat.gitbook.io/typescript/
2996
-
- Axel Rauschmeyer's [Tackling TypeScript](https://exploringjs.com/tackling-ts/)
2997
2987
- Rares Matei: [Egghead.io course](https://egghead.io/courses/practical-advanced-typescript)'s advanced TypeScript course on Egghead.io is great for newer typescript features and practical type logic applications (e.g. recursively making all properties of a type `readonly`)
2998
2988
- Learn about [Generics, Conditional types and Mapped types](https://www.youtube.com/watch?v=PJjeHzvi_VQ&feature=youtu.be)
2999
2989
- Shu Uesugi: [TypeScript for Beginner Programmers](https://ts.chibicode.com/)
Copy file name to clipboardExpand all lines: docs/advanced/index.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,9 @@ title: Advanced Cheatsheet
12
12
13
13
**Creating React + TypeScript Libraries**
14
14
15
-
The best tool for creating React + TS libraries right now is [`tsdx`](https://github.com/palmerhq/tsdx). Run `npx tsdx create` and select the "react" option. You can view [the React User Guide](https://github.com/palmerhq/tsdx/issues/5) for a few tips on React+TS library best practices and optimizations for production.
15
+
The best tool for creating React + TS libraries right now is [`tsdx`](https://github.com/palmerhq/tsdx). Run `npx tsdx create` and select the "react" option.
16
16
17
17
Another option is [Rollpkg](https://github.com/rafgraph/rollpkg), which uses Rollup and the TypeScript compiler (not Babel) to create packages. It includes default configs for TypeScript, Prettier, ESLint, and Jest (setup for use with React), as well as Bundlephobia package stats for each build.
18
18
19
-
- Be sure to also check [`basarat`'s guide](https://basarat.gitbooks.io/typescript/content/docs/quick/library.html) for library tsconfig settings.
20
19
- Alec Larson: [The best Rollup config for TypeScript libraries](https://gist.github.com/aleclarson/9900ed2a9a3119d865286b218e14d226)
21
20
- From the Angular world, check out https://github.com/bitjson/typescript-starter
TypeScript uses [TSDoc](https://github.com/Microsoft/tsdoc), a variant of JSDoc for TypeScript. This is very handy for writing component libraries and having useful descriptions pop up in autocomplete and other tooling (like the [Docz PropsTable](https://www.docz.site/docs/components-api#propstable)). The main thing to remember is to use `/** YOUR_COMMENT_HERE */` syntax in the line just above whatever you're annotating.
31
+
TypeScript uses [TSDoc](https://github.com/Microsoft/tsdoc), a variant of JSDoc for TypeScript. This is very handy for writing component libraries and having useful descriptions pop up in autocomplete and other tooling. The main thing to remember is to use `/** YOUR_COMMENT_HERE */` syntax in the line just above whatever you're annotating.
32
32
33
33
```tsx
34
34
interfaceMyComponentProps {
@@ -87,26 +87,6 @@ For developing with Storybook, read the docs I wrote over here: [https://storybo
87
87
88
88
[Something to add? File an issue](https://github.com/typescript-cheatsheets/react/issues/new).
89
89
90
-
## Migrating From Flow
91
-
92
-
You should check out large projects that are migrating from flow to pick up concerns and tips:
Integrating this with ESlint may be a problem. We haven't written much on this yet, please contribute if you have a strong opinion. [Here's a helpful gist.](https://gist.github.com/JirkaVebr/519c7597517e4ba756d5b89e7cb4cc0e)
146
126
147
-
For library authors, this is set up for you in [tsdx](https://github.com/palmerhq/tsdx/pull/45/files). You may also wish to check out the newer https://ts-engine.dev/ project.
127
+
For library authors, this is set up for you in [tsdx](https://github.com/palmerhq/tsdx/pull/45/files).
Copy file name to clipboardExpand all lines: docs/advanced/utility-types.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,6 @@ We will assume knowledge of utility types covered in the sister project [`typesc
8
8
9
9
If you intend to maintain a large TS codebase/a nontrivial React+TS library, **we strongly recommend exploring these utilities** so that you don't reinvent the wheel and/or lose sanity trying to do so. Studying their code can also teach you a lot of advanced TS that is not covered here.
10
10
11
-
I also recommend having a good working knowledge of how to construct the inbuilt utility types from scratch. See [Dr. Rauschmayer's guide](https://2ality.com/2020/06/computing-with-types.html) for a concise introduction.
12
-
13
11
A level of comfort with **generic types** is therefore required. Here are some helpful resources:
Copy file name to clipboardExpand all lines: docs/basic/recommended/resources.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ sidebar_label: Other resources
19
19
9. bangbang checks `if (!!nonboolean)`
20
20
10.`!= null` to check for `null` and `undefined`
21
21
-[Ultimate React Component Patterns with TypeScript 2.8](https://levelup.gitconnected.com/ultimate-react-component-patterns-with-typescript-2-8-82990c516935)
22
-
-[Basarat's TypeScript gitbook has a React section](https://basarat.gitbook.io/typescript/tsx/react) with an [Egghead.io course](https://egghead.io/courses/use-typescript-to-develop-react-applications) as well.
22
+
-[Basarat's TypeScript gitbook has a React section](https://basarat.gitbook.io/typescript/tsx/react).
23
23
-[Palmer Group's TypeScript + React Guidelines](https://github.com/palmerhq/typescript) as well as Jared's other work like [disco.chat](https://github.com/jaredpalmer/disco.chat)
-[TypeScript React Starter Template by Microsoft](https://github.com/Microsoft/TypeScript-React-Starter) A starter template for TypeScript and React with a detailed README describing how to use the two together. Note: this doesn't seem to be frequently updated anymore.
Copy file name to clipboardExpand all lines: docs/basic/troubleshooting/learn-ts.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@ It is worth mentioning some resources to help you get started:
14
14
- Anders Hejlsberg's overview of TS: https://www.youtube.com/watch?v=ET4kT88JRXs
15
15
- Marius Schultz: https://blog.mariusschulz.com/series/typescript-evolution with an [Egghead.io course](https://egghead.io/courses/advanced-static-types-in-typescript)
16
16
- Basarat's Deep Dive: https://basarat.gitbook.io/typescript/
17
-
- Axel Rauschmeyer's [Tackling TypeScript](https://exploringjs.com/tackling-ts/)
18
17
- Rares Matei: [Egghead.io course](https://egghead.io/courses/practical-advanced-typescript)'s advanced TypeScript course on Egghead.io is great for newer typescript features and practical type logic applications (e.g. recursively making all properties of a type `readonly`)
19
18
- Learn about [Generics, Conditional types and Mapped types](https://www.youtube.com/watch?v=PJjeHzvi_VQ&feature=youtu.be)
20
19
- Shu Uesugi: [TypeScript for Beginner Programmers](https://ts.chibicode.com/)
Copy file name to clipboardExpand all lines: docs/basic/troubleshooting/types.md
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -413,8 +413,6 @@ npm install -g dts-gen
413
413
dts-gen -m <your-module>
414
414
```
415
415
416
-
There are other automated JS to TS conversion tools and migration strategies - see [our MIGRATION cheatsheet](https://react-typescript-cheatsheet.netlify.app/docs/migration/from_js).
In case of typing untyped class components, there's almost no difference in approach except for the fact that after declaring the types, you export the extend the type using `class UntypedClassComponent extends React.Component<UntypedClassComponentProps, any> {}` where `UntypedClassComponentProps` holds the type declaration.
522
520
523
-
For instance, [sw-yx's Gist on React Router 6 types](https://gist.github.com/sw-yx/37a6a3d248c2d4031801f0d568904df8) implemented a similar method for typing the then untyped RR6.
For more information on creating type definitions for class components, you can refer to this [post](https://templecoding.com/blog/2016/03/31/creating-typescript-typings-for-existing-react-components) for reference.
540
-
541
535
## Frequent Known Problems with TypeScript
542
536
543
537
Just a list of stuff that React developers frequently run into, that TS has no solution for. Not necessarily TSX only.
0 commit comments