import { expectType } from 'tsd' ; { const downloadTask = wx . downloadFile ( { url : 'http://example.com/audio/123' , success ( ) { } , } ) ; downloadTask . onProgressUpdate ( res => { console . log ( '下载进度' , res . progress ) ; console . log ( '已经下载的数据长度' , res . totalBytesWritten ) ; console . log ( '预期需要下载的数据总长度' , 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 => { console . log ( res . errCode ) ; } ) ; } { 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 ; 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 ( ) ; } { const updateManager = wx . getUpdateManager ( ) ; updateManager . onCheckForUpdate ( function ( res ) { console . log ( 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 ) { const data = res . data ; expectType < string > ( data ) ; } , } ) ; uploadTask . onProgressUpdate ( res => { console . log ( '上传进度' , res . progress ) ; console . log ( '已经上传的数据长度' , res . totalBytesSent ) ; console . log ( '预期需要上传的数据总长度' , res . totalBytesExpectedToSend ) ; } ) ; uploadTask . abort ( ) ; } { const worker = wx . createWorker ( 'workers/request/index.js' ) ; worker . postMessage ( { msg : 'hello from worker' , } ) ; } { wx . createWorker ( 'workers/index.js' ) ; } { const worker = wx . createWorker ( 'workers/index.js' , { useExperimentalWorker : true , } ) ; worker . onProcessKilled ( ( ) => { wx . createWorker ( 'workers/index.js' , { useExperimentalWorker : true , } ) ; } ) ; } { const worker = wx . createWorker ( 'workers/request/index.js' ) ; worker . onMessage ( function ( res ) { console . log ( 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 ) { console . log ( res . cardList ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { if ( ! res . authSetting [ 'scope.werun' ] ) { wx . authorize ( { scope : 'scope.werun' , success ( ) { } , } ) ; } } , } ) ; } { wx . checkSession ( { success ( ) { } , fail ( ) { wx . login ( ) ; } , } ) ; } { wx . clearStorage ( ) ; } { wx . clearStorage ( ) ; } { wx . connectSocket ( { url : 'test.php' , } ) ; wx . onSocketOpen ( function ( ) { wx . closeSocket ( ) ; } ) ; wx . onSocketClose ( function ( ) { console . log ( 'WebSocket 已关闭！' ) ; } ) ; } { wx . connectSocket ( { url : 'wss://example.qq.com' , header : { 'content-type' : 'application/json' , } , protocols : [ 'protocol1' ] , } ) ; } { wx . downloadFile ( { url : 'https://example.com/audio/123' , success ( res ) { if ( res . statusCode === 200 ) { } } , } ) ; } { wx . getClipboardData ( { success ( res ) { console . log ( res . data ) ; } , } ) ; } { 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 ) { expectType < 'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none' > ( res . networkType ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { console . log ( res . authSetting ) ; res . authSetting = { 'scope.userInfo' : true , 'scope.userLocation' : true , } ; } , } ) ; } { wx . getStorageInfo ( { success ( res ) { console . log ( res . keys ) ; console . log ( res . currentSize ) ; console . log ( res . limitSize ) ; } , } ) ; } { wx . getStorageInfo ( { success ( res ) { console . log ( res . keys ) ; console . log ( res . currentSize ) ; console . log ( res . limitSize ) ; } , } ) ; } { wx . getStorage ( { key : 'key' , success ( res ) { console . log ( res . data ) ; } , } ) ; } { wx . getStorage ( { key : 'key' , success ( res ) { console . log ( res . data ) ; } , } ) ; } { wx . getSystemInfo ( { success ( res ) { console . log ( res . model ) ; console . log ( res . pixelRatio ) ; console . log ( res . windowWidth ) ; console . log ( res . windowHeight ) ; console . log ( res . language ) ; console . log ( res . version ) ; console . log ( 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 . hideShareMenu ( ) ; } { wx . hideShareMenu ( { menus : [ 'shareAppMessage' , 'shareTimeline' ] , } ) ; } { wx . login ( { success ( res ) { if ( res . code ) { wx . request ( { url : 'https://example.com/onLogin' , data : { code : res . code , } , } ) ; } else { console . log ( '登录失败！' + res . errMsg ) ; } } , } ) ; } { wx . navigateToMiniProgram ( { appId : '' , path : 'page/index/index?id=123' , extraData : { foo : 'bar' , } , envVersion : 'develop' , success ( ) { } , } ) ; } { wx . onAccelerometerChange ( function ( res ) { expectType < number > ( res . x ) ; expectType < number > ( res . y ) ; expectType < number > ( res . z ) ; } ) ; } { wx . onNetworkStatusChange ( function ( res ) { expectType < boolean > ( res . isConnected ) ; expectType < 'wifi' | '2g' | '3g' | '4g' | 'unknown' | 'none' > ( res . networkType ) ; } ) ; } { wx . onUserCaptureScreen ( function ( ) { console . log ( '用户截屏了' ) ; } ) ; } { wx . openCard ( { cardList : [ { cardId : '' , code : '' , } , { cardId : '' , code : '' , } , ] , success ( ) { } , } ) ; } { wx . openSetting ( { success ( res ) { console . log ( res . authSetting ) ; } , } ) ; } { wx . previewImage ( { current : '' , urls : [ ] , } ) ; } { wx . removeStorage ( { key : 'key' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . removeStorage ( { key : 'key' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . request ( { url : 'example.php' , data : { x : '' , y : '' , } , header : { 'content-type' : 'application/json' , } , success ( res ) { console . log ( res . data ) ; } , } ) ; } { wx . saveImageToPhotosAlbum ( { filePath : '' , success ( ) { } , } ) ; } { 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 . setClipboardData ( { data : 'data' , success ( ) { wx . getClipboardData ( { success ( res ) { console . log ( res . data ) ; } , } ) ; } , } ) ; } { wx . setKeepScreenOn ( { keepScreenOn : true , } ) ; } { wx . setStorage ( { key : 'key' , data : 'value' , } ) ; } { wx . setStorage ( { key : 'key' , data : 'value' , } ) ; } { 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 . startCompass ( ) ; } { wx . stopAccelerometer ( ) ; } { wx . stopCompass ( ) ; } { wx . updateShareMenu ( { withShareTicket : true , success ( ) { } , } ) ; } { 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 ) { expectType < string > ( res . data ) ; } , } ) ; } , } ) ; } { const worker = wx . createWorker ( 'workers/request/index.js' ) ; worker . postMessage ( { msg : 'hello from main' , } ) ; } { try { wx . clearStorageSync ( ) ; } catch ( e ) { } } { try { wx . clearStorageSync ( ) ; } catch ( e ) { } } { try { const res = wx . getStorageInfoSync ( ) ; console . log ( res . keys ) ; console . log ( res . currentSize ) ; console . log ( res . limitSize ) ; } catch ( e ) { } } { try { const res = wx . getStorageInfoSync ( ) ; console . log ( res . keys ) ; console . log ( res . currentSize ) ; console . log ( 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 ) { } } { wx . setEnableDebug ( { enableDebug : true , } ) ; wx . setEnableDebug ( { enableDebug : false , } ) ; } { const canvas = wx . createCanvas ( ) ; const gl = canvas . getContext ( 'webgl' ) ; gl . wxBindCanvasTexture ( gl . TEXTURE_2D , canvas ) ; } { const canvas = wx . createCanvas ( ) ; const gl = canvas . getContext ( 'webgl' ) ; const texture = gl . createTexture ( ) ; gl . bindTexture ( gl . TEXTURE_2D , texture ) ; gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , gl . RGBA , gl . UNSIGNED_BYTE , canvas ) ; } { const recorder = wx . getGameRecorder ( ) ; recorder . on ( 'stop' , res => { expectType < any > ( res . duration ) ; } ) ; } { if ( wx . getExtConfig ) { wx . getExtConfig ( { success ( res ) { console . log ( res . extConfig ) ; } , } ) ; } } { const extConfig = wx . getExtConfigSync ? wx . getExtConfigSync ( ) : { } ; console . log ( extConfig ) ; } { wx . chooseImage ( { count : 1 , sizeType : [ 'original' , 'compressed' ] , sourceType : [ 'album' , 'camera' ] , success ( res ) { expectType < string [ ] > ( res . tempFilePaths ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { if ( res . authSetting [ 'scope.userInfo' ] ) { wx . getUserInfo ( { success ( res ) { console . log ( res . userInfo ) ; } , } ) ; } } , } ) ; } { const recorder = wx . getGameRecorder ( ) ; recorder . on ( 'error' , res => { expectType < any > ( res . error . code ) ; } ) ; recorder . stop ( ) . catch ( res => { expectType < any > ( res . error . code ) ; } ) ; } { const recorder = wx . getGameRecorder ( ) ; recorder . on ( 'timeUpdate' , res => { console . log ( res . currentTime ) ; } ) ; } { const recorder = wx . getGameRecorder ( ) ; recorder . on ( 'error' , res => { console . log ( '错误码' , res . error . code ) ; console . log ( '错误信息' , res . error . message ) ; } ) ; } { wx . reportMonitor ( '1' , 1 ) ; } { wx . startBeaconDiscovery ( { uuids : [ ] , success ( ) { } , } ) ; } { wx . closeBLEConnection ( { deviceId : '' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . closeBluetoothAdapter ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . createBLEConnection ( { deviceId : '' , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . getBLEDeviceCharacteristics ( { deviceId : '' , serviceId : '' , success ( res ) { console . log ( 'device getBLEDeviceCharacteristics:' , res . characteristics ) ; } , } ) ; } { wx . getBLEDeviceServices ( { deviceId : '' , success ( res ) { console . log ( 'device services:' , res . services ) ; } , } ) ; } { wx . getBluetoothAdapterState ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . getBluetoothDevices ( { success ( res ) { console . log ( res ) ; if ( res . devices [ 0 ] ) { expectType < ArrayBuffer > ( res . devices [ 0 ] . advertisData ) ; } } , } ) ; } { wx . getConnectedBluetoothDevices ( { services : [ ] , success ( res ) { expectType < WechatMinigame . BluetoothDeviceInfo [ ] > ( res . devices ) ; } , } ) ; } { wx . getFileInfo ( { filePath : '' , success ( res ) { expectType < number > ( res . size ) ; expectType < string > ( res . digest ) ; } , } ) ; } { wx . notifyBLECharacteristicValueChange ( { state : true , deviceId : '' , serviceId : '' , characteristicId : '' , success ( res ) { console . log ( 'notifyBLECharacteristicValueChange success' , res . errMsg ) ; } , } ) ; } { wx . onBLECharacteristicValueChange ( function ( res ) { 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 . devices ; console . log ( 'new device list has founded' ) ; expectType < ArrayBuffer > ( devices [ 0 ] . advertisData ) ; } ) ; } { wx . openBluetoothAdapter ( { success ( res ) { console . log ( res ) ; } , } ) ; } { wx . onBLECharacteristicValueChange ( function ( characteristic ) { console . log ( 'characteristic value comed:' , characteristic ) ; } ) ; wx . readBLECharacteristicValue ( { deviceId : '' , serviceId : '' , characteristicId : '' , success ( res ) { console . log ( 'readBLECharacteristicValue:' , res . errCode ) ; } , } ) ; } { wx . startBluetoothDevicesDiscovery ( { services : [ 'FEE7' ] , success ( res ) { console . log ( res ) ; } , } ) ; } { wx . stopBluetoothDevicesDiscovery ( { success ( res ) { console . log ( res ) ; } , } ) ; } { 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 ) ; } , } ) ; } { wx . requestSubscribeMessage ( { tmplIds : [ '' ] , success ( res ) { expectType < string > ( res . TEMPLATE_ID ) ; } , } ) ; } { wx . requestSubscribeSystemMessage ( { msgTypeList : [ 'SYS_MSG_TYPE_INTERACTIVE' , 'SYS_MSG_TYPE_RANK' ] , success ( res ) { expectType < string > ( res . errMsg ) ; } , } ) ; } { wx . getSetting ( { success ( res ) { expectType < boolean | undefined > ( res . authSetting [ 'scope.userInfo' ] ) ; 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 . reportPerformance ( 1101 , 680 ) ; } { const accountInfo = wx . getAccountInfoSync ( ) ; expectType < string > ( accountInfo . miniProgram . appId ) ; expectType < string > ( accountInfo . plugin . appId ) ; expectType < string > ( accountInfo . plugin . version ) ; } { wx . reportPerformance ( 1101 , 680 ) ; wx . reportPerformance ( 1101 , 680 , 'custom' ) ; } { wx . hideShareMenu ( { menus : [ 'shareAppMessage' , 'shareTimeline' ] , } ) ; } { wx . showShareMenu ( { withShareTicket : true , menus : [ 'shareAppMessage' , 'shareTimeline' ] , } ) ; } { 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 ] ) ; } { wx . getGroupEnterInfo ( { success ( res ) { expectType < string > ( res . errMsg ) ; expectType < string > ( res . encryptedData ) ; expectType < string > ( res . iv ) ; } } ) ; } { 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 ; } ) ; } { 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 < WechatMinigame . 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 < WechatMinigame . 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 worker = wx . createWorker ( 'workers/index.js' ) ; const camera = wx . createCamera ( { success ( ) { camera . listenFrameChange ( worker ) ; } , } ) ; } { const worker = wx . createWorker ( 'workers/index.js' ) ; const data = worker . getCameraFrameData ( ) ; console . log ( data ) ; } { 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 ) ; console . log ( 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 ) ; console . log ( 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` ) ; console . log ( 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` ) ; 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 . 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 ) ; } } ) ; } { const worker = wx . createWorker ( 'workers/index.js' , { useExperimentalWorker : true } ) ; const camera = wx . createCamera ( { success ( ) { camera . listenFrameChange ( worker ) ; } } ) ; }