OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

How to add custom functions to an existing addin #3173

Closed theboyknowsclass closed 1 year ago

theboyknowsclass commented 1 year ago

Hi,

i've created a 'functions.ts' file, but seem to be having issues with my webpack, throwing an error

`[tsl] ERROR in C:\Repos\ojsx-addin-service\src\functions\functions.ts(17,1) TS2304: Cannot find name 'CustomFunctions'.

We have several forums where you can ask the developer community questions about your code. Try one of the following forums to ask technical questions about:

For additional information about JavaScript programming, see the JavaScript at Microsoft community hub.

theboyknowsclass commented 1 year ago

webpack.config.dev.zip

alison-mk commented 1 year ago

Hi @theboyknowsclass, thank you for submitting and sorry for the delay. I've assigned it to @yaweizhu-henson who will be able to provide you with more information or help resolve the issue.

Cheers, Alison

rundongmsft commented 1 year ago

Hi @theboyknowsclass, looks like the ts in your side cannot recognize CustomFunctions. Please try to run this command under your project: npm install --save @types/custom-functions-runtime

If this method can't solve your issue, please send me a complete project so that I can help to debug it.

The differences between CF Add-in and non-CF Add-in include 5 parts:

  1. Functions.js or Functions.ts
  2. Functions.html
  3. manifest.xml (For details about these 3 parts refer to this doc.)
  4. Webpack config
  5. Dependences (For details about these 2 parts, you can refer to a yoman generated CF sample add-in.)

If you want to add custom functions to an existing add-in, check and update these 5 parts.

donlvMSFT commented 1 year ago

I'd like to close this issue due to current status, please raise a new one or reactive if there're further questions.