XrmDefinitelyTyped icon indicating copy to clipboard operation
XrmDefinitelyTyped copied to clipboard

Add support for deprecation of fields

Open TomMalow opened this issue 6 years ago • 1 comments

It is possible to deprecate fields in XrmContext by specifying a prefix, such as "X_", that is added to the display name of the deprecated field. The same feature would be useful in XrmDefinitelyTyped. However, TypeScript does not currently support deprecation but it is still possible to introduce it through union types.

We could introduce a new type called deprecated and use it as part of the union type of the deprecated field. Say for example that we have a deprecated text field, the generated definition for the field could then have the type string | null | deprecated. This will introduce a compile time error which the user needs to handle. Either by stop using the field og discard the type and insist on using the field even though it is deprecated.

This new feature should be optional and activated the same way as it is done in XrmContext, by adding an additional argument specifying the deprecated prefix. For example "deprecatedprefix", "X_"

TomMalow avatar Nov 21 '17 10:11 TomMalow

Since TS 4.0, the @deprecated tag is supported https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#deprecated-support

The deprecated type could be an option, allowing the user to choose between compile time warnings and errors.

mkholt avatar Sep 10 '20 10:09 mkholt