TypeScript - difference between import … and import {…} (with curly braces)

后端 未结 3 1178
有刺的猬
有刺的猬 2020-12-13 12:38

Coming from Java to TS, I\'ve omitted the {...} around the imported type.

import DiscriminatorMappingData from \'./DiscriminatorMappingData\';
         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 13:09

    This is imports in destructruring format. Essentially grouping all the entities that we want to be imported from a definition file.

    If you are familiar with other programming languages you might be familiar with the destructuring notion. Actually destructuring was added in the form of assignments as part of es6.

    Import restructuring support was first suggested in TypeScript in this Github ticket but then got grouped under this ticket that was tracking all the es6 modules.

提交回复
热议问题