When to use Classes vs Modules in TypeScript?

后端 未结 2 900
名媛妹妹
名媛妹妹 2021-02-18 23:59

I\'m in the process of migrating a large codebase to Typescript, but wanted to get a good handle on when & where I should be using certain things.

Right now I have s

2条回答
  •  醉话见心
    2021-02-19 00:29

    It depends. A module should be a discrete set of "things" rather than just a jumbled collection of disparate classes, so if things seem like they belong together, use a module to group them.

    I believe the TypeScript team is waiting to see how people use the language before they publish guidance, but I imagine people will publish a module where they currently publish a script - so jQuery would be a module, each jQuery Plugin would be a module, a testing framework would be a module, and an AOP framework would be a module - for example.

提交回复
热议问题