making visualforce remoteaction bulletproof with typescript
TRANSCRIPT
![Page 1: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/1.jpg)
Making Visualforce RemoteActions Bulletproof with TypeScript
Simon Goodyear Beaufort 12 @simongoodyear
![Page 2: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/2.jpg)
Simon Goodyear Co-Founder, Beaufort 12
![Page 3: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/3.jpg)
Demo The Problem
![Page 4: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/4.jpg)
Root Cause Analysis
JavaScript is not metadata aware
![Page 5: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/5.jpg)
Making JavaScript Metadata Aware
What we need Where we get it
Method Signatures Tooling API
Custom Apex Types Tooling API
SObjects Standard API
![Page 6: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/6.jpg)
Making JavaScript Metadata Aware
JavaScript is loosely typed
![Page 7: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/7.jpg)
What is TypeScript?
“TypeScript is a typed superset of JavaScript that compiles to plain JavaScript”
“…a symantic subset of JavaScript; the sensical subset” – Anders Hejlsberg
Aimed at improving the development experience for JavaScript
![Page 8: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/8.jpg)
What is TypeScript?
Strongly typed. Tools perform type inference.
Modules, Classes & Interfaces
4 primitives: string, number, boolean, any
TypeScriptLang.org
![Page 9: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/9.jpg)
Demo Introduction to TypeScript
![Page 10: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/10.jpg)
Joining the Dots
Represent metadata as classes in TypeScript
• We need tools to do this
We no longer write JavaScript
• TypeScript only now
TypeScript is compiled before deployment
• And thus type checked
![Page 11: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/11.jpg)
Demo Joining the dots
![Page 12: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/12.jpg)
Where Next?
Better flow for developers
• Create a grunt task
• Automatically generate d.ts files on metadata changes
Improved support of metadata
• Inner classes
• Namespace support
Integration with continuous integration tools
Whatever else you can imagine
![Page 13: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/13.jpg)
3 Simple Points
JavaScript is not aware of the Salesforce metadata
All the metadata is exposed via the Tooling and Standard APIs
We can make TypeScript aware of the Salesforce metadata
![Page 14: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/14.jpg)
Resources
typescriptlang.org
blogs.msdn.com/b/typescript
channel9.msdn.com/Tags/typescript
definitelytyped.org
github.com/Microsoft/TypeScript-Sublime-Plugin
![Page 15: Making Visualforce RemoteAction Bulletproof with TypeScript](https://reader031.vdocuments.us/reader031/viewer/2022030316/5873259e1a28ab596c8b4943/html5/thumbnails/15.jpg)
Thank you