Search code examples
excelvisual-studio-codeoffice-jsoffice-addinsyeoman-generator-angular

Switching Office Javascript APIs to Preview on Yeoman Office Generated project


I am trying to access the Office Javascript Preview APIs on my Angular Yeoman Generated project. I am writing this Office add-in on a Mac in Visual Studio Code. I wrote code on Script Lab with the preview library but do not know how to do the same for the Yeoman generated Office project. When I try to access the ".addFromBase64()" function, I get:

"Property 'addFromBase64' does not exist on type 'WorksheetCollection'.ts(2339)"

I have already tried changing the CDN references from Javascript 1.8 APIs to the Javascript Beta (Preview) APIs and added the @types suggested by the note next to the section. I found and replaced 2 instances of the 1.8 APIs in 'commands.html' and 'taskpane.html'.

I have tried the steps for Updating an Office Add-in project created with a text editor or other IDE.


Solution

  • In case anyone else besides Daniel and me ever wants to know this:

    As described here, in addition to changing the CDN referernces and adding the preview @types, you need to uninstall the production @types with

    npm uninstall --save-dev @types/office-js