XrmDefinitelyTyped
XrmDefinitelyTyped copied to clipboard
Add support for deprecation of fields
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_"
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.