Home  >  Article  >  Web Front-end  >  Detailed explanation of the steps for writing d.ts files

Detailed explanation of the steps for writing d.ts files

php中世界最好的语言
php中世界最好的语言Original
2018-04-28 14:19:222129browse

This time I will give you a detailed explanation of the steps for writing a d.ts file. What are the precautions for writing a d.ts file? The following is a practical case, let’s take a look.

Preface

This article mainly talks about how to write a typescript description file (a file name ending with d.ts, such as xxx.d. ts).

I recently started switching from js to ts. However, some description files (d.ts) are required. Commonly used ones such as jquery can be downloaded through npm to npm install @types/jquery that has been written by others. However, there are still some niche or internal public libraries within the company or public js codes that have been written before that require manual writing of description files.

I also found some information from the Internet before, but it was still unclear. After a period of exploration, I recorded the results of the exploration, and I hope it can give others a reference.

If you only write js, d.ts is also useful for you. Most editors can recognize d.ts files and give you intelligence when you write js code. hint. The effect looks like this:

For details, you can read some articles I have written before: http://www.jb51.net/article/138211.htm

Normally, when we write js, there are two ways to introduce js:

1. Globally introduce global variables in the html file through the