avatarSlavo_3, July 26, 2022

Definitely Typed

Definitely Typed. TypeScript, Programming, 3rd Party Library

TODO: provide alt

We do not use regular JavaScript syntax if you use a 3rd party libraries ( React, jQuery, Vue, Angular), and we want to include TypeSript in our codebase.

TypeScript, we will not understand what react, nextjs or jsx/tsx is. We need to add 3rd parties libraries that will help us to understand that library's syntax.

Adding TypeScript to React and NextJS:

- React we will use

export function usersHandler(){}

to add TypeScript to our React project.

- NextJS, You can create a TypeScript project with

npx create-next-app -ts

flag --ts ( typescript ) or to existing projects create empty "tsconfig.json" file in the root folder and run your project.

The packages that we installed should explain what is "jsx/tsx" for us.

TypeScript allows you to use 'Declaration Files", which are files that will enable describing the shape of code written. You can add files that we can reference to tell TypeScript, and I am also using this library. Use these types that just made up for you.

TypeScript is complex, but it is worth learning & using. It's a lot of learning, especially when using some framework or library. We must be familiar with all our 3rd party library files and learn the new TS types that these 3rd party libraries provide.

The repository for high-quality TypeScript type definitions, please follow - Definitely Typed