HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • SC-3568HA

    • Introduction

      • SC-3568HA Overview
    • Quick Start Guide

      • OpenHarmony Overview
      • Image Flashing
      • Setting Up the Development Environment
      • Hello World Application and Deployment
    • Application Development

      • ArkUI

        • Chapter 1 Introduction to ArkTS Language
        • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
        • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
        • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
      • Expand

        • Chapter 1 Getting Started Guide
        • Chapter 2 Referencing and Using Third-Party Libraries
        • Chapter 3: Application Compilation and Deployment
        • Chapter 4: Command-Line Factory Reset
        • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
        • Chapter 6 APP Stability Testing
        • Chapter 7 Application Testing
    • Device Development

      • Chapter 1 Environment Setup
      • Chapter 2 Download Source Code
      • Chapter 3 Compiling Source Code
    • Peripheral And Iinterface

      • Raspberry Pi interface
      • GPIO Interface
      • I2C Interface
      • SPI communication
      • PWM (Pulse Width Modulation) control
      • Serial port communication
      • TF Card
      • Display Screen
      • Touch
      • Audio
      • RTC
      • Ethernet
      • M.2
      • MINI-PCIE
      • Camera
      • WIFI&BT
      • Raspberry Pi expansion board
    • Frequently Asked Questions

      • Resource Downloads
  • M-K1HSE

    • Introduction

      • M-K1HSE Introduction
    • Quick Start

      • Development environment construction
      • Source code acquisition
      • Compilation Notes
      • Burning Guide
    • Peripherals and interfaces

      • 01 Audio
      • 02 RS485
      • 03 Display
    • System customization development

      • System transplant
      • System customization
      • Driver Development
      • System Debugging
      • OTA Update

Chapter 1 Introduction to ArkTS Language

1. Introduction

ArkTS, as part of the OpenHarmony application development framework ArkUI, provides developers with a declarative development paradigm based on TypeScript (TS) extensions. This paradigm not only lowers the development threshold but also enhances efficiency, allowing developers to focus more on business logic implementation rather than UI rendering details. This article will elaborate on the fundamental concepts, syntax features of the ArkTS language, and its applications in OpenHarmony app development.

2. ArkTS Language Fundamentals

2.1 What is TS?

TypeScript (abbreviated as TS) is a superset of JavaScript that supports the ECMAScript 6 (ES6) standard while introducing static typing and class-based object-oriented programming. Its syntax maintains high compatibility with JavaScript but enhances type checking and expands language features through constructs like interfaces, enums, generics, and more.

2.2 TS Basic Syntax

Variable Declaration: In TypeScript, variables can be declared using the var, let, or const keywords. Unlike JavaScript, TypeScript allows developers to explicitly specify the type of a variable during declaration.

Type Annotations: TypeScript provides a robust type system, including primitive types (e.g., number, string, boolean), array types, tuple types, enum types, and interfaces. By using type annotations, developers can catch type-related errors during the compilation phase, significantly enhancing code robustness and reliability.

Functions: Function declarations in TypeScript are similar to JavaScript but support type annotations for parameters and return values. Additionally, TypeScript extends JavaScript's function capabilities with advanced features such as optional parameters, default parameters, and rest parameters.

Classes: TypeScript introduces class-based programming, enabling developers to structure code in an object-oriented manner. Classes can encapsulate properties, methods, constructors, and access modifiers (e.g., public, private, protected), providing a clear blueprint for object creation and behavior.

2.3 ArkTS-Specific Syntax

In ArkTS, beyond TypeScript's foundational syntax, several framework-specific syntax and concepts are introduced, such as components, state, and lifecycle. These constructs enable developers to build UI interfaces in a declarative manner, implement two-way data binding, and handle event responses effectively.

3. Applications of ArkTS in OpenHarmony Development

The ArkUI development framework for OpenHarmony applications provides two programming paradigms: a JS-extended web-like development paradigm and a TS-extended declarative development paradigm. Among these, ArkTS has become the preferred choice for many developers due to its powerful type system and declarative programming approach. In OpenHarmony application development, using ArkTS allows developers to effortlessly construct complex UI interfaces, achieve interface reusability and scalability through component-based architecture, and enable interoperability with native code to invoke platform-specific functionalities when required.


Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Next
Chapter 2 Introduction to UI Components and Practical Applications (Part 1)