# Workspace configuration - setup project the hardway (we want to use webpack) - create a build directory (either ant or dx) to handle deploying meta-data (page, controller, static resource) - add package.json scripts to compile -> copy assets to build -> deploy ``` "scripts": { "build": "webpack --config config/webpack.config.js && npm run prepare", "prepare": "cp dist/app.js build/package/StaticResources/App.resource && cp -r src/salesforce/* build/package", "push": "ant deploy -buildfile build -Ddir build/package", "deploy": "npm run build && npm run push", "start": "webpack-dev-server --config config/webpack.config.js --https" } ``` ## serving locally 1. Setup page to toggle scripts on URL param (`?local=1`): ```
` 3. declare a var in your app: `declare var accessToken: string;` 4. make callout using token. Can generate types from response using something like http://json2ts.com/ [Type Assertions vs Casting](https://basarat.gitbooks.io/typescript/content/docs/types/type-assertion.html) Example, You call the rest API and assert that the response is of type `Account` ```javascript public class Account{ public foo(){ } public Name: string; } let acc : Account = Rest.query('select Name FROM Account limit 1'); ``` While the system may let you do this, and some other the properties do line up, when you go to access `.foo` on the returned object, you will get undefined. The proper way to do this would be to use `Object.Assign(new Account(), Rest.query('select Name FROM Account limit 1'));`. This creates a new Account instance and copies over the properties!