How to Test TypeScript 4.0-beta Features

Setup a project to test latest TypeScript 4.0-beta features

Image for post
Image for post
Photo by Miguel Á. Padriñán from Pexels

Prerequisites

Create project

$ mkdir typescript-4-beta
$ cd typescript-4-beta
$ npm init
Image for post
Image for post

Install TypeScript 4.0-beta

$ npm install typescript@beta

Create core files

$ touch index.ts index.html
$ npm install
Image for post
Image for post
export class Dog {
public name:string;
public age: number;
public bark(): void {
console.log(`Bark !!`)
}
}

Compile your typescript code

$ tsc index.ts
Image for post
Image for post

Add the Js file to HTML

<script src="./index.js"> </script>

Conclusion

Written by

I develop software by profession. My interests include: history, economics, politics & enterprise-architecture. I am a child of God.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store