microsoft / tslib

Runtime library for TypeScript helpers.
BSD Zero Clause License
1.25k stars 126 forks source link

TypeError: (0 , tslib__WEBPACK_IMPORTED_MODULE_0__.__rest) is not a function #198

Closed kegbo closed 1 year ago

kegbo commented 1 year ago

I am building an Angular app so as to up load audio files to azure storage. When code execution reaches the point to where it calls

const result = await blockBlobClient.uploadData(file, options);

The full function is

async upload(file: any,filename:string, speakers: number, inputLanguage: string, outputLanguage: string): Promise<string> {
    const containerClient = this.blobServiceClient.getContainerClient(this.containerName);
    console.log(containerClient)
    const blobName = filename;
    const blockBlobClient = containerClient.getBlockBlobClient(blobName);

    const options = {
      blobHTTPHeaders: { blobContentType: 'audio/wav' },
      metadata: {
        speakers: speakers.toString(),
        inputLanguage: inputLanguage,
        outputLanguage: outputLanguage
      }
    };

    const uploadOptions = { bufferSize: 4 * 1024 * 1024, maxBuffers: 20 };
    const result = await blockBlobClient.uploadData(file, options);

    const blobUrl = `https://${this.accountName}.blob.core.windows.net/${this.containerName}/${blobName}`;
    console.log(`Blob "${blobName}" is uploaded successfully. URL: ${blobUrl}.`);
    return blobUrl;
  }

I get the error with the stacktrace

TypeError: (0 , tslib__WEBPACK_IMPORTED_MODULE_0__.__rest) is not a function
    at Module.operationOptionsToRequestOptionsBase (operationOptions.js:10:80)
    at BlockBlob.upload (blockBlob.js:33:22)
    at Clients.js:1503:48
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (asyncToGenerator.js:3:1)
    at _next (asyncToGenerator.js:22:1)
    at asyncToGenerator.js:27:1
    at new ZoneAwarePromise (zone.js:1432:21)
    at asyncToGenerator.js:19:1
    at BlockBlobClient.upload (Clients.js:1516:10)

Checking the tslib.js file in my node_modules, the __rest function is present.

I have tried the solution presented here at https://stackoverflow.com/questions/73730085/typeerror-0-tslib-webpack-imported-module-1-extends-is-not-a-function but that didnt do anything

I also tried the solution present here at https://stackoverflow.com/questions/59849127/typeerror-tslib-spreadarrays-is-not-a-function but also the problem presisted.

I have updated my npm and tslib to the latest version but again, the problem has persisted.

Pls advise

kegbo commented 1 year ago

I had to close visual studio and then restarted my machine for this to clear. Do not understand what happened