Daryl
Daryl

Reputation: 18895

Organize Interfaces in a semi large TD file

I'm working on cleaning up the definitions for the XRM respository (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/xrm) and need some guidelines for how the interfaces in definitions should be structured. (here is a cheatsheet just to get an idea of how Xrm is structure https://drive.google.com/file/d/0B9-OddqJEKamWEs0MV9MMDdsWE0/view)

Basically everything is Xrm.Page, or Xrm.Utility but can go deep (Xrm.Page.ui.formSelector, Xrm.Page.ui.navigation, Xrm.Page.data.process, etc). I believe each of these "namespaces" should be their own interface. My question is how do you structure the interfaces in the code? Put everything at a root level? So Xrm.Data (or maybe XrmPageData) interface is Xrm.Page.data? This could result in naming conflicts but makes everything simple to access. Other option is to nest them where they are found, so Xrm.Page.Data would exist in an Xrm.Page module (which is the same name, but not the Xrm.Page interface).

Currently the definition file is using both, I just wanted to know what the guidelines/best practices are.

Upvotes: 0

Views: 75

Answers (1)

Cobus Kruger
Cobus Kruger

Reputation: 8615

The simple truth is that users of the typing will refer to the XRM documentation for help and examples. From a usage perspective, the most obvious way is for your type definitions to resemble the API docs. Which in this case means using your second suggestion, where Xrm.Page.data becomes data, placed in a Xrm.Page module.

Upvotes: 1

Related Questions