How to use TypeScript with Node

  • For example:

    //Typescript
    class Test {
    //field
    name:string;
    //constructor
    constructor(name:string) {
    this.name = name
    }
    //function
    display_name():void {
    console.log(“name is : “+this.name)
    }
    }
    //javascript
    var Test = (function () {
    //constructor
    function Test(name) {
    this.name = name;
    }
    //function
    Test.prototype.display_name = function () {
    console.log(“name is : ” + this.name);
    };
    return Test;
    }());

    In the snippet above, notice that it is easier to read the TypeScript version of the code than the JavaScript Version.

  • Getting Started
    To install TypeScript globally so you can call it when needed, run:
    npm install -g typescript

    For verification of the installed TypeScript, use the tsc –v command:
    tsc –v
    //Version 2.1.6

    Next, install gulp for the build process.

  • To do that, we run:
    npm install gulp gulp-typescript typescript –save

    Doing just this setup done might be enough, but you would have to go back to the terminal to run the tsc command every time a change occurs.

  • Now, put the following contents into the gulpfile.js:
    const gulp = require(‘gulp’);
    const ts = require(‘gulp-typescript’);

    // pull in the project Typescript config
    const tsProject = //task to be run when the watcher detects changes
    gulp.task(‘scripts’, () = {
    const tsResult = tsProject.src()
    .

  • const server = http.createServer(App);
    server.listen(port);
    server.on(‘listening’, onListening);

    //function to note that Express is listening
    function onListening(): void {
    console.log(`Listening on port `+port);
    }

    This has imported the HTTP module from node.

Learn how you can create an app with TypeScript and Node.js, using Gulp to automate the building process and Nodemon to restart the server.
Continue reading “How to use TypeScript with Node”

5 Best JavaScript Frameworks

Which #JavaScript framework is the best for you? @Da14_team #ReactJS #AngularJS

  • In the meanwhile, JavaScript web frameworks can become a silver bullet for quick web app development.
  • Angular.js is often referred to as an MVW (Model-View-Whatever) framework and among the top benefits, for startups and mid-sized companies, people name: quick code production, easy testing of any app part and two-way data binding (changes in the backend are immediately reflected on the UI).
  • As for now, it is reasonably called the most used JS framework for SPAs (Single-Page Applications) development and it boasts the largest community of developers.
  • Back in 2015 Ember was called the best javascript framework for web application, leaving behind React and AngularJS.
  • When it comes to quick web development or prototyping, JavaScript frameworks are among the most favorable and 2017 won’t become an exception.

This article originally appeared on DA-14 and has been republished with permission. Find out how to syndicate your content with Upwork.
Continue reading “5 Best JavaScript Frameworks”

How to use Presentational/Container components in a Redux app – Jakob Lind

I wrote about when and how to use presentational/container components #reactjs #redux

  • Either present something visual (presentational component) OR fetch data (container component).
  • You can use the container/presentational pattern when using both regular Ajax calls inside your components, or when you are using Redux to fetch data.
  • When you start coding your Redux app, you usually start with a wrapper component that receives the data from the Redux store.
  • It is possible to connect Redux to any React component in your application.
  • In a real world application you might need to do more advanced refactorings of the presentational components.

Have you read about Presentational/Container pattern but are still not sure how it looks when it’s used correctly? When should you use it and when should you NOT use it?
Continue reading “How to use Presentational/Container components in a Redux app – Jakob Lind”

8 things to learn in React before using Redux

  • A component can manage a whole lot of state, pass it down as props to its child components and pass a couple of functions along the way to enable child components to alter the state in the parent component again.
  • Component A is the only component that manages local state but passes it down to its child components as props.
  • In addition, it passes down the necessary functions to enable B and C to alter its own state in A.

    Now, half of the local state of component A is consumed as props by component C but not by component B.

  • When you lift the local state management down to component C, all the necessary props don’t need to traverse down the whole component tree.
  • When a library such as Redux “connects” its state managements layer with React’s view layer, you will often run into a higher order component that takes care of it (connect HOC in react-redux).

Facts about React that should be known before using Redux (or MobX). Most important: Learn React first, then opt-in Redux…
Continue reading “8 things to learn in React before using Redux”

pixielabs/cavy – An integration test framework for #reactjs native

  • Cavy is a cross-platform integration test framework for React Native, by Pixie Labs.
  • Cavy (ab)uses React generating functions to give you the ability to refer to, and simulate actions upon, deeply nested components within your application.
  • This function should be used if your testable component does not respond to either or , for example:

    Cavy is a comparable tool to Appium.

  • The key difference is that Appium uses native hooks to access components (accessibility IDs), wheras Cavy uses React Native refs.
  • Jest is a useful tool for unit testing individual React Native components, whereas Cavy is an integration testing tool allowing you to run end-to-end user interface tests.

cavy – An integration test framework for React Native.
Continue reading “pixielabs/cavy – An integration test framework for #reactjs native”

Expo SDK v19.0.0 is now available – Exposition

Expo SDK v19.0.0 is now available – Exposition  #reactjs #reactnative @expo_io

  • JavaScriptCore on Android gets a big updateThe version of JavaScriptCore (JSC) built into upstream React Native is currently (r174650) three years old and missing many features that are available on iOS already, such as native async/await support, ES6 Symbols, and native TypedArray (which works efficiently with Expo Graphics).
  • A friendly reminder: you should probably use your device most of the time.Access QR scanner from in-app menu on iOSWhen you shake your device to open the developer menu when you have a project open, it now includes an option to let you jump to the QR scanner screen.Set up Universal Links for expo.ioNavigating to will open the app directly into Expo if it is installed now.Developer toolsEnabled –non-interactive for exp login.
  • We will be adding a guide to the Expo documentation for this shortly.Customize permissions required by Android standalone appsA common request from developers building Android apps with Expo is the ability to customize which permissions are requested at install-time.
  • App developers should respect this and only request the minimal permissions that the app requires.In Expo SDK 19 you can select the permissions using app.json, see the full documentation.BugfixesIt’s hard to document all of the small fixes that go into each release, but here are some of the highlights.General fixesContacts API is more uniform on iOS and AndroidAPI server and XDE agree about username formatting requirementsDocumentation search is fixed on mobileAndroid standalone app names can now contain ‘’, ‘’, ‘’, “‘“, ‘“‘Audio fixes- When preparing a Recording, you can pass an optional settings dictionary to customize the format / extension / bitrate / quality / encoding, et cetera.
  • Upgrading your appHere’s how to upgrade your app to Expo SDK 19.0.0 from 18.0.0:Close XDE or your exp CLI serverIn app.json (formerly exp.json), change sdkVersion to “19.0.0”In package.json, change these dependencies:- react-native to expo to “^19.0.0”- react did not change from SDK 18- jest-expo to “~19.0.0” (if you use it)- sentry-expo to “~1.6.0” (if you use it)Delete your project’s node_modules directory and run npm installagain (or use yarn, we love yarn)Reopen your project in XDE and press “Restart” to clear the packager cache, or run exp start -c if you use use exp.Update the Expo app on your phones from the App Store / Play Store.

I am pleased to announce the release of Expo SDK v19.0.0. It is based off the recently released React Native 0.46, “June”. Our previous SDK, v18.0.0, is based off 0.45, “May”. The version of…
Continue reading “Expo SDK v19.0.0 is now available – Exposition”

8 things to learn in React before using Redux

  • A component can manage a whole lot of state, pass it down as props to its child components and pass a couple of functions along the way to enable child components to alter the state in the parent component again.
  • Component A is the only component that manages local state but passes it down to its child components as props.
  • In addition, it passes down the necessary functions to enable B and C to alter its own state in A.

    Now, half of the local state of component A is consumed as props by component C but not by component B.

  • When you lift the local state management down to component C, all the necessary props don’t need to traverse down the whole component tree.
  • When a library such as Redux “connects” its state managements layer with React’s view layer, you will often run into a higher order component that takes care of it (connect HOC in react-redux).

Facts about React that should be known before using Redux (or MobX). Most important: Learn React first, then opt-in Redux…
Continue reading “8 things to learn in React before using Redux”