How to use added vices in typescript

I am trying to learn Typescript and created a basic typescript structure after this tutorial.

I need to add typing to the project now. So I looked around and found typings . Then I added JQuery, Lodashand D3with the help of typing. So my project structure is as follows:

β”œβ”€β”€ dist
β”‚   β”œβ”€β”€ chart.js
β”‚   β”œβ”€β”€ greet.js
β”‚   └── main.js
β”œβ”€β”€ gulpfile.js
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚   └── ts
β”‚       β”œβ”€β”€ chart.ts
β”‚       β”œβ”€β”€ greet.ts
β”‚       └── main.ts
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ typings
β”‚   β”œβ”€β”€ globals
β”‚   β”‚   └── jquery
β”‚   β”‚       β”œβ”€β”€ index.d.ts
β”‚   β”‚       └── typings.json
β”‚   β”œβ”€β”€ index.d.ts
β”‚   └── modules
β”‚       β”œβ”€β”€ d3
β”‚       β”‚   β”œβ”€β”€ index.d.ts
β”‚       β”‚   └── typings.json
β”‚       └── lodash
β”‚           β”œβ”€β”€ index.d.ts
β”‚           └── typings.json
└── typings.json

This is my file tsconfig.json:

{
    "files": [
        "src/ts/*.ts"
    ],
    "compilerOptions": {
        "noImplicitAny": true,
        "target": "es5"
    }
}

My question is: how to add the files *.d.tsthat I have in the directory typingsin my main.tsfile and start using jQuery $or D3 D3?

I noticed a index.d.tsfile in typingsthat looks like this:

/// <reference path="globals/jquery/index.d.ts" />
/// <reference path="modules/d3/index.d.ts" />
/// <reference path="modules/lodash/index.d.ts" />

, - main.ts tsconfig.json ( , .d.ts). ? .

+4
2

TypeScript 2 npm . . .

, , - :

npm install --save @types/lodash @types/d3 @types/jquery

.

+3

tsconfig:

"files": [
    "src/ts/*.ts",
    "typings/**/*.ts"
]

"files": [
    "src/ts/*.ts",
    "typings/index.d.ts"
]
+3

Source: https://habr.com/ru/post/1658006/


All Articles