krahets / hello-algo

《Hello 算法》:动画图解、一键运行的数据结构与算法教程。支持 Python, Java, C++, C, C#, JS, Go, Swift, Rust, Ruby, Kotlin, TS, Dart 代码。简体版和繁体版同步更新,English version ongoing
https://www.hello-algo.com
Other
95.51k stars 12.12k forks source link

feat(TypeScript): Add the workflow file for CI check #1280

Closed Shyam-Chen closed 5 months ago

Shyam-Chen commented 5 months ago

If this pull request (PR) pertains to Chinese-to-English translation, please confirm that you have read the contribution guidelines and complete the checklist below:

If this pull request (PR) is associated with coding or code transpilation, please attach the relevant console outputs to the PR and complete the following checklist:

krahets commented 5 months ago

Hi, I added a bug to test the workflow but it still reported success.

Shyam-Chen commented 5 months ago

It seems like executing TypeScript code (test_all.ts) might not be necessary anymore, as the code doesn't utilize assertions, so type checking should suffice. Moving the execution to JavaScript could be an option.

krahets commented 5 months ago

Please remove the file changes irrelevant to the CI check to make the semantic of the PR clear.

krahets commented 5 months ago

By the way, could you avoid unnecessary force-pushes? It's relatively inconvenient to track the history.

Shyam-Chen commented 5 months ago

Due to the use of modern ES modules, Node does not yet support import.meta.main, a feature exclusively available in Deno.

https://docs.deno.com/runtime/manual/runtime/import_meta_api#importmetamain

require.main === module
// ->
import.meta.url === `file://${process.argv[1]}`
// ->
import esMain from 'es-main';
esMain(import.meta)
Node Deno
import.meta.url :white_check_mark: :white_check_mark:
import.meta.main :x: :white_check_mark:
import.meta.filename :white_check_mark: :white_check_mark:
import.meta.dirname :white_check_mark: :white_check_mark:
import.meta.resolve :white_check_mark: :white_check_mark:
Shyam-Chen commented 5 months ago

Would you like to add the Javascript's workflow file in another PR?

In JavaScript, only the previously written test_all.ts can be used for modification. Or use allowJs in tsconfig.json?

krahets commented 5 months ago

@Shyam-Chen We can do that for JavaScript because it is a relative Ioose programming language. It's acceptable to only find the exception that crashes the program. (Just like Python)