import { expectType } from 'tsd' ; { Page ( { animation : { } as WechatMiniprogram . Animation , data : { animationData : { } , } , onShow ( ) { const animation = wx . createAnimation ( { duration : 1000 , timingFunction : 'ease' , } ) ; this . animation = animation ; animation . scale ( 2 , 2 ) . rotate ( 45 ) . step ( ) ; this . setData ( { animationData : animation . export ( ) , } ) ; setTimeout ( ( ) => { animation . translate ( 30 ) . step ( ) ; this . setData ( { animationData : animation . export ( ) , } ) ; } , 1000 ) ; } , rotateAndScale ( ) { this . animation . rotate ( 45 ) . scale ( 2 , 2 ) . step ( ) ; this . setData ( { animationData : this . animation . export ( ) , } ) ; } , rotateThenScale ( ) { this . animation . rotate ( 45 ) . step ( ) ; this . animation . scale ( 2 , 2 ) . step ( ) ; this . setData ( { animationData : this . animation . export ( ) , } ) ; } , rotateAndScaleThenTranslate ( ) { this . animation . rotate ( 45 ) . scale ( 2 , 2 ) . step ( ) ; this . animation . translate ( 100 , 100 ) . step ( { duration : 1000 } ) ; this . setData ( { animationData : this . animation . export ( ) , } ) ; } , } ) ; } { Page ( { audioCtx : { } as WechatMiniprogram . AudioContext , onReady ( ) { this . audioCtx = wx . createAudioContext ( 'myAudio' ) ; this . audioCtx . setSrc ( 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46' ) ; this . audioCtx . play ( ) ; } , data : { src : '' , } , audioPlay ( ) { this . audioCtx . play ( ) ; } , audioPause ( ) { this . audioCtx . pause ( ) ; } , audio14 ( ) { this . audioCtx . seek ( 14 ) ; } , audioStart ( ) { this . audioCtx . seek ( 0 ) ; } , } ) ; } { const backgroundAudioManager = wx . getBackgroundAudioManager ( ) ; backgroundAudioManager . title = '此时此刻' ; backgroundAudioManager . epname = '此时此刻' ; backgroundAudioManager . singer = '许巍' ; backgroundAudioManager . coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000' ; backgroundAudioManager . src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' ; } { const context = wx . createCameraContext ( ) ; const listener = context . onCameraFrame ( frame => { expectType < ArrayBuffer > ( frame . data ) ; expectType < number > ( frame . width ) ; expectType < number > ( frame . height ) ; } ) ; listener . start ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; const grd = ctx . createLinearGradient ( 30 , 10 , 120 , 10 ) ; grd . addColorStop ( 0 , 'red' ) ; grd . addColorStop ( 0.16 , 'orange' ) ; grd . addColorStop ( 0.33 , 'yellow' ) ; grd . addColorStop ( 0.5 , 'green' ) ; grd . addColorStop ( 0.66 , 'cyan' ) ; grd . addColorStop ( 0.83 , 'blue' ) ; grd . addColorStop ( 1 , 'purple' ) ; ctx . setFillStyle ( grd ) ; ctx . fillRect ( 10 , 10 , 150 , 80 ) ; ctx . draw ( ) ; } { const downloadTask = wx . downloadFile ( { url : 'http://example.com/audio/123' , success ( res ) { wx . playVoice ( { filePath : res . tempFilePath , } ) ; } , } ) ; downloadTask . onProgressUpdate ( res => { expectType < number > ( res . progress ) ; expectType < number > ( res . totalBytesWritten ) ; expectType < number > ( res . totalBytesExpectedToWrite ) ; } ) ; downloadTask . abort ( ) ; } { const innerAudioContext = wx . createInnerAudioContext ( ) ; innerAudioContext . autoplay = true ; innerAudioContext . src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' ; innerAudioContext . onPlay ( ( ) => { console . log ( '开始播放' ) ; } ) ; innerAudioContext . onError ( res => { expectType < string > ( res . errMsg ) ; res . errCode ; } ) ; } { Page ( { getRect ( ) { wx . createSelectorQuery ( ) . select ( '#the-id' ) . boundingClientRect ( function ( rect ) { rect . id ; rect . dataset ; rect . left ; rect . right ; rect . top ; rect . bottom ; rect . width ; rect . height ; } ) . exec ( ) ; } , getAllRects ( ) { } , } ) ; } { Page ( { getContext ( ) { wx . createSelectorQuery ( ) . select ( '.the-video-class' ) . context ( function ( res ) { const context = res . context as WechatMiniprogram . VideoContext ; context . seek ( 0 ) ; } ) . exec ( ) ; } , } ) ; } { Page ( { getFields ( ) { wx . createSelectorQuery ( ) . select ( '#the-id' ) . fields ( { dataset : true , size : true , scrollOffset : true , properties : [ 'scrollX' , 'scrollY' ] , computedStyle : [ 'margin' , 'backgroundColor' ] , context : true , } , function ( res ) { res . dataset ; res . width ; res . height ; res . scrollLeft ; res . scrollTop ; res . scrollX ; res . scrollY ; res . margin ; res . backgroundColor ; res . context ; } ) . exec ( ) ; } , } ) ; } { Page ( { getNode ( ) { wx . createSelectorQuery ( ) . select ( '.canvas' ) . node ( function ( res ) { const canvas = res . node as WechatMiniprogram . Canvas ; canvas ; } ) . exec ( ) ; } , } ) ; } { Page ( { getScrollOffset ( ) { wx . createSelectorQuery ( ) . selectViewport ( ) . scrollOffset ( function ( res ) { res . id ; res . dataset ; res . scrollLeft ; res . scrollTop ; } ) . exec ( ) ; } , } ) ; } { const recorderManager = wx . getRecorderManager ( ) ; recorderManager . onStart ( ( ) => { console . log ( 'recorder start' ) ; } ) ; recorderManager . onPause ( ( ) => { console . log ( 'recorder pause' ) ; } ) ; recorderManager . onStop ( res => { console . log ( 'recorder stop' , res ) ; const { tempFilePath } = res ; expectType < string > ( tempFilePath ) ; } ) ; recorderManager . onFrameRecorded ( res => { const { frameBuffer } = res ; expectType < number > ( frameBuffer . byteLength ) ; console . log ( 'frameBuffer.byteLength' , frameBuffer . byteLength ) ; } ) ; recorderManager . start ( { duration : 10000 , sampleRate : 44100 , numberOfChannels : 1 , encodeBitRate : 192000 , format : 'aac' , frameSize : 50 , } ) ; } { const requestTask = wx . request ( { url : 'test.php' , data : { x : '' , y : '' , } , header : { 'content-type' : 'application/json' , } , success ( res ) { console . log ( res . data ) ; } , } ) ; requestTask . abort ( ) ; } { Component ( { methods : { queryMultipleNodes ( ) { const query = wx . createSelectorQuery ( ) . in ( this ) ; query . select ( '#the-id' ) . boundingClientRect ( function ( res ) { res . top ; } ) . exec ( ) ; } , } , } ) ; } { const updateManager = wx . getUpdateManager ( ) ; updateManager . onCheckForUpdate ( function ( res ) { expectType < boolean > ( res . hasUpdate ) ; } ) ; updateManager . onUpdateReady ( function ( ) { wx . showModal ( { title : '更新提示' , content : '新版本已经准备好，是否重启应用？' , success ( res ) { if ( res . confirm ) { updateManager . applyUpdate ( ) ; } } , } ) ; } ) ; updateManager . onUpdateFailed ( function ( ) { } ) ; } { const uploadTask = wx . uploadFile ( { url : 'http://example.weixin.qq.com/upload' , filePath : '' , name : 'file' , formData : { user : 'test' , } , success ( res ) { expectType < string > ( res . data ) ; } , } ) ; uploadTask . onProgressUpdate ( res => { expectType < number > ( res . progress ) ; expectType < number > ( res . totalBytesSent ) ; expectType < number > ( res . totalBytesExpectedToSend ) ; } ) ; uploadTask . abort ( ) ; } { const getRandomColor = ( ) => { const rgb = [ ] ; for ( let i = 0 ; i < 3 ; ++ i ) { let color = Math . floor ( Math . random ( ) * 256 ) . toString ( 16 ) ; color = color . length === 1 ? '0' + color : color ; rgb . push ( color ) ; } return '#' + rgb . join ( '' ) ; } ; Page ( { videoContext : { } as WechatMiniprogram . VideoContext , onReady ( ) { this . videoContext = wx . createVideoContext ( 'myVideo' ) ; } , inputValue : '' , bindInputBlur ( e ) { this . inputValue = e . detail . value ; } , bindSendDanmu ( ) { this . videoContext . sendDanmu ( { text : this . inputValue , color : getRandomColor ( ) , } ) ; } , } ) ; } { const worker = wx . createWorker ( '' ) ; worker . postMessage ( { msg : 'hello from worker' , } ) ; } { const worker = wx . createWorker ( 'workers/request/index.js' ) ; worker . onMessage ( function ( res ) { expectType < WechatMiniprogram . WorkerOnMessageCallbackResult > ( res ) ; } ) ; worker . onProcessKilled ( function ( ) { console . log ( 'worker has been killed' ) ; } ) ; worker . postMessage ( { msg : 'hello worker' , } ) ; worker . terminate ( ) ; } { wx . addCard ( { cardList : [ { cardId : '' , cardExt : '{"code": "", "openid": "", "timestamp": "", "signature":""}' , } , { cardId : '' , cardExt : '{"code": "", "openid": "", "timestamp": "", "signature":""}' , } , ] , success ( res ) { res . cardList . forEach ( card => { expectType < string > ( card . cardExt ) ; expectType < string > ( card . cardId ) ; } ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { if ( ! res . authSetting [ 'scope.record' ] ) { wx . authorize ( { scope : 'scope.record' , success ( ) { wx . startRecord ( { success ( ) { } , } ) ; } , } ) ; } } , } ) ; } { wx . authorizeForMiniProgram ( { scope : 'scope.record' , success ( ) { wx . startRecord ( ) ; } , } ) ; } { wx . canIUse ( 'console.log' ) ; wx . canIUse ( 'CameraContext.onCameraFrame' ) ; wx . canIUse ( 'CameraFrameListener.start' ) ; wx . canIUse ( 'Image.src' ) ; wx . canIUse ( 'openBluetoothAdapter' ) ; wx . canIUse ( 'getSystemInfoSync.return.safeArea.left' ) ; wx . canIUse ( 'getSystemInfo.success.screenWidth' ) ; wx . canIUse ( 'showToast.object.image' ) ; wx . canIUse ( 'onCompassChange.callback.direction' ) ; wx . canIUse ( 'request.object.method.GET' ) ; wx . canIUse ( 'live-player' ) ; wx . canIUse ( 'text.selectable' ) ; wx . canIUse ( 'button.open-type.contact' ) ; } { 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 . checkIsSoterEnrolledInDevice ( { checkAuthMode : 'fingerPrint' , success ( res ) { expectType < boolean > ( res . isEnrolled ) ; } , } ) ; } { wx . checkIsSupportSoterAuthentication ( { success ( res ) { res . supportMode = [ ] ; res . supportMode = [ 'fingerPrint' ] ; res . supportMode = [ 'fingerPrint' , 'facial' ] ; } , } ) ; } { wx . checkSession ( { success ( ) { } , fail ( ) { wx . login ( ) ; } , } ) ; } { wx . chooseAddress ( { success ( res ) { expectType < string > ( res . userName ) ; expectType < string > ( res . postalCode ) ; expectType < string > ( res . provinceName ) ; expectType < string > ( res . cityName ) ; expectType < string > ( res . countyName ) ; expectType < string > ( res . detailInfo ) ; expectType < string > ( res . nationalCode ) ; expectType < string > ( res . telNumber ) ; } , } ) ; } { wx . chooseInvoiceTitle ( { success ( ) { } , } ) ; } { wx . chooseVideo ( { sourceType : [ 'album' , 'camera' ] , maxDuration : 60 , camera : 'back' , success ( res ) { expectType < string > ( res . tempFilePath ) ; } , } ) ; } { wx . clearStorage ( ) ; } { wx . clearStorage ( ) ; } { wx . closeBLEConnection ( { deviceId : '' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . closeBluetoothAdapter ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . connectSocket ( { url : 'test.php' , } ) ; wx . onSocketOpen ( function ( ) { wx . closeSocket ( ) ; } ) ; wx . onSocketClose ( function ( res ) { expectType < number > ( res . code ) ; expectType < string > ( res . reason ) ; console . log ( 'WebSocket 已关闭！' ) ; } ) ; } { wx . compressImage ( { src : '' , quality : 80 , } ) ; } { wx . connectSocket ( { url : 'wss://example.qq.com' , header : { 'content-type' : 'application/json' , } , protocols : [ 'protocol1' ] , } ) ; } { wx . connectWifi ( { SSID : '' , password : '' , success ( res ) { expectType < string > ( res . errMsg ) ; } , } ) ; } { wx . createBLEConnection ( { deviceId : '' , success ( res ) { console . log ( res ) ; } , } ) ; } { const query = wx . createSelectorQuery ( ) ; query . select ( '#the-id' ) . boundingClientRect ( ) ; query . selectViewport ( ) . scrollOffset ( ) ; query . exec ( function ( res ) { res [ 0 ] . top ; res [ 1 ] . scrollTop ; } ) ; } { wx . downloadFile ( { url : 'https://example.com/audio/123' , success ( res ) { if ( res . statusCode === 200 ) { wx . playVoice ( { filePath : res . tempFilePath , } ) ; } } , } ) ; } { const accountInfo = wx . getAccountInfoSync ( ) ; expectType < string > ( accountInfo . miniProgram . appId ) ; expectType < string > ( accountInfo . plugin . appId ) ; expectType < string > ( accountInfo . plugin . version ) ; } { wx . getBLEDeviceCharacteristics ( { deviceId : '' , serviceId : '' , success ( res ) { res . characteristics . forEach ( characteristic => { expectType < boolean > ( characteristic . properties . indicate ) ; expectType < boolean > ( characteristic . properties . notify ) ; expectType < boolean > ( characteristic . properties . read ) ; expectType < boolean > ( characteristic . properties . write ) ; expectType < string > ( characteristic . uuid ) ; } ) ; } , } ) ; } { wx . getBLEDeviceServices ( { deviceId : '' , success ( res ) { res . services . forEach ( service => { expectType < string > ( service . uuid ) ; expectType < boolean > ( service . isPrimary ) ; } ) ; } , } ) ; } { wx . getBackgroundAudioPlayerState ( { success ( res ) { expectType < 0 | 1 | 2 > ( res . status ) ; expectType < string > ( res . dataUrl ) ; expectType < number > ( res . currentPosition ) ; expectType < number > ( res . duration ) ; expectType < number > ( res . downloadPercent ) ; } , } ) ; } { wx . getBluetoothAdapterState ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . getBluetoothDevices ( { success ( res ) { res . devices . forEach ( device => { expectType < ArrayBuffer > ( device . advertisData ) ; } ) ; } , } ) ; } { wx . getClipboardData ( { success ( res ) { expectType < string > ( res . data ) ; } , } ) ; } { wx . getConnectedBluetoothDevices ( { services : [ '' ] , success ( res ) { res . devices . forEach ( device => { expectType < string > ( device . deviceId ) ; expectType < string > ( device . name ) ; } ) ; } , } ) ; } { wx . getFileInfo ( { filePath : '' , success ( res ) { expectType < number > ( res . size ) ; expectType < string > ( res . digest ) ; } , } ) ; } { wx . getHCEState ( { success ( res ) { expectType < string > ( res . errMsg ) ; } , } ) ; } { wx . getImageInfo ( { src : 'images/a.jpg' , success ( res ) { expectType < number > ( res . width ) ; expectType < number > ( res . height ) ; } , } ) ; wx . chooseImage ( { success ( res ) { wx . getImageInfo ( { src : res . tempFilePaths [ 0 ] , success ( res ) { expectType < number > ( res . width ) ; expectType < number > ( res . height ) ; } , } ) ; } , } ) ; } { const logger = wx . getLogManager ( { level : 1 } ) ; logger . log ( { str : 'hello world' } , 'basic log' , 100 , [ 1 , 2 , 3 ] ) ; logger . info ( { str : 'hello world' } , 'info log' , 100 , [ 1 , 2 , 3 ] ) ; logger . debug ( { str : 'hello world' } , 'debug log' , 100 , [ 1 , 2 , 3 ] ) ; logger . warn ( { str : 'hello world' } , 'warn log' , 100 , [ 1 , 2 , 3 ] ) ; } { wx . getNetworkType ( { success ( res ) { res . networkType ; } , } ) ; } { { const logger = wx . getRealtimeLogManager ( ) ; logger . info ( { str : 'hello world' } , 'info log' , 100 , [ 1 , 2 , 3 ] ) ; logger . error ( { str : 'hello world' } , 'error log' , 100 , [ 1 , 2 , 3 ] ) ; logger . warn ( { str : 'hello world' } , 'warn log' , 100 , [ 1 , 2 , 3 ] ) ; } { const logManager = wx . getRealtimeLogManager ( ) ; const logger = logManager . tag ( 'plugin-log1' ) ; logger . info ( 'key1' , 'value1' ) ; logger . error ( 'key2' , { str : 'value2' } ) ; logger . warn ( 'key3' , 'value3' ) ; } } { wx . getSavedFileList ( { success ( res ) { res . fileList ; } , } ) ; } { wx . getSavedFileList ( { success ( res ) { res . fileList ; } , } ) ; } { wx . getSelectedTextRange ( { success ( res ) { expectType < number > ( res . start ) ; expectType < number > ( res . end ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { expectType < boolean | undefined > ( res . authSetting [ 'scope.address' ] ) ; expectType < boolean > ( res . subscriptionsSetting . mainSwitch ) ; expectType < Record < string , any > | undefined > ( res . subscriptionsSetting . itemSettings ) ; } , } ) ; } { wx . getSetting ( { withSubscriptions : true , success ( res ) { expectType < undefined | boolean > ( res . authSetting [ 'scope.userInfo' ] ) ; expectType < undefined | boolean > ( res . authSetting [ 'scope.userLocation' ] ) ; expectType < boolean > ( res . subscriptionsSetting . mainSwitch ) ; if ( res . subscriptionsSetting . itemSettings !== undefined ) { expectType < any > ( res . subscriptionsSetting . itemSettings . SYS_MSG_TYPE_INTERACTIVE ) ; } } , } ) ; } { wx . getStorageInfo ( { success ( res ) { expectType < string [ ] > ( res . keys ) ; expectType < number > ( res . currentSize ) ; expectType < number > ( res . limitSize ) ; } , } ) ; } { wx . getStorageInfo ( { success ( res ) { expectType < string [ ] > ( res . keys ) ; expectType < number > ( res . currentSize ) ; expectType < number > ( res . limitSize ) ; } , } ) ; } { wx . getStorage ( { key : 'key' , success ( res ) { expectType < any > ( res . data ) ; } , } ) ; } { wx . getStorage ( { key : 'key' , success ( res ) { expectType < any > ( res . data ) ; } , } ) ; } { wx . getSystemInfo ( { success ( res ) { expectType < string > ( res . model ) ; expectType < number > ( res . pixelRatio ) ; expectType < number > ( res . windowWidth ) ; expectType < number > ( res . windowHeight ) ; expectType < string > ( res . language ) ; expectType < string > ( res . version ) ; expectType < string > ( res . platform ) ; } , } ) ; } { wx . getSystemInfo ( { success ( res ) { expectType < string > ( res . model ) ; expectType < number > ( res . pixelRatio ) ; expectType < number > ( res . windowWidth ) ; expectType < number > ( res . windowHeight ) ; expectType < string > ( res . language ) ; expectType < string > ( res . version ) ; expectType < string > ( res . platform ) ; } , } ) ; } { wx . getSystemInfoAsync ( { success ( res ) { expectType < string > ( res . model ) ; expectType < number > ( res . pixelRatio ) ; expectType < number > ( res . windowWidth ) ; expectType < number > ( res . windowHeight ) ; expectType < string > ( res . language ) ; expectType < string > ( res . version ) ; expectType < string > ( res . platform ) ; } } ) ; } { wx . getUserInfo ( { success ( res ) { const userInfo = res . userInfo ; expectType < string > ( userInfo . nickName ) ; expectType < string > ( userInfo . avatarUrl ) ; expectType < 0 | 1 | 2 > ( userInfo . gender ) ; expectType < string > ( userInfo . province ) ; expectType < string > ( userInfo . city ) ; expectType < string > ( userInfo . country ) ; } , } ) ; } { wx . getWeRunData ( { success ( res ) { expectType < string > ( res . encryptedData ) ; expectType < string > ( res . cloudID ) ; } , } ) ; } { wx . hideKeyboard ( { complete : res => { console . log ( 'hideKeyboard res' , res ) ; } , } ) ; } { wx . hideShareMenu ( ) ; } { wx . hideShareMenu ( { menus : [ 'shareAppMessage' , 'shareTimeline' ] , } ) ; } { wx . loadFontFace ( { family : 'Bitstream Vera Serif Bold' , source : 'url("https://sungd.github.io/Pacifico.ttf")' , success : console . log , } ) ; } { wx . login ( { success ( res ) { if ( res . code ) { wx . request ( { url : 'https://example.com/onLogin' , data : { code : res . code , } , } ) ; } else { console . log ( '登录失败！' + res . errMsg ) ; } } , } ) ; } { wx . makePhoneCall ( { phoneNumber : '1340000' , } ) ; } { wx . navigateBackMiniProgram ( { extraData : { foo : 'bar' , } , success ( ) { } , } ) ; } { wx . navigateToMiniProgram ( { appId : '' , path : 'page/index/index?id=123' , extraData : { foo : 'bar' , } , envVersion : 'develop' , success ( ) { } , } ) ; } { wx . navigateTo ( { url : 'test?id=1' , events : { acceptDataFromOpenedPage ( data ) { console . log ( data ) ; } , someEvent ( data ) { console . log ( data ) ; } , } , success ( res ) { res . eventChannel . emit ( 'acceptDataFromOpenerPage' , { data : 'test' } ) ; } , } ) ; } { Component ( { methods : { doSth ( ) { this . setData ( { number : 1 } ) ; wx . nextTick ( ( ) => { this . setData ( { number : 3 } ) ; } ) ; this . setData ( { number : 2 } ) ; } , } , } ) ; } { wx . notifyBLECharacteristicValueChange ( { state : true , deviceId : '' , serviceId : '' , characteristicId : '' , success ( res ) { console . log ( 'notifyBLECharacteristicValueChange success' , res . errMsg ) ; } , } ) ; } { wx . onAccelerometerChange ( function ( res ) { expectType < number > ( res . x ) ; expectType < number > ( res . y ) ; expectType < number > ( res . z ) ; } ) ; } { wx . onBLECharacteristicValueChange ( function ( res ) { expectType < string > ( res . characteristicId ) ; expectType < ArrayBuffer > ( res . value ) ; console . log ( `characteristic ${ res . characteristicId } has changed, now is ${ res . value }` ) ; expectType < ArrayBuffer > ( res . value ) ; } ) ; } { wx . onBLEConnectionStateChange ( function ( res ) { console . log ( `device ${ res . deviceId } state has changed, connected: ${ res . connected }` ) ; } ) ; } { wx . onBluetoothAdapterStateChange ( function ( res ) { console . log ( 'adapterState changed, now is' , res ) ; } ) ; } { wx . onBluetoothDeviceFound ( function ( res ) { const { devices } = res ; console . log ( 'new device list has founded' ) ; devices . forEach ( device => { expectType < number > ( device . RSSI ) ; expectType < ArrayBuffer > ( device . advertisData ) ; expectType < string [ ] > ( device . advertisServiceUUIDs ) ; expectType < string > ( device . deviceId ) ; expectType < string > ( device . localName ) ; expectType < string > ( device . name ) ; expectType < Record < string , any > > ( device . serviceData ) ; } ) ; } ) ; } { wx . onKeyboardHeightChange ( res => { expectType < number > ( res . height ) ; } ) ; } { const _locationChangeFn = function ( res ) { console . log ( 'location change' , res ) ; } ; wx . onLocationChange ( _locationChangeFn ) ; wx . offLocationChange ( _locationChangeFn ) ; } { wx . onNetworkStatusChange ( function ( res ) { expectType < boolean > ( res . isConnected ) ; res . networkType ; } ) ; } { wx . onUserCaptureScreen ( function ( ) { console . log ( '用户截屏了' ) ; } ) ; } { wx . openBluetoothAdapter ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . openCard ( { cardList : [ { cardId : '' , code : '' , } , { cardId : '' , code : '' , } , ] , success ( ) { } , } ) ; } { wx . openSetting ( { success ( res ) { expectType < WechatMiniprogram . AuthSetting > ( res . authSetting ) ; res . authSetting = { 'scope.userInfo' : true , 'scope.userLocation' : true , } ; } , } ) ; } { wx . pageScrollTo ( { scrollTop : 0 , duration : 300 , } ) ; } { wx . pauseBackgroundAudio ( ) ; } { wx . startRecord ( { success ( res ) { const tempFilePath = res . tempFilePath ; wx . playVoice ( { filePath : tempFilePath , } ) ; setTimeout ( ( ) => { wx . pauseVoice ( ) ; } , 5000 ) ; } , } ) ; } { wx . playBackgroundAudio ( { dataUrl : '' , title : '' , coverImgUrl : '' , } ) ; } { wx . startRecord ( { success ( res ) { const tempFilePath = res . tempFilePath ; wx . playVoice ( { filePath : tempFilePath , complete ( ) { } , } ) ; } , } ) ; } { wx . previewImage ( { current : '' , urls : [ ] , } ) ; } { wx . reLaunch ( { url : 'test?id=1' , } ) ; } { wx . onBLECharacteristicValueChange ( function ( characteristic ) { console . log ( 'characteristic value comed:' , characteristic ) ; } ) ; wx . readBLECharacteristicValue ( { deviceId : '' , serviceId : '' , characteristicId : '' , success ( res ) { console . log ( 'readBLECharacteristicValue:' , res . errCode ) ; } , } ) ; } { wx . redirectTo ( { url : 'test?id=1' , } ) ; } { wx . getSavedFileList ( { success ( res ) { if ( res . fileList . length > 0 ) { wx . removeSavedFile ( { filePath : res . fileList [ 0 ] . filePath , complete ( res ) { console . log ( res ) ; } , } ) ; } } , } ) ; } { wx . removeStorage ( { key : 'key' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . removeStorage ( { key : 'key' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . reportAnalytics ( 'purchase' , { price : 120 , color : 'red' , } ) ; } { wx . reportMonitor ( '1' , 1 ) ; } { wx . requestPayment ( { timeStamp : '' , nonceStr : '' , package : '' , signType : 'MD5' , paySign : '' , success ( ) { } , fail ( ) { } , } ) ; } { wx . requestSubscribeMessage ( { tmplIds : [ '' ] , success ( res ) { expectType < string > ( res . errMsg ) ; expectType < string > ( res . anyTemplateId ) ; } } ) ; } { wx . request ( { url : 'example.php' , data : { x : '' , y : '' , } , header : { 'content-type' : 'application/json' , } , success ( res ) { console . log ( res . data ) ; } , } ) ; } { wx . chooseImage ( { success ( res ) { const tempFilePaths = res . tempFilePaths ; wx . saveFile ( { tempFilePath : tempFilePaths [ 0 ] , success ( res ) { res . savedFilePath ; } , } ) ; } , } ) ; } { wx . saveImageToPhotosAlbum ( { filePath : '' , success ( ) { } , } ) ; } { wx . saveVideoToPhotosAlbum ( { filePath : 'wxfile://xxx' , success ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { wx . scanCode ( { success ( res ) { console . log ( res ) ; } , } ) ; wx . scanCode ( { onlyFromCamera : true , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . seekBackgroundAudio ( { position : 30 , } ) ; } { const buffer = new ArrayBuffer ( 1 ) ; const dataView = new DataView ( buffer ) ; dataView . setUint8 ( 0 , 0 ) ; wx . startHCE ( { aid_list : [ '' ] , success ( ) { wx . onHCEMessage ( function ( res ) { if ( res . messageType === 1 ) { wx . sendHCEMessage ( { data : buffer } ) ; } } ) ; } , } ) ; } { let socketOpen = false ; let socketMsgQueue = [ ] ; wx . connectSocket ( { url : 'test.php' , } ) ; wx . onSocketOpen ( function ( ) { socketOpen = true ; socketMsgQueue . forEach ( socketMsg => { sendSocketMessage ( socketMsg ) ; } ) ; socketMsgQueue = [ ] ; } ) ; const sendSocketMessage = ( msg ) => { if ( socketOpen ) { wx . sendSocketMessage ( { data : msg , } ) ; } else { socketMsgQueue . push ( msg ) ; } } ; } { wx . setBackgroundColor ( { backgroundColor : '#ffffff' , } ) ; wx . setBackgroundColor ( { backgroundColorTop : '#ffffff' , backgroundColorBottom : '#ffffff' , } ) ; } { wx . setBackgroundTextStyle ( { textStyle : 'dark' , } ) ; } { wx . setClipboardData ( { data : 'data' , success ( ) { wx . getClipboardData ( { success ( res ) { console . log ( res . data ) ; } , } ) ; } , } ) ; } { wx . setKeepScreenOn ( { keepScreenOn : true , } ) ; } { wx . setNavigationBarTitle ( { title : '当前页面' , } ) ; } { wx . setStorage ( { key : 'key' , data : 'value' , } ) ; } { wx . setStorage ( { key : 'key' , data : 'value' , } ) ; } { wx . setTabBarBadge ( { index : 0 , text : '1' , } ) ; } { wx . setTabBarItem ( { index : 0 , text : 'text' , iconPath : '/path/to/iconPath' , selectedIconPath : '/path/to/selectedIconPath' , } ) ; } { wx . setTabBarStyle ( { color : '#FF0000' , selectedColor : '#00FF00' , backgroundColor : '#0000FF' , borderStyle : 'white' , } ) ; } { wx . setTopBarText ( { text : 'hello, world!' , } ) ; } { wx . onGetWifiList ( function ( res ) { if ( res . wifiList . length ) { wx . setWifiList ( { wifiList : [ { SSID : res . wifiList [ 0 ] . SSID , BSSID : res . wifiList [ 0 ] . BSSID , password : '123456' , } , ] , } ) ; } else { wx . setWifiList ( { wifiList : [ ] , } ) ; } } ) ; wx . getWifiList ( ) ; } { wx . showActionSheet ( { itemList : [ 'A' , 'B' , 'C' ] , success ( res ) { console . log ( res . tapIndex ) ; } , fail ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { wx . showLoading ( { title : '加载中' , } ) ; setTimeout ( function ( ) { wx . hideLoading ( ) ; } , 2000 ) ; } { wx . showModal ( { title : '提示' , content : '这是一个模态弹窗' , success ( res ) { if ( res . confirm ) { console . log ( '用户点击确定' ) ; } else if ( res . cancel ) { console . log ( '用户点击取消' ) ; } } , } ) ; } { wx . showShareMenu ( { withShareTicket : true , } ) ; } { wx . showShareMenu ( { withShareTicket : true , menus : [ 'shareAppMessage' , 'shareTimeline' ] , } ) ; } { wx . showToast ( { title : '成功' , icon : 'success' , duration : 2000 , } ) ; } { wx . startAccelerometer ( { interval : 'game' , } ) ; } { wx . startBeaconDiscovery ( { uuids : [ ] , success ( res ) { res . errMsg ; } , } ) ; } { wx . startBluetoothDevicesDiscovery ( { services : [ 'FEE7' ] , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . startCompass ( ) ; } { wx . startHCE ( { aid_list : [ 'F222222222' ] , success ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { wx . startPullDownRefresh ( ) ; } { wx . startRecord ( { success ( res ) { res . tempFilePath ; } , } ) ; setTimeout ( function ( ) { wx . stopRecord ( ) ; } , 10000 ) ; } { wx . startSoterAuthentication ( { requestAuthModes : [ 'fingerPrint' ] , challenge : '123456' , authContent : '请用指纹解锁' , success ( ) { } , } ) ; } { wx . startWifi ( { success ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { wx . stopAccelerometer ( ) ; } { wx . stopBackgroundAudio ( ) ; } { wx . stopBluetoothDevicesDiscovery ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . stopCompass ( ) ; } { wx . stopHCE ( { success ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { Page ( { onPullDownRefresh ( ) { wx . stopPullDownRefresh ( ) ; } , } ) ; } { wx . startRecord ( { success ( res ) { res . tempFilePath ; } , } ) ; setTimeout ( function ( ) { wx . stopRecord ( ) ; } , 10000 ) ; } { wx . startRecord ( { success ( res ) { const tempFilePath = res . tempFilePath ; wx . playVoice ( { filePath : tempFilePath , } ) ; setTimeout ( ( ) => { wx . stopVoice ( ) ; } , 5000 ) ; } , } ) ; } { wx . stopWifi ( { success ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { wx . switchTab ( { url : '/index' , } ) ; } { wx . updateShareMenu ( { withShareTicket : true , success ( ) { } , } ) ; } { wx . updateShareMenu ( { isPrivateMessage : true , activityId : 'xxx' , templateInfo : { parameterList : [ { name : '' , value : '' , } ] } , success ( ) { } , fail ( ) { } , } ) ; } { wx . chooseImage ( { success ( res ) { const tempFilePaths = res . tempFilePaths ; wx . uploadFile ( { url : 'https://example.weixin.qq.com/upload' , filePath : tempFilePaths [ 0 ] , name : 'file' , formData : { user : 'test' , } , success ( res ) { res . data ; } , } ) ; } , } ) ; } { const buffer = new ArrayBuffer ( 1 ) ; const dataView = new DataView ( buffer ) ; dataView . setUint8 ( 0 , 0 ) ; wx . writeBLECharacteristicValue ( { deviceId : '' , serviceId : '' , characteristicId : '' , value : buffer , success ( res ) { console . log ( 'writeBLECharacteristicValue success' , res . errMsg ) ; } , } ) ; } { const worker = wx . createWorker ( 'workers/request/index.js' ) ; worker . postMessage ( { msg : 'hello from main' , } ) ; } { wx . createWorker ( 'workers/index.js' ) ; } { const worker = wx . createWorker ( 'workers/index.js' , { useExperimentalWorker : true , } ) ; worker . onProcessKilled ( ( ) => { wx . createWorker ( 'workers/index.js' , { useExperimentalWorker : true , } ) ; } ) ; } { try { wx . clearStorageSync ( ) ; } catch ( e ) { } } { try { wx . clearStorageSync ( ) ; } catch ( e ) { } } { try { const res = wx . getStorageInfoSync ( ) ; expectType < string [ ] > ( res . keys ) ; expectType < number > ( res . currentSize ) ; expectType < number > ( res . limitSize ) ; } catch ( e ) { } } { try { const res = wx . getStorageInfoSync ( ) ; expectType < string [ ] > ( res . keys ) ; expectType < number > ( res . currentSize ) ; expectType < number > ( res . limitSize ) ; } catch ( e ) { } } { try { const value = wx . getStorageSync ( 'key' ) ; if ( value ) { } } catch ( e ) { } } { try { const value = wx . getStorageSync ( 'key' ) ; if ( value ) { } } catch ( e ) { } } { try { const res = wx . getSystemInfoSync ( ) ; expectType < string > ( res . model ) ; expectType < number > ( res . pixelRatio ) ; expectType < number > ( res . windowWidth ) ; expectType < number > ( res . windowHeight ) ; expectType < string > ( res . language ) ; expectType < string > ( res . version ) ; expectType < string > ( res . platform ) ; } catch ( e ) { } } { try { const res = wx . getSystemInfoSync ( ) ; expectType < string > ( res . model ) ; expectType < number > ( res . pixelRatio ) ; expectType < number > ( res . windowWidth ) ; expectType < number > ( res . windowHeight ) ; expectType < string > ( res . language ) ; expectType < string > ( res . version ) ; expectType < string > ( res . platform ) ; } catch ( e ) { } } { try { wx . removeStorageSync ( 'key' ) ; } catch ( e ) { } } { try { wx . removeStorageSync ( 'key' ) ; } catch ( e ) { } } { try { wx . setStorageSync ( 'key' , 'value' ) ; } catch ( e ) { } } { try { wx . setStorageSync ( 'key' , 'value' ) ; } catch ( e ) { } } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 100 ) ; ctx . draw ( ) ; ctx . fillRect ( 50 , 50 , 150 , 100 ) ; ctx . draw ( true ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; const grd = ctx . createLinearGradient ( 0 , 0 , 200 , 0 ) ; grd . addColorStop ( 0 , 'red' ) ; grd . addColorStop ( 1 , 'white' ) ; ctx . setFillStyle ( grd ) ; ctx . fillRect ( 10 , 10 , 150 , 80 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; const grd = ctx . createCircularGradient ( 75 , 50 , 50 ) ; grd . addColorStop ( 0 , 'red' ) ; grd . addColorStop ( 1 , 'white' ) ; ctx . setFillStyle ( grd ) ; ctx . fillRect ( 10 , 10 , 150 , 80 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . save ( ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 100 ) ; ctx . restore ( ) ; ctx . fillRect ( 50 , 50 , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . save ( ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 100 ) ; ctx . restore ( ) ; ctx . fillRect ( 50 , 50 , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . rect ( 10 , 10 , 100 , 30 ) ; ctx . setFillStyle ( 'yellow' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . rect ( 10 , 40 , 100 , 30 ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fillRect ( 10 , 70 , 100 , 30 ) ; ctx . rect ( 10 , 100 , 100 , 30 ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 10 ) ; ctx . moveTo ( 10 , 50 ) ; ctx . lineTo ( 100 , 50 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . moveTo ( 10 , 10 ) ; ctx . rect ( 10 , 10 , 100 , 50 ) ; ctx . lineTo ( 110 , 60 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . arc ( 20 , 20 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 200 , 20 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'lightgreen' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 20 , 100 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fill ( ) ; ctx . setFillStyle ( 'black' ) ; ctx . setFontSize ( 12 ) ; ctx . beginPath ( ) ; ctx . moveTo ( 20 , 20 ) ; ctx . lineTo ( 20 , 100 ) ; ctx . lineTo ( 200 , 20 ) ; ctx . setStrokeStyle ( '#AAAAAA' ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . moveTo ( 20 , 20 ) ; ctx . quadraticCurveTo ( 20 , 100 , 200 , 20 ) ; ctx . setStrokeStyle ( 'black' ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . arc ( 20 , 20 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 200 , 20 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'lightgreen' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 20 , 100 , 2 , 0 , 2 * Math . PI ) ; ctx . arc ( 200 , 100 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fill ( ) ; ctx . setFillStyle ( 'black' ) ; ctx . setFontSize ( 12 ) ; ctx . beginPath ( ) ; ctx . moveTo ( 20 , 20 ) ; ctx . lineTo ( 20 , 100 ) ; ctx . lineTo ( 150 , 75 ) ; ctx . moveTo ( 200 , 20 ) ; ctx . lineTo ( 200 , 100 ) ; ctx . lineTo ( 70 , 75 ) ; ctx . setStrokeStyle ( '#AAAAAA' ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . moveTo ( 20 , 20 ) ; ctx . bezierCurveTo ( 20 , 100 , 200 , 100 , 200 , 20 ) ; ctx . setStrokeStyle ( 'black' ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . arc ( 100 , 75 , 50 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( '#EEEEEE' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . moveTo ( 40 , 75 ) ; ctx . lineTo ( 160 , 75 ) ; ctx . moveTo ( 100 , 15 ) ; ctx . lineTo ( 100 , 135 ) ; ctx . setStrokeStyle ( '#AAAAAA' ) ; ctx . stroke ( ) ; ctx . setFontSize ( 12 ) ; ctx . setFillStyle ( 'black' ) ; ctx . fillText ( '0' , 165 , 78 ) ; ctx . fillText ( '0.5*PI' , 83 , 145 ) ; ctx . fillText ( '1*PI' , 15 , 78 ) ; ctx . fillText ( '1.5*PI' , 83 , 10 ) ; ctx . beginPath ( ) ; ctx . arc ( 100 , 75 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'lightgreen' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 100 , 25 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 150 , 75 , 2 , 0 , 2 * Math . PI ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . arc ( 100 , 75 , 50 , 0 , 1.5 * Math . PI ) ; ctx . setStrokeStyle ( '#333333' ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . rect ( 10 , 10 , 150 , 75 ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; wx . downloadFile ( { url : 'http://is5.mzstatic.com/image/thumb/Purple128/v4/75/3b/90/753b907c-b7fb-5877-215a-759bd73691a4/source/50x50bb.jpg' , success ( res ) { ctx . save ( ) ; ctx . beginPath ( ) ; ctx . arc ( 50 , 50 , 25 , 0 , 2 * Math . PI ) ; ctx . clip ( ) ; ctx . drawImage ( res . tempFilePath , 25 , 25 ) ; ctx . restore ( ) ; ctx . draw ( ) ; } , } ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setStrokeStyle ( 'red' ) ; ctx . strokeRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 0 , 0 , 150 , 200 ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fillRect ( 150 , 0 , 150 , 200 ) ; ctx . clearRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 10 ) ; ctx . lineTo ( 100 , 100 ) ; ctx . fill ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . rect ( 10 , 10 , 100 , 30 ) ; ctx . setFillStyle ( 'yellow' ) ; ctx . fill ( ) ; ctx . beginPath ( ) ; ctx . rect ( 10 , 40 , 100 , 30 ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fillRect ( 10 , 70 , 100 , 30 ) ; ctx . rect ( 10 , 100 , 100 , 30 ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 10 ) ; ctx . lineTo ( 100 , 100 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . rect ( 10 , 10 , 100 , 30 ) ; ctx . setStrokeStyle ( 'yellow' ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . rect ( 10 , 40 , 100 , 30 ) ; ctx . setStrokeStyle ( 'blue' ) ; ctx . strokeRect ( 10 , 70 , 100 , 30 ) ; ctx . rect ( 10 , 100 , 100 , 30 ) ; ctx . setStrokeStyle ( 'red' ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 10 ) ; ctx . lineTo ( 100 , 100 ) ; ctx . closePath ( ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . rect ( 10 , 10 , 100 , 30 ) ; ctx . closePath ( ) ; ctx . beginPath ( ) ; ctx . rect ( 10 , 40 , 100 , 30 ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fillRect ( 10 , 70 , 100 , 30 ) ; ctx . rect ( 10 , 100 , 100 , 30 ) ; ctx . setFillStyle ( 'red' ) ; ctx . fill ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . strokeRect ( 10 , 10 , 25 , 15 ) ; ctx . scale ( 2 , 2 ) ; ctx . strokeRect ( 10 , 10 , 25 , 15 ) ; ctx . scale ( 2 , 2 ) ; ctx . strokeRect ( 10 , 10 , 25 , 15 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . strokeRect ( 100 , 10 , 150 , 100 ) ; ctx . rotate ( ( 20 * Math . PI ) / 180 ) ; ctx . strokeRect ( 100 , 10 , 150 , 100 ) ; ctx . rotate ( ( 20 * Math . PI ) / 180 ) ; ctx . strokeRect ( 100 , 10 , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . strokeRect ( 10 , 10 , 150 , 100 ) ; ctx . translate ( 20 , 20 ) ; ctx . strokeRect ( 10 , 10 , 150 , 100 ) ; ctx . translate ( 20 , 20 ) ; ctx . strokeRect ( 10 , 10 , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; wx . chooseImage ( { success ( res ) { ctx . drawImage ( res . tempFilePaths [ 0 ] , 0 , 0 , 150 , 100 ) ; ctx . draw ( ) ; } , } ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . setShadow ( 10 , 50 , 50 , 'blue' ) ; ctx . fillRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 100 ) ; ctx . setGlobalAlpha ( 0.2 ) ; ctx . setFillStyle ( 'blue' ) ; ctx . fillRect ( 50 , 50 , 150 , 100 ) ; ctx . setFillStyle ( 'yellow' ) ; ctx . fillRect ( 100 , 100 , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 150 , 10 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 5 ) ; ctx . moveTo ( 10 , 30 ) ; ctx . lineTo ( 150 , 30 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 10 , 50 ) ; ctx . lineTo ( 150 , 50 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 15 ) ; ctx . moveTo ( 10 , 70 ) ; ctx . lineTo ( 150 , 70 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 50 ) ; ctx . lineTo ( 10 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineJoin ( 'bevel' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 50 , 10 ) ; ctx . lineTo ( 140 , 50 ) ; ctx . lineTo ( 50 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineJoin ( 'round' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 90 , 10 ) ; ctx . lineTo ( 180 , 50 ) ; ctx . lineTo ( 90 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineJoin ( 'miter' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 130 , 10 ) ; ctx . lineTo ( 220 , 50 ) ; ctx . lineTo ( 130 , 90 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 150 , 10 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineCap ( 'butt' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 10 , 30 ) ; ctx . lineTo ( 150 , 30 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineCap ( 'round' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 10 , 50 ) ; ctx . lineTo ( 150 , 50 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineCap ( 'square' ) ; ctx . setLineWidth ( 10 ) ; ctx . moveTo ( 10 , 70 ) ; ctx . lineTo ( 150 , 70 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setLineDash ( [ 10 , 20 ] , 5 ) ; ctx . beginPath ( ) ; ctx . moveTo ( 0 , 100 ) ; ctx . lineTo ( 400 , 100 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 10 ) ; ctx . setLineJoin ( 'miter' ) ; ctx . setMiterLimit ( 1 ) ; ctx . moveTo ( 10 , 10 ) ; ctx . lineTo ( 100 , 50 ) ; ctx . lineTo ( 10 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 10 ) ; ctx . setLineJoin ( 'miter' ) ; ctx . setMiterLimit ( 2 ) ; ctx . moveTo ( 50 , 10 ) ; ctx . lineTo ( 140 , 50 ) ; ctx . lineTo ( 50 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 10 ) ; ctx . setLineJoin ( 'miter' ) ; ctx . setMiterLimit ( 3 ) ; ctx . moveTo ( 90 , 10 ) ; ctx . lineTo ( 180 , 50 ) ; ctx . lineTo ( 90 , 90 ) ; ctx . stroke ( ) ; ctx . beginPath ( ) ; ctx . setLineWidth ( 10 ) ; ctx . setLineJoin ( 'miter' ) ; ctx . setMiterLimit ( 4 ) ; ctx . moveTo ( 130 , 10 ) ; ctx . lineTo ( 220 , 50 ) ; ctx . lineTo ( 130 , 90 ) ; ctx . stroke ( ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFontSize ( 20 ) ; ctx . fillText ( 'Hello' , 20 , 20 ) ; ctx . fillText ( 'MINA' , 100 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFontSize ( 20 ) ; ctx . fillText ( '20' , 20 , 20 ) ; ctx . setFontSize ( 30 ) ; ctx . fillText ( '30' , 40 , 40 ) ; ctx . setFontSize ( 40 ) ; ctx . fillText ( '40' , 60 , 60 ) ; ctx . setFontSize ( 50 ) ; ctx . fillText ( '50' , 90 , 90 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setStrokeStyle ( 'red' ) ; ctx . moveTo ( 150 , 20 ) ; ctx . lineTo ( 150 , 170 ) ; ctx . stroke ( ) ; ctx . setFontSize ( 15 ) ; ctx . setTextAlign ( 'left' ) ; ctx . fillText ( 'textAlign=left' , 150 , 60 ) ; ctx . setTextAlign ( 'center' ) ; ctx . fillText ( 'textAlign=center' , 150 , 80 ) ; ctx . setTextAlign ( 'right' ) ; ctx . fillText ( 'textAlign=right' , 150 , 100 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setStrokeStyle ( 'red' ) ; ctx . moveTo ( 5 , 75 ) ; ctx . lineTo ( 295 , 75 ) ; ctx . stroke ( ) ; ctx . setFontSize ( 20 ) ; ctx . setTextBaseline ( 'top' ) ; ctx . fillText ( 'top' , 5 , 75 ) ; ctx . setTextBaseline ( 'middle' ) ; ctx . fillText ( 'middle' , 50 , 75 ) ; ctx . setTextBaseline ( 'bottom' ) ; ctx . fillText ( 'bottom' , 120 , 75 ) ; ctx . setTextBaseline ( 'normal' ) ; ctx . fillText ( 'normal' , 200 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setFillStyle ( 'red' ) ; ctx . fillRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { const ctx = wx . createCanvasContext ( 'myCanvas' ) ; ctx . setStrokeStyle ( 'red' ) ; ctx . strokeRect ( 10 , 10 , 150 , 75 ) ; ctx . draw ( ) ; } { if ( wx . getExtConfig ) { wx . getExtConfig ( { success ( res ) { console . log ( res . extConfig ) ; } , } ) ; } } { const extConfig = wx . getExtConfigSync ? wx . getExtConfigSync ( ) : { } ; console . log ( extConfig ) ; } { wx . chooseMessageFile ( { count : 10 , type : 'image' , success ( res ) { res . tempFiles . forEach ( tempFile => { expectType < string > ( tempFile . name ) ; expectType < string > ( tempFile . path ) ; expectType < number > ( tempFile . size ) ; expectType < number > ( tempFile . time ) ; } ) ; } , } ) ; } { wx . chooseImage ( { count : 1 , sizeType : [ 'original' , 'compressed' ] , sourceType : [ 'album' , 'camera' ] , success ( res ) { expectType < string [ ] > ( res . tempFilePaths ) ; } , } ) ; } { Page ( { data : { canIUse : wx . canIUse ( 'button.open-type.getUserInfo' ) , } , onLoad ( ) { wx . getSetting ( { success ( res ) { if ( res . authSetting [ 'scope.userInfo' ] ) { wx . getUserInfo ( { success ( res ) { console . log ( res . userInfo ) ; } , } ) ; } } , } ) ; } , bindGetUserInfo ( e ) { console . log ( e . detail . userInfo ) ; } , } ) ; } { Page ( { onLoad ( ) { wx . createIntersectionObserver ( this ) . relativeToViewport ( { bottom : 100 } ) . observe ( '.target-class' , res => { res . intersectionRatio ; res . intersectionRect ; res . intersectionRect . left ; res . intersectionRect . top ; res . intersectionRect . width ; res . intersectionRect . height ; } ) ; } , } ) ; } { wx . createSelectorQuery ( ) . select ( '#editor' ) . context ( res => { const editorCtx = res . context as WechatMiniprogram . EditorContext ; editorCtx . insertImage ( { src : 'xx' , width : '100px' , height : '50px' , extClass : 'className' , } ) ; } ) ; } { Page ( { mapCtx : { } as WechatMiniprogram . MapContext , onReady ( ) { this . mapCtx = wx . createMapContext ( 'myMap' ) ; } , getCenterLocation ( ) { this . mapCtx . getCenterLocation ( { success ( res ) { expectType < number > ( res . longitude ) ; expectType < number > ( res . latitude ) ; } , } ) ; } , moveToLocation ( ) { this . mapCtx . moveToLocation ( { latitude : 0 , longitude : 0 , } ) ; } , translateMarker ( ) { this . mapCtx . translateMarker ( { rotate : 0 , markerId : 0 , autoRotate : true , duration : 1000 , destination : { latitude : 23.10229 , longitude : 113.3345211 , } , animationEnd ( ) { console . log ( 'animation end' ) ; } , } ) ; } , includePoints ( ) { this . mapCtx . includePoints ( { padding : [ 10 ] , points : [ { latitude : 23.10229 , longitude : 113.3345211 , } , { latitude : 23.00229 , longitude : 113.3345211 , } , ] , } ) ; } , } ) ; } { Page ( { mapCtx : { } as WechatMiniprogram . MapContext , onReady ( ) { this . mapCtx = wx . createMapContext ( 'myMap' ) ; } , method ( ) { this . mapCtx . on ( 'markerClusterCreate' , ( res ) => { expectType < any > ( res ) ; } ) ; this . mapCtx . on ( 'markerClusterClick' , ( res ) => { expectType < any > ( res ) ; } ) ; } } ) ; } { wx . setEnableDebug ( { enableDebug : true , } ) ; wx . setEnableDebug ( { enableDebug : false , } ) ; } { Page ( { onLoad ( option ) { console . log ( option . query ) ; const eventChannel = this . getOpenerEventChannel ( ) ; eventChannel . emit ( 'acceptDataFromOpenedPage' , { data : 'test' } ) ; eventChannel . emit ( 'someEvent' , { data : 'test' } ) ; eventChannel . on ( 'acceptDataFromOpenerPage' , function ( data ) { console . log ( data ) ; } ) ; } , } ) ; } { wx . requestSubscribeMessage ( { tmplIds : [ '' ] , success ( res ) { expectType < string > ( res . TEMPLATE_ID ) ; } , } ) ; } { wx . chooseMedia ( { count : 9 , mediaType : [ 'image' , 'video' ] , sourceType : [ 'album' , 'camera' ] , maxDuration : 30 , camera : 'back' , success ( res ) { expectType < string > ( res . tempFiles [ 0 ] . tempFilePath ) ; expectType < string > ( res . tempFiles [ 0 ] . thumbTempFilePath ) ; expectType < number > ( res . tempFiles [ 0 ] . width ) ; expectType < number > ( res . tempFiles [ 0 ] . height ) ; expectType < number > ( res . tempFiles [ 0 ] . size ) ; expectType < number > ( res . tempFiles [ 0 ] . duration ) ; } , } ) ; } { wx . reportPerformance ( 1101 , 680 ) ; wx . reportPerformance ( 1101 , 680 , 'custom' ) ; } { wx . getRandomValues ( { length : 6 , success : res => { expectType < ArrayBuffer > ( res . randomValues ) ; } } ) ; } { wx . getGroupEnterInfo ( { success ( res ) { expectType < string > ( res . errMsg ) ; expectType < string > ( res . encryptedData ) ; expectType < string > ( res . iv ) ; } } ) ; } { const performance = wx . getPerformance ( ) ; const observer = performance . createObserver ( entryList => { console . log ( entryList . getEntries ( ) ) ; } ) ; observer . observe ( { entryTypes : [ 'render' , 'script' ] } ) ; } { wx . authPrivateMessage ( { shareTicket : 'xxxxxx' , success ( res ) { expectType < boolean > ( res . valid ) ; expectType < string > ( res . iv ) ; expectType < string > ( res . encryptedData ) ; } , fail ( res ) { expectType < string > ( res . errMsg ) ; } , } ) ; } { const videoDecoder = wx . createVideoDecoder ( ) ; const mediaAudioPlayer = wx . createMediaAudioPlayer ( ) ; videoDecoder . start ( { source : '' } ) ; mediaAudioPlayer . start ( ) . then ( ( ) => { mediaAudioPlayer . addAudioSource ( videoDecoder ) . then ( res => { videoDecoder . getFrameData ( ) ; console . log ( res ) ; } ) ; mediaAudioPlayer . removeAudioSource ( videoDecoder ) . then ( ) ; mediaAudioPlayer . stop ( ) . then ( ) ; mediaAudioPlayer . destroy ( ) . then ( ) ; mediaAudioPlayer . volume = 0.5 ; } ) ; } { wx . createSelectorQuery ( ) . select ( '#scrollview' ) . node ( ) . exec ( res => { const scrollView = res [ 0 ] . node ; scrollView . scrollEnabled = false ; } ) ; } { Page ( { data : { userInfo : { } , hasUserInfo : false , canIUseGetUserProfile : false , } , onLoad ( ) { if ( wx . getUserProfile !== undefined ) { this . setData ( { canIUseGetUserProfile : true , } ) ; } } , getUserProfile ( ) { wx . getUserProfile ( { desc : '用于完善会员资料' , success : res => { this . setData ( { userInfo : res . userInfo , hasUserInfo : true , } ) ; } , } ) ; } , getUserInfo ( e ) { this . setData ( { userInfo : e . detail . userInfo , hasUserInfo : true , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { fs . close ( { fd : res . fd , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; fs . closeSync ( { fd : fd } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { fs . fstat ( { fd : res . fd , success ( res ) { expectType < WechatMiniprogram . Stats > ( res . stats ) ; } , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; const stats = fs . fstatSync ( { fd : fd } ) ; expectType < WechatMiniprogram . Stats > ( stats ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { fs . ftruncate ( { fd : res . fd , length : 10 , success ( res ) { console . log ( res ) ; } , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; fs . ftruncateSync ( { fd : fd , length : 10 , } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { expectType < string > ( res . fd ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; expectType < string > ( fd ) ; } { const fs = wx . getFileSystemManager ( ) ; const ab = new ArrayBuffer ( 1024 ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { fs . read ( { fd : res . fd , arrayBuffer : ab , length : 10 , success ( res ) { console . log ( res ) ; } , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const ab = new ArrayBuffer ( 1024 ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; const res = fs . readSync ( { fd : fd , arrayBuffer : ab , length : 10 , } ) ; console . log ( res ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . truncate ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , length : 10 , success ( res ) { console . log ( res ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . truncateSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , length : 10 , } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . open ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , success ( res ) { fs . write ( { fd : res . fd , data : 'some text' , success ( res ) { expectType < number > ( res . bytesWritten ) ; } , } ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; const fd = fs . openSync ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , flag : 'a+' , } ) ; const res = fs . writeSync ( { fd : fd , data : 'some text' , } ) ; expectType < number > ( res . bytesWritten ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . access ( { path : `${ wx . env . USER_DATA_PATH }/hello.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . accessSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . access ( { path : `${ wx . env . USER_DATA_PATH }/hello.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . accessSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . appendFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , data : 'some text' , encoding : 'utf8' , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . appendFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'some text' , 'utf8' ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . appendFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , data : 'some text' , encoding : 'utf8' , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . appendFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'some text' , 'utf8' ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . copyFile ( { srcPath : `${ wx . env . USER_DATA_PATH }/hello.txt` , destPath : `${ wx . env . USER_DATA_PATH }/hello_copy.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . copyFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , `${ wx . env . USER_DATA_PATH }/hello_copy.txt` ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . copyFile ( { srcPath : `${ wx . env . USER_DATA_PATH }/hello.txt` , destPath : `${ wx . env . USER_DATA_PATH }/hello_copy.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . copyFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , `${ wx . env . USER_DATA_PATH }/hello_copy.txt` ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . mkdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , recursive : false , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . mkdirSync ( `${ wx . env . USER_DATA_PATH }/example` , false ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . mkdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , recursive : false , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { fs . mkdirSync ( `${ wx . env . USER_DATA_PATH }/example` , false ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . readFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , encoding : 'utf8' , position : 0 , success ( res ) { console . log ( res . data ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . readFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'utf8' , 0 ) ; expectType < string | ArrayBuffer > ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . readFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , encoding : 'utf8' , position : 0 , success ( res ) { console . log ( res . data ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . readFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'utf8' , 0 ) ; expectType < string | ArrayBuffer > ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . readZipEntry ( { filePath : 'wxfile://from/to.zip' , entries : [ { path : 'some_folder/my_file.txt' , encoding : 'utf-8' , position : 0 , length : 10000 , } , { path : 'other_folder/orther_file.txt' , } ] , success ( res ) { console . log ( res . entries ) ; } , fail ( res ) { console . log ( res . errMsg ) ; } , } ) ; fs . readZipEntry ( { filePath : 'wxfile://from/to.zip' , entries : 'all' , encoding : 'utf-8' , success ( res ) { console . log ( res . entries ) ; } , fail ( res ) { console . log ( res . errMsg ) ; } , } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . readdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , success ( res ) { console . log ( res . files ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . readdirSync ( `${ wx . env . USER_DATA_PATH }/example` ) ; expectType < string [ ] > ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . readdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , success ( res ) { console . log ( res . files ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . readdirSync ( `${ wx . env . USER_DATA_PATH }/example` ) ; expectType < string [ ] > ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . rename ( { oldPath : `${ wx . env . USER_DATA_PATH }/hello.txt` , newPath : `${ wx . env . USER_DATA_PATH }/hello_new.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . renameSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , `${ wx . env . USER_DATA_PATH }/hello_new.txt` ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . rename ( { oldPath : `${ wx . env . USER_DATA_PATH }/hello.txt` , newPath : `${ wx . env . USER_DATA_PATH }/hello_new.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . renameSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , `${ wx . env . USER_DATA_PATH }/hello_new.txt` ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . rmdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , recursive : false , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . rmdirSync ( `${ wx . env . USER_DATA_PATH }/example` , false ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . rmdir ( { dirPath : `${ wx . env . USER_DATA_PATH }/example` , recursive : false , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . rmdirSync ( `${ wx . env . USER_DATA_PATH }/example` , false ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { wx . saveFileToDisk ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . unlink ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . unlinkSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . unlink ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . unlinkSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . unzip ( { zipFilePath : `${ wx . env . USER_DATA_PATH }/example.zip` , targetPath : '${wx.env.USER_DATA_PATH}/example' , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; } { const fs = wx . getFileSystemManager ( ) ; fs . writeFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , data : 'some text or arrayBuffer' , encoding : 'utf8' , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . writeFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'some text or arrayBuffer' , 'utf8' ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const fs = wx . getFileSystemManager ( ) ; fs . writeFile ( { filePath : `${ wx . env . USER_DATA_PATH }/hello.txt` , data : 'some text or arrayBuffer' , encoding : 'utf8' , success ( res ) { console . log ( res ) ; } , fail ( res ) { console . error ( res ) ; } } ) ; try { const res = fs . writeFileSync ( `${ wx . env . USER_DATA_PATH }/hello.txt` , 'some text or arrayBuffer' , 'utf8' ) ; console . log ( res ) ; } catch ( e ) { console . error ( e ) ; } } { const userCryptoManager = wx . getUserCryptoManager ( ) ; userCryptoManager . getLatestUserKey ( { success : res => { const { encryptKey , iv , version , expireTime } = res ; console . log ( encryptKey , iv , version , expireTime ) ; } } ) ; } { wx . getRandomValues ( { length : 6 , success : res => { console . log ( wx . arrayBufferToBase64 ( res . randomValues ) ) ; } } ) ; }