Skip to content

Add ArkTS language support#7593

Merged
lildude merged 2 commits intogithub-linguist:mainfrom
Groupguanfang:main
Oct 6, 2025
Merged

Add ArkTS language support#7593
lildude merged 2 commits intogithub-linguist:mainfrom
Groupguanfang:main

Conversation

@Groupguanfang
Copy link
Contributor

@Groupguanfang Groupguanfang commented Sep 20, 2025

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 struct declarations, HarmonyOS-specific decorators, and APIs.

The changes include:

  • Added ArkTS as a new language in languages.yml with .ets file extension
  • Added official ArkTS syntax highlighting grammar from the ohosvscode/arkTS repository
  • Added real-world sample files demonstrating typical ArkTS usage patterns
  • Configured proper TextMate scope (source.ets) and language ID

Checklist:

  • I am adding a new extension to a language.

  • I am adding a new language.

  • I am fixing a misclassified language

    • I have included a new sample for the misclassified language:
      • Sample source(s):
        • [URL to each sample source, if applicable]
      • Sample license(s):
    • I have included a change to the heuristics to distinguish my language from others using the same extension.
  • I am changing the source of a syntax highlighting grammar

    • Old: [URL to grammar repo]
    • New: [URL to grammar repo]
  • I am updating a grammar submodule

    • Added vendor/grammars/ArkTS submodule pointing to ohosvscode/arkTS
    • Updated grammars.yml to map the grammar to source.ets scope
    • Updated vendor/README.md to include the new grammar
  • I am adding new or changing current functionality

    • I have added or updated the tests for the new or changed functionality.
  • I am changing the color associated with a language

    • I have obtained agreement from the wider language community on this color change.
      • [URL to public discussion]
      • [Optional: URL to official branding guidelines for the language]

@Groupguanfang Groupguanfang requested a review from a team as a code owner September 20, 2025 09:00
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you missed one crucial line in the CONTRIBUTING.md file 😉

**"Hello world" examples will not be accepted.**

Please remove that sample, and ideally replace it with a real-world sample.

@lildude lildude changed the title feat: add .ets language support Add .ets extension to TypeScript Sep 20, 2025
@Nixinova
Copy link
Contributor

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.

@Groupguanfang
Copy link
Contributor Author

Thank you for the feedback! I apologize for the initial mistakes and have made the necessary corrections.

Response to @lildude

You'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:

  • @Component and @Entry decorators
  • @State state management
  • @Builder functions
  • HarmonyOS-specific APIs and lifecycle methods
  • Real-world UI components and system integration

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 @Nixinova

You'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:

  • The struct keyword in ArkTS has different semantics than the TC39 Stage 2 proposal for TypeScript
  • ArkTS includes HarmonyOS-specific decorators and APIs
  • It has its own compilation target and runtime environment

I have now:

  1. Added ArkTS as a separate language in languages.yml with its own language_id and tm_scope
  2. Used the ets.tmLanguage.json grammar file from the ohosvscode/arkTS repository
  3. Added this repository as a git submodule under vendor/grammars/ArkTS

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 ets.tmLanguage.json grammar file that's now being used for this PR.

Additional Notes

As 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:

  • All .ets files are correctly identified as ArkTS
  • The grammar file is properly configured
  • No conflicts exist with existing language definitions
  • All samples are real-world examples, not "Hello world" code

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!

@Nixinova
Copy link
Contributor

Nixinova commented Sep 21, 2025

ok thanks mr gpt

youll need to link where you got the samples from also.

@Groupguanfang
Copy link
Contributor Author

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:

@Groupguanfang Groupguanfang changed the title Add .ets extension to TypeScript Add ArkTS language support Sep 21, 2025
@SummerKaze
Copy link

There is also this HarmonyOS open-source project repository collection:

HMOSHapURL

Some of the repository links might be hosted on Gitee, a Chinese code hosting platform.

@Groupguanfang
Copy link
Contributor Author

🎉 I tested it in my forked github-linguist repository, and now it 's perfectly passable CI: https://github.com/Groupguanfang/linguist/actions/runs/17894256842

@Groupguanfang
Copy link
Contributor Author

@lildude Fixed! I followed the CONTRIBUTING.md instructions and ran script/update-ids to get the correct language_id: 56341321 for ArkTS.

@Groupguanfang
Copy link
Contributor Author

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
@Groupguanfang
Copy link
Contributor Author

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!

@Nixinova
Copy link
Contributor

No need to fret about commit history, it's all squashed at the end.

@OverflowCat
Copy link

OverflowCat commented Sep 22, 2025

  • Hex value: #3178c6
  • Rationale: Used the same color as TypeScript since ArkTS is a superset of TypeScript, maintaining visual consistency while indicating the relationship between the languages

Huawei's GitCode uses the same #3178c6 for TS, but #0080ff for ArkTs. I think it is better to follow suit as this is their language. Also in an ArkTs project, pure TS can also be used. Different colors can distinguish between them.


@Groupguanfang
Copy link
Contributor Author

OK 👌 I updated ArkTS color to #0080ff to match ArkTS's official color scheme, Thank you for the reminder @OverflowCat

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Important

The changes in this PR will not appear on GitHub until the next release has been made and deployed. See here for more details.

@lildude lildude added this pull request to the merge queue Oct 6, 2025
Merged via the queue into github-linguist:main with commit 347e912 Oct 6, 2025
5 checks passed
@lildude
Copy link
Member

lildude commented Jan 8, 2026

Reverting this as it appears the grammar wasn't added cleanly and correctly using the script/add-grammar and is now causing issues in other PRs.

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.

lildude added a commit that referenced this pull request Jan 8, 2026
lildude added a commit that referenced this pull request Jan 8, 2026
Revert "Add ArkTS language support (#7593)"

This reverts commit 347e912.
@Groupguanfang
Copy link
Contributor Author

Oh, sorry about that — I previously tried to add support for HML syntax to VSCode.
HML is a temporary language used in HarmonyOS before ArkTS, and its syntax is very similar to HTML.
However, since this has caused confusion here, I’ve decided to remove the HML syntax I added earlier.
For HML itself, I plan to maintain it in a separate repository when I have more free time.

Additionally, due to my lack of familiarity with how linguist scans tmLanguage.json files in submodules,
I mistakenly placed the VSCode language configuration file inside the syntaxes directory.
My apologies for that 🙏 — I’ve now moved it to a separate folder so that it will no longer be picked up by linguist.

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?

@lildude
Copy link
Member

lildude commented Jan 8, 2026

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.

@Groupguanfang
Copy link
Contributor Author

I’ve created a new PR (#7742). Thanks in advance for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants