import { expectType } from 'tsd' ; expectType < string > ( wx . env . USER_DATA_PATH ) ; const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . drawImage ( '' , 1 , 1 ) ; ctx . drawImage ( '' , 0 , 0 , 150 , 100 ) ; ctx . drawImage ( '' , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ; wx . getSetting ( { success ( res ) { expectType < boolean | undefined > ( res . authSetting [ 'scope.userInfo' ] ) ; } , } ) ; wx . cloud . callFunction ( { name : 'add' , data : { x : 1 , y : 2 , } , success : res => { expectType < string > ( res . errMsg ) ; } , fail : err => { expectType < string > ( err . errMsg ) ; } , } ) ; wx . cloud . deleteFile ( { fileList : [ 'a7xzcb' ] , success : res => { expectType < ICloud . DeleteFileResultItem [ ] > ( res . fileList ) ; } , } ) ; wx . addCard ( { cardList : [ { cardId : '' , cardExt : '{"code": "", "openid": "", "timestamp": "", "signature":""}' , } , { cardId : '' , cardExt : '{"code": "", "openid": "", "timestamp": "", "signature":""}' , } , ] , success ( res ) { expectType < WechatMiniprogram . AddCardResponseInfo [ ] > ( res . cardList ) ; } , } ) ; wx . chooseMessageFile ( { count : 10 , type : 'image' , success ( res ) { expectType < WechatMiniprogram . ChooseFile [ ] > ( res . tempFiles ) ; } , } ) ; wx . canvasGetImageData ( { canvasId : 'myCanvas' , x : 0 , y : 0 , width : 100 , height : 100 , success ( res ) { expectType < number > ( res . width ) ; expectType < number > ( res . height ) ; expectType < Uint8ClampedArray > ( res . data ) ; expectType < number > ( res . data . length ) ; } , } ) ; wx . onGyroscopeChange ( res => { expectType < number > ( res . x ) ; expectType < number > ( res . y ) ; expectType < number > ( res . z ) ; } ) ; wx . reportAnalytics ( 'purchase' , { price : 120 , color : 'red' , } ) ; wx . navigateBack ( ) ; wx . navigateBack ( { } ) ; wx . navigateBack ( { delta : 1 } ) ; wx . setTabBarStyle ( ) ; wx . setTabBarStyle ( { } ) ; wx . setTabBarStyle ( { color : '#111111' } ) ; wx . setBackgroundColor ( { backgroundColor : '#111111' } ) ; wx . setNavigationBarColor ( { frontColor : '#ffffff' , backgroundColor : '#123456' , } ) ; wx . login ( { success ( res ) { expectType < string > ( res . errMsg ) ; } , } ) ; wx . loadFontFace ( { source : '' , family : 'font' , success ( res ) { expectType < string > ( res . status ) ; } , fail ( res ) { expectType < string > ( res . status ) ; } , complete ( res ) { expectType < string > ( res . status ) ; } , } ) ; wx . request ( { url : '' , success ( res ) { const data = { res } ; expectType < any > ( data . customData ) ; } , } ) ; interface IResponse { customData : string ; } wx . request ( { url : '' , success ( res ) { const data = res . data as IResponse ; expectType < string > ( data . customData ) ; } , } ) ; { const task = wx . connectSocket ( { url : '' } ) ; task . onClose ( res => { expectType < number > ( res . code ) ; expectType < string > ( res . reason ) ; } ) ; } { wx . onBluetoothDeviceFound ( res => { res . devices . forEach ( device => { expectType < string > ( device . name ) ; expectType < string > ( device . deviceId ) ; } ) ; } ) ; } { interface IDialogMethod extends Partial < WechatMiniprogram . Component . MethodOption > { f ? : ( ) => string ; g : ( ) => void ; } type Dialog = WechatMiniprogram . Component . Instance < { } , { } , IDialogMethod > ; Page ( { f ( ) { const comp = this . selectComponent ( '#comp' ) as Dialog ; expectType < ( ( ) => string ) | undefined > ( comp . f ) ; if ( comp . f ) expectType < string > ( comp . f ( ) ) ; comp . g ( ) ; } , } ) ; } { Behavior ( { observers : { value ( v ) { expectType < any > ( v ) ; } , } , } ) ; } import WX = WechatMiniprogram ; { type ILoginResult = WX . LoginSuccessCallbackResult ; const t = { code : '' , errMsg : '' } ; expectType < WechatMiniprogram . LoginSuccessCallbackResult > ( t ) ; } { wx . createSelectorQuery ( ) . select ( '#canvas' ) . fields ( { node : true } ) . exec ( res => { wx . canvasToTempFilePath ( { canvas : res [ 0 ] . node } ) ; wx . canvasToTempFilePath ( { canvas : res [ 0 ] . node , quality : 0.5 } ) ; } ) ; wx . canvasToTempFilePath ( { canvasId : '' } ) ; } { const udp = wx . createUDPSocket ( ) ; const port = udp . bind ( ) ; expectType < number > ( port ) ; } { expectType < Record < string , any > > ( wx . getExtConfigSync ( ) ) ; wx . getExtConfig ( { success ( res ) { expectType < Record < string , any > > ( res . extConfig ) ; } , } ) ; } { Page ( { ctx : { } as WechatMiniprogram . CameraContext , onLoad ( ) { this . ctx = wx . createCameraContext ( ) ; } , takePhoto ( ) { this . ctx . takePhoto ( { quality : 'high' , success : res => { expectType < string > ( res . tempImagePath ) ; this . setData ( { src : res . tempImagePath , } ) ; } , } ) ; } , startRecord ( ) { this . ctx . startRecord ( { success : res => { expectType < string > ( res . errMsg ) ; console . log ( 'startRecord' ) ; } , } ) ; } , stopRecord ( ) { this . ctx . stopRecord ( { success : res => { expectType < string > ( res . tempThumbPath ) ; expectType < string > ( res . tempVideoPath ) ; this . setData ( { src : res . tempThumbPath , videoSrc : res . tempVideoPath , } ) ; } , } ) ; } , } ) ; } { type IData = { name : string ; } ; type IProperty = { id : typeof Number ; } ; type IMethod = { setJob ( job ) : void ; } ; type ICustomInstanceProperty = { job : string ; } ; Component < IData , IProperty , IMethod , ICustomInstanceProperty > ( { properties : { id : Number , } , data : { name : '' , } , methods : { setJob ( job ) { this . job = job ; expectType < string > ( this . job ) ; } , } , } ) ; } { const ctx = wx . createMapContext ( 'map' ) ; ctx . getRegion ( { success ( res ) { expectType < number > ( res . southwest . longitude ) ; expectType < number > ( res . southwest . latitude ) ; expectType < number > ( res . northeast . longitude ) ; expectType < number > ( res . northeast . latitude ) ; } , } ) ; } { App ( { onThemeChange ( res ) { expectType < 'light' | 'dark' > ( res . theme ) ; } , } ) ; } { Page ( { onAddToFavorites ( res ) { if ( res . webviewUrl ) { expectType < string > ( res . webviewUrl ) ; } return { title : '自定义标题' , imageUrl : 'http://demo.png' , query : 'name=xxx&age=xxx' , } ; } , } ) ; } { wx . requestPayment ( { timeStamp : '' , nonceStr : '' , package : '' , signType : 'MD5' , paySign : '' , } ) ; wx . requestPayment ( { timeStamp : '' , nonceStr : '' , package : '' , signType : 'RSA' , paySign : '' , } ) ; } { wx . saveFile ( { tempFilePath : '' , success ( res ) { expectType < string > ( res . savedFilePath ) ; } } ) ; } { Page ( { onShareTimeline ( ) { return { title : '' , query : '' , imageUrl : '' , } ; } , } ) ; } { Component ( { properties : { bar : { type : Object , value : { skuNum : 0 } , observer ( ) { } } } , data : { foo : 123 , } , methods : { getDataOrPoperty ( ) { return this . data . foo ; } , test ( ) { expectType < Record < string , any > > ( this . data . bar ) ; expectType < number > ( this . getDataOrPoperty ( ) ) ; } , } } ) ; } { requirePlugin ( 'myPlugin' ) ; requireMiniProgram ( ) ; } { wx . requestSubscribeMessage ( { tmplIds : [ '1' , '2' ] , success : ( res ) => { expectType < string > ( res . errMsg ) ; expectType < string > ( res . whatever ) ; expectType < string > ( res . randomTemplateId ) ; } , } ) ; } { Page ( { test ( ) { const observer = wx . createIntersectionObserver ( this ) ; observer . observe ( '' , e => { expectType < string > ( e . id ) ; expectType < Record < string , any > > ( e . dataset ) ; } ) ; } } ) ; }