lib.wx.behavior.d.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*! *****************************************************************************
  2. Copyright (c) 2021 Tencent, Inc. All rights reserved.
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  7. of the Software, and to permit persons to whom the Software is furnished to do
  8. so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.
  18. ***************************************************************************** */
  19. declare namespace WechatMiniprogram.Behavior {
  20. type BehaviorIdentifier = string
  21. type Instance<
  22. TData extends DataOption,
  23. TProperty extends PropertyOption,
  24. TMethod extends MethodOption,
  25. TCustomInstanceProperty extends IAnyObject = Record<string, never>
  26. > = Component.Instance<TData, TProperty, TMethod, TCustomInstanceProperty>
  27. type TrivialInstance = Instance<IAnyObject, IAnyObject, IAnyObject>
  28. type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject>
  29. type Options<
  30. TData extends DataOption,
  31. TProperty extends PropertyOption,
  32. TMethod extends MethodOption,
  33. TCustomInstanceProperty extends IAnyObject = Record<string, never>
  34. > = Partial<Data<TData>> &
  35. Partial<Property<TProperty>> &
  36. Partial<Method<TMethod>> &
  37. Partial<OtherOption> &
  38. Partial<Lifetimes> &
  39. ThisType<Instance<TData, TProperty, TMethod, TCustomInstanceProperty>>
  40. interface Constructor {
  41. <
  42. TData extends DataOption,
  43. TProperty extends PropertyOption,
  44. TMethod extends MethodOption,
  45. TCustomInstanceProperty extends IAnyObject = Record<string, never>
  46. >(
  47. options: Options<TData, TProperty, TMethod, TCustomInstanceProperty>
  48. ): BehaviorIdentifier
  49. }
  50. type DataOption = Component.DataOption
  51. type PropertyOption = Component.PropertyOption
  52. type MethodOption = Component.MethodOption
  53. type Data<D extends DataOption> = Component.Data<D>
  54. type Property<P extends PropertyOption> = Component.Property<P>
  55. type Method<M extends MethodOption> = Component.Method<M>
  56. type DefinitionFilter = Component.DefinitionFilter
  57. type Lifetimes = Component.Lifetimes
  58. type OtherOption = Omit<Component.OtherOption, 'options'>
  59. }
  60. /** 注册一个 `behavior`,接受一个 `Object` 类型的参数。*/
  61. declare let Behavior: WechatMiniprogram.Behavior.Constructor