Add ArkTS language support#7593
Conversation
.ets language support.ets extension to TypeScript
|
From what is see when I Google ArkTS it seems it should be added as a language in its own right and not just considered an aka of TS. |
|
Thank you for the feedback! I apologize for the initial mistakes and have made the necessary corrections. Response to @lildudeYou're absolutely right about the "Hello world" examples. I have now replaced them with real-world samples based on an actual HarmonyOS project created with DevEco Studio. While these samples are not from a complete, production-ready HarmonyOS application, they do demonstrate real ArkTS language features including:
If you require a complete, runnable HarmonyOS project as the sample, I can provide that in a follow-up commit. The current samples showcase the core ArkTS language features that would be most relevant for syntax highlighting and language detection. Response to @NixinovaYou're absolutely correct - I made an error by initially treating ArkTS as just a TypeScript extension. ArkTS should indeed be added as a standalone language. While ArkTS is a superset of TypeScript, it has significant differences:
I have now:
The ohosvscode/arkTS project I created in March 2025 provides comprehensive VSCode support for ArkTS, including syntax highlighting, code completion, and language server features. It contains the Additional NotesAs I'm relatively new to the linguist project, I've relied heavily on documentation, web searches, and AI assistance to ensure proper implementation. I've run the full test suite and verified that:
Please let me know if there are any remaining issues or if additional changes are needed. I'm committed to getting this implementation right and contributing properly to the project. Thank you for your patience and guidance! |
|
ok thanks mr gpt youll need to link where you got the samples from also. |
|
emm....I updated the PR description.... 🤔 At present, I have only thought of two relatively well-known open-source projects on github:
Also, here is a collection of open-source HarmonyOS projects:
|
.ets extension to TypeScript|
There is also this HarmonyOS open-source project repository collection: Some of the repository links might be hosted on Gitee, a Chinese code hosting platform. |
|
🎉 I tested it in my forked github-linguist repository, and now it 's perfectly passable CI: https://github.com/Groupguanfang/linguist/actions/runs/17894256842 |
|
@lildude Fixed! I followed the CONTRIBUTING.md instructions and ran script/update-ids to get the correct language_id: 56341321 for ArkTS. |
|
I've squashed all commits in this PR into a single clean commit. The commit history is now much more organized and contains all the ArkTS language support changes in one place 🎉 |
- Add ArkTS as a new programming language with .ets file extension - Configure syntax highlighting using TextMate grammar from ohosvscode/arkTS - Add real-world ArkTS samples from HarmonyOS development (Index.ets, EntryAbility.ets, EntryBackupAbility.ets) - Set language ID using script/update-ids (56341321) and color to #3178c6 - Configure ace_mode as typescript and codemirror_mode as javascript - Add license information for ArkTS submodule - Update grammars.yml and .gitmodules with proper alphabetical sorting
|
Hi maintainers, I just realized that my PR accidentally included unrelated Docker changes from a previous commit when syncing with main. I've now cleaned up the commit history to contain only my ArkTS language support changes. Please review the updated commit. Thanks! |
|
No need to fret about commit history, it's all squashed at the end. |
Huawei's GitCode uses the same |
|
OK 👌 I updated ArkTS color to #0080ff to match ArkTS's official color scheme, Thank you for the reminder @OverflowCat |
|
Reverting this as it appears the grammar wasn't added cleanly and correctly using the I've just tested re-adding it and sure enough, there are problems with the grammar: ➜ script/add-grammar ohosvscode/arkTS --replace https://github.com/ohosvscode/arkTS
Checking Docker is installed and running
Registering new submodule: https://github.com/ohosvscode/arkTS.git
Cloning into '/workspaces/linguist/vendor/grammars/arkTS'...
remote: Enumerating objects: 8346, done.
remote: Counting objects: 100% (1467/1467), done.
remote: Compressing objects: 100% (465/465), done.
remote: Total 8346 (delta 1160), reused 1002 (delta 1002), pack-reused 6879 (from 3)
Receiving objects: 100% (8346/8346), 26.72 MiB | 39.89 MiB/s, done.
Resolving deltas: 100% (5076/5076), done.
latest: Pulling from linguist/grammar-compiler
32fb02163b6b: Pull complete
167c7feebee8: Pull complete
d6dfff1f6f3d: Pull complete
e9cdcd4942eb: Pull complete
543368fb39ee: Pull complete
5898d990df6b: Pull complete
9602be2ba0fe: Pull complete
bbe16c78b8cb: Pull complete
5711e12c9be4: Pull complete
9f22d6761517: Pull complete
e2fa649b33f6: Pull complete
Digest: sha256:fcaf08a6e27d3d88212d9ca8aceee30d4089499a77bb05307871febd8073790f
Status: Downloaded newer image for linguist/grammar-compiler:latest
docker.io/linguist/grammar-compiler:latest
2 errors found in new grammar 'repository `vendor/grammars/arkTS` (from https://github.com/ohosvscode/arkTS.git)':
- Grammar conversion failed. File `packages/vscode/syntaxes/hml-language-configuration.json` failed to parse: Undeclared scope in grammar: `packages/vscode/syntaxes/hml-language-configuration.json` has no scope name
- Grammar conversion failed. File `packages/vscode/syntaxes/language-configuration.json` failed to parse: Undeclared scope in grammar: `packages/vscode/syntaxes/language-configuration.json` has no scope name
Compilation failed. Aborting
➜ Please fix your grammar (the only files in the syntaxes directory should be syntax files) or find another and then submit a new PR to add support for this language. |
|
Oh, sorry about that — I previously tried to add support for HML syntax to VSCode. Additionally, due to my lack of familiarity with how linguist scans tmLanguage.json files in submodules, I’m still not very familiar with the linguist project, and I really appreciate your understanding. I’ve updated the ArkTS repository to address the issues mentioned above. Given this, would it be possible to revert the previous revert PR, or alternatively, I can submit a new PR to re-add ArkTS support? |
Please submit a new PR, and make sure you use the documented process to add the grammar to ensure it is added cleanly and safely. |
|
I’ve created a new PR (#7742). Thanks in advance for taking a look! |


Add ArkTS language support with .ets extension
Description
This PR adds support for ArkTS as a new programming language in Linguist. ArkTS is a superset of TypeScript used for HarmonyOS development, featuring additional language constructs like
structdeclarations, HarmonyOS-specific decorators, and APIs.The changes include:
languages.ymlwith.etsfile extensionsource.ets) and language IDChecklist:
I am adding a new extension to a language.
I am adding a new language.
packages/vscode/syntaxes/ets.tmLanguage.jsonsource.ets#0080ff.etsextension exclusively and has unique language constructs likestructdeclarations and HarmonyOS-specific decoratorsI am fixing a misclassified language
I am changing the source of a syntax highlighting grammar
I am updating a grammar submodule
vendor/grammars/ArkTSsubmodule pointing to ohosvscode/arkTSgrammars.ymlto map the grammar tosource.etsscopevendor/README.mdto include the new grammarI am adding new or changing current functionality
I am changing the color associated with a language