Engineering

Our engineering is underpinned by principles that celebrate both the integrity of code and the ambition to innovate. This manifesto champions excellence, advocates for the adoption of cutting-edge technologies, and fosters an environment of continuous intellectual growth.

TypeScript setup

To add TypeScript to a project, you'll need to add the typescript package, configure TypeScript, and use Babel to compile TypeScript files.

Install TypeScript

Install the typescript package, tslint for linting, and other supporting packages.

See the full list in Mashup Garage's defaults repo. https://github.com/mashupgarage/defaults/tree/master/typescript

Create TypeScript configuration

Create the file tsconfig.json wherever the top-level package.json is in your project. For Node.js projects, that'd be the root folder; for Elixir projects, that might be /assets.

See our recommend configuration files in Mashup Garage's defaults repo. https://github.com/mashupgarage/defaults/tree/master/typescript

Update webpack.config.js

Update your Webpack config to allow compilation of .ts and .tsx files. If your project is already using babel-loader, this configuration may already be there, and you just to update the test value to include TypeScript's extensions. Otherwise, you might need to add the entire module.rules[] section as necessary below.

See our recommended Webpack and Babel configs in Mashup Garage's defaults repo. https://github.com/mashupgarage/defaults/tree/master/typescript

Rename files

Rename your .js to .ts and .jsx files to .tsx. There are many ways to accomplish this. Here are a few pointers. • Using moreutils's vidir https://relentlesscoding.com/posts/use-vidir-to-quickly-edit-filenames-in-your-editor/ • Using ranger's :flat and :bulkrenamehttps://github.com/ranger/ranger/wiki/Official-user-guide

Additional notes

Avoid using ts-loader Avoid using ts-loader. We strongly recommend using Babel (babel-loader) to compile TypeScript files instead of tsc (ts-loader). • Babel is much faster than tsc. While tsc is a full type-checker and compiler, Babel will not do any type-checking, leading to faster compile times. • Not using tsc means features that rely on emitting are disabled. While this seems like a bad idea, • Most of MG projects already use Babel, so migrating to TypeScript using the same JavaScript compiler is the most practical path to updating to TypeScript. • Install @types and typescript to devDependencies More notes • Add linting and formatting. After setting up TypeScript, add Tslint and Prettier afterwards to improve your coding experience. • Always use strict: true. The configuration outlined above already includes this rule. This disallows implicit any types, which should lessen chances of running into false positives (ie, TypeScript allowing something that will cause runtime type errors). • Avoid using eslint. TypeScript support in eslint is very limited (as of Feb 2019). Tslint provides most of the Eslint rules that matter, while also providing many TypeScript-specific rules.

Further reading

• TypeScript in 5 minutes (typescriptlang.org) — The official quick-start guide from the TypeScript team https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html • [TypeScript playground (typescriptlang.org) — Try TypeScript features on your browser](https://www.typescriptlang.org/play/?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydajBBCcQQ0MwAUVWDEQC0gADVHBQGNJ3KAALygABEAAkYNAMOB4GRonzFBTBPB3AERcwABS0+mM9ysygc9wASmCKhwzQ8ZC8iHFzmB7BoXzcZmY7AYzEg-Fg0HUiQ58D0Ii8fLpDKZgj5SWxfPADlQAHJhAA5SASPlBFQAeS+ZHegmdWkgR1QjgUrmkeFATjNOmGWH0KAQiGhwkuNok4uiIgMHGxCyYrA4PCCJSAA) • TypeScript deep dive (basarat.gitbook.io) — A free e-book on TypeScript https://basarat.gitbook.io/typescript

Next: Design Playbook

Connect.

Mashup Garage, a premier software development team, specialises in crafting exceptional products for startups and enterprises. With expertise in React, Elixir/Phoenix, and Ruby on Rails, we deliver solutions that meet your unique needs. Our mission is to bring value backed by decades of technical expertise and global co-founding experience.

What do you need help with?

Build a project

Build a team

Consult

Speak to someone

Expect a guaranteed response from us in 1-2 business days.

United Kingdom

London

Islington, London

+44 738 777 3405

LDN

Philippines

Manila

3F Topy IV Building, 3 Economia Road, Bagumbayan, Quezon City, 1110

+63 917 3084089

MNL