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
678 stars 95 forks source link

importing metron.extender into TS or JSX file causes issues with Office.js API #10

Closed kbrandl closed 7 years ago

kbrandl commented 7 years ago

Logging this issue to track a bug reported by a customer in this Stack Overflow post: https://stackoverflow.com/questions/45927586/office-js-typescript-metron-extender-error.

From the post:

If you import metron.extender into any TS or JXS file (even if you don't use it), none of the Office API (like Excel.run(ctx) will work). If you trap the error, you will get something like: Unable to set property 'isValid' of undefined or null reference.

(If/when I'm able to get more detailed repro steps from the customer, I'll add that info this issue.)

syncimprov commented 7 years ago

We added and imported this file for some useful string functions:

https://github.com/metronical/metron/blob/master/src/metron.extenders.ts

This caused the issue. We had to remove all instances of the import to fix it.

We didn't want the entire metron library https://github.com/metronical/metron) and this in itself may have caused some inconsistencies.

kbrandl commented 7 years ago

Thanks for the update @BizH. Do I understand correctly that you've resolved this problem and this issue can be closed?

kbrandl commented 7 years ago

Closing this issue, as BizH has confirmed it is resolved (see prior comment in this thread).

rasikat86 commented 6 years ago

Hi, I am seeing a similar issue when using OfficeJS in an Angular 2 application. The full erro stack is as below -

{"description":"Unable to set property 'isValid' of undefined or null reference","number":-2146823281,"stack":"TypeError: Unable to set property 'isValid' of undefined or null reference\n at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:264919)\n at ZoneDelegate.prototype.invoke (eval code:386:13)\n at onInvoke (eval code:4976:17)\n at ZoneDelegate.prototype.invoke (eval code:386:13)\n at Zone.prototype.run (eval code:138:17)\n at Anonymous function (eval code:872:17)\n at ZoneDelegate.prototype.invokeTask (eval code:419:13)\n at onInvokeTask (eval code:4967:17)\n at ZoneDelegate.prototype.invokeTask (eval code:419:13)\n at Zone.prototype.runTask (eval code:188:21)"}

Any help will be much appreciated!