In TypeScript, when to use the link, when to use the import?

TypeScript has two concepts of file / module references. Although I read the TypeScript documentation briefly, I don’t understand when this approach should be used when:

  • Triple Slash Link: /// <reference path="..." />
  • Import: import { Foo } from "./Foo";

thank

+4
source share
1 answer

It is important to understand that these are not two concepts of file / module links. There are actually two completely different things.

import

ES2015 , , , JavaScript. /, API/ .

import - concat <link> HTML, jQuery. import * as $ from 'jQuery', JavaScript/TypeScript "" . , , Loader.

TypeScript, TypeScript , //... .

/// <reference>

<reference> .d.ts. TypeScript . .

, import <reference> , import "" . <reference> . /IDE , , TypeScript API , . () , .

+4

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


All Articles