Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Developing Mobile Applications using TypeScript on Red Hat Mobile Application Platform

July 5, 2017
Evan Shortiss
Related products:
Red Hat build of Node.js

    As of its release 2.19, the Red Hat Mobile JavaScript Client SDK contains a TypeScript definition file. By providing type definitions our JavaScript SDK can easily be used in applications developed using TypeScript. As a developer with a few years of JavaScript experience, I was initially skeptical of TypeScript, but after using it for a short period, I'm not sure how I ever managed without it! In this post, I take a look at the benefits TypeScript offers and demonstrate how you can get up and running with an application written in TypeScript on the Red Hat Mobile Application Platform.

    TypeScript

    If you're not familiar with TypeScript then it might be best to head over to the project website and read a little about it, but to summarize, TypeScript is a superset of JavaScript that compiles down to regular JavaScript code. Since it compiles to JavaScript it will run in virtually any JavaScript platform - even older web browsers! For those who are curious as to the benefits of writing TypeScript instead of regular JavaScript here's a quick summary:

    • Static typing. This improves development speed due to better readability, clear type information, and excellent IntelliSense.
    • Compilation. Since TypeScript is compiled to JavaScript, many errors that could easily be missed with JavaScript are caught by the compiler before runtime.
    • Extended language features. You can use modern JavaScript language features that would otherwise require browser workarounds.
    • Ease of use. Since TypeScript is a superset of JavaScript, it immediately feels familiar to JavaScript developers and is an easier transition for developers who aren't used to JavaScript.

    Let's see how the following JavaScript code could be improved using TypeScript:

    // return the sum of two numbers
    function add (x, y) {
      return x + y;
    }

    This function should return the sum of two numbers passed to it, but there's nothing to stop a developer from accidentally passing an Object like so:

    // incorrectly try to use this function to merge two objects
    add({firstname: 'red'}, {lastname" hat'});
    

    If you're familiar with JavaScript you're aware that this code would actually run and return the result "[object Object][object Object]". Ideally, we'd like these issues to be captured before runtime - this is where TypeScript can help us:

    // We specify the type of inputs using TypeScript syntax
    // We don't specify the return type of this function since the TypeScript
    // engine can use type inference to figure it out!
    function add (x: number, y: number) {
      return x + y;
    }

    If a developer attempted to pass anything other than a number to this function the TypeScript compiler would throw an error thus avoiding wasted time debugging a simple developer error.

    The GIF below is an example of a TypeScript enabled editor (Visual Studio Code) providing documentation and warnings for the RHMAP Client SDK as I type:

    TypeScript-Intellisense

    Getting Started with TypeScript on RHMAP

    To help you get started we've created a new version of our standard Hello World HTML5 Cordova application using TypeScript. We've also ported it to React to further demonstrate how you can create a structured, statically typed Cordova Application. You can find the source code for this application in this repository on GitHub.

    Those of you who've been observant of the code in the linked GitHub repository might have noticed that the www/ folder that typically contains JavaScript files for Cordova applications contains only CSS, JSON, and HTML. The reason for this is that the JavaScript files can be easily generated so we've deliberately chosen to not commit them to the repository via a rule in our .gitignore. You might now be wondering how Red Hat Mobile Application Platform will know how to generate the JavaScript files. The solution is simple but very powerful - it will try calling an install script that can be specified in our package.json. This feature provides the ability to call tools we need such as the TypeScript compiler and browserify.

    Let's go ahead and get our template imported into your Red Hat Mobile Application Platform instance. Open a web browser and navigate to your domain. Select an existing project or create a new blank project by choosing "Blank" from the options on the left of the Create screen shown:

    create-project

    Once the Project has been created, add a new Client Application to it. Client Applications are Applications that will run on a mobile device or in a web browser. To add a Client Application click the plus icon in the corner of the "Apps" pane:

    project-created

    When adding the Client Application choose "Import Existing Application" and when prompted to select a type to choose "Cordova":

    create-client

    Now choose the "Public Git Repository" option and when prompted for a repository URL enter https://github.com/evanshortiss/rhmap-hello-world-typescript-react and choose the master branch as demonstrated:

    create-client-import

    Once the import is complete, you can return to the Project screen and view it. From the Project screen, you will need to add a Cloud Application by clicking the plus icon similar to how you added the Client Application:

    client-created

    Select our regular "Cloud App" template and give it a name:

    create-cloud

    Once the Cloud Application is created Deploy it, then navigate back to your Client Application. Go to the "Build" screen in your Client Application to create an application binary for the platform of your choice. Remember, iOS will require you to upload valid iOS developer credentials, but Android Debug builds can be done without any special requirements:

    build-client

    Once the build process is complete, you will be presented with a QR code that you can scan on a mobile device to install our application. Here's an example of it working on an Android tablet. Enter your name in the text box, then tap the "Say Hello From the Cloud" button to have it echoed back.

    rhmpa-typescript-hello-world


    Red Hat Mobile Application Platform is available for download, and you can read more at Red Hat Mobile Application Platform.

    Last updated: October 31, 2023

    Recent Posts

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.