Deprecated API

    • markAsWarning embeds a warning in the attribute on the given object, and the attribute needs to exist on the given object.

    • removeProperty redefines the removed property on the given object, and embeds an error message. The property should not exist on the given object.

    According to the module division, each module maintains an obsolete file. In order to facilitate maintenance, the name is unified as deprecated.ts and placed in the directory of the corresponding module, and the file needs to be import in the index.ts file of the corresponding module, such as import'./deprecated'.

    1. // For APIs that are not compatible with replacement parameters, adapt them through appropriate custom functions
    2. replaceProperty(AnimationComponent.prototype, 'AnimationComponent.prototype', [
    3. {
    4. name: 'removeClip',
    5. newName: 'removeState',
    6. customFunction: function (...args: any) {
    7. const arg0 = args[0] as AnimationClip;
    8. return AnimationComponent.prototype.removeState.call(this, arg0.name);
    9. ]);
    10. replaceProperty(vmath, 'vmath', [
    11. {
    12. name: 'vec2',
    13. newName: 'Vec2',
    14. target: math,
    15. targetName: 'math',
    16. 'logTimes': 1
    17. },
    18. {
    19. name: 'EPSILON',
    20. target: math,
    21. targetName: 'math',
    22. 'logTimes': 2
    23. ]);
    24. removeProperty(vmath, 'vmath', [
    25. {
    26. 'name': 'random',
    27. 'suggest': 'use Math.random.'
    28. }
    29. ]);
    30. markAsWarning(math, 'math', [
    31. {
    32. 'name': 'toRadian'
    33. }
    34. ]);
    • replaceProperty does not pass in newName or newTarget, which means it is consistent with name or target.