brucemcpherson / desktopliberation

hosting for desktop liberation google plus community
30 stars 1 forks source link

Use a proxy to catch invalid property access #148

Open brucemcpherson opened 1 year ago

brucemcpherson commented 1 year ago

Accidentally accessing non-existent properties and tracking down where that is happening is a big time waster that a JavaScript proxy can help you track down.

In Fix Apps Script file order problems with Exports (https://ramblings.mcpher.com/gassnippets2/exports/) I described how to organize your Apps Script code better using an Exports object to describe and modify the classes and namespaces in your project, or in libraries your project uses. Now that you have this centralized view, it’s easy to add checks on attempts to access properties that don’t exist in your target object.

See how here https://ramblings.mcpher.com/gassnippets2/proxy-props/