Version: 1.3
语言 : 中文
Call native plug-in for OpenHarmony code
Call TypeScript plug-in code from C# scripts

TypeScript source plug-ins

Tuanjie can interpret individual typeScript source files as individual plug-ins.

Tuanjie supports TypeScript code written in source files with .tslib extensions. To do this, Tuanjie interprets each source file as an individual plug-in and compiles them when it builds the Player. This type of plug-in is useful if you need to write a small amount of code for a single project.

Create a TypeScript source plug-in

To indicate to Tuanjie to create a plug-in from a TypeScript (.tslib,.etslib) source file:

  1. In the Assets folder, place your TypeScript (.tslib,.etslib) source file.
    Tip: It’s best practice to create a sub-folder to contain your TypeScript source files.
  2. Select the source file and view it in the Inspector window.
  3. In the Inspector, under the Select Platforms for plugin section, enable OpenHarmony.
  4. Select Apply.

Note: You can place the source files (.tslib,.etslib) in any folder in your Project, except in special use locations such as StreamingAssets. If you place files in these locations, the Tuanjie Editor doesn’t display the plug-in inspector.

Edit TypeScript files in an exported OpenHarmony Studio project

By default when you export a Tuanjie project for OpenHarmony, Tuanjie only copies TypeScript files under directory Assets\Plugins\OpenHarmony (includes .ts, .ets) over to the entry\src\main\ets directory of DevEco Studio project. If you edit these files in DevEco Studio, the changes aren’t reflected in the original files in the Tuanjie project. If you export the Tuanjie project again, the export process will overwrite your changes in DevEco Studio.

Other resource

Call native plug-in for OpenHarmony code
Call TypeScript plug-in code from C# scripts