In this basic example of TypeScript implementation the parameters of the outputText function have ensured that it is receiving an array containing only string values.

In this post I want to highlight how TypeScript can be used in combination with React quite effectively. It can make your React codebase more predictable to follow and reduce margin for error for a project’s expected data types.

The Props and State types have been predefined here and exist in the the context of the file they are created in. This ensures that the values of these types should only be what we expect from our definitions.