{"id":23583634,"url":"https://github.com/qszhu/ts-leetcode","last_synced_at":"2026-03-09T15:32:54.814Z","repository":{"id":40433784,"uuid":"284284474","full_name":"qszhu/ts-leetcode","owner":"qszhu","description":"Cli for solving LeetCode questions in TypeScript","archived":false,"fork":false,"pushed_at":"2024-01-05T06:45:22.000Z","size":478,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T08:36:56.237Z","etag":null,"topics":["cli","leetcode","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qszhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-01T15:16:54.000Z","updated_at":"2024-06-09T07:01:47.000Z","dependencies_parsed_at":"2024-01-05T07:36:39.915Z","dependency_job_id":"4b99c65d-7a16-45d6-9325-2df2aac71fe0","html_url":"https://github.com/qszhu/ts-leetcode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qszhu/ts-leetcode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qszhu%2Fts-leetcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qszhu%2Fts-leetcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qszhu%2Fts-leetcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qszhu%2Fts-leetcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qszhu","download_url":"https://codeload.github.com/qszhu/ts-leetcode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qszhu%2Fts-leetcode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30301109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","leetcode","typescript"],"created_at":"2024-12-27T02:15:09.031Z","updated_at":"2026-03-09T15:32:54.782Z","avatar_url":"https://github.com/qszhu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"背景和开发过程见此[博文](https://qszhu.github.io/2020/08/16/leetcode-with-typescript.html)\n\n## LeetCode TypeScript 解题工具\n\n### 特性\n* 针对`leetcode-cn.com`开发\n* 提供`TypeScript`工程模版，支持自定义\n* 使用本地测试数据\n* 支持同一个问题的多个解答，可随时切换\n\n### 运行需求\n\n* Node.js v10+\n* Google Chrome\n* 仅在Mac OSX下测试过\n\n### 安装\n\n```bash\n$ npm i -g ts-leetcode\n```\n\n### 初始化工程\n\n* 由[leetcode-ts-template](https://github.com/qszhu/leetcode-ts-template)模版创建工程并clone到本地\n\n* 在工程根目录运行以下命令：\n\n```bash\n$ npm i\n$ mv .tslcrc.example .tslcrc\n```\n\n* 根据需要调整`.tslcrc`中`browserPath`的值为Google Chrome浏览器路径\n\n* 登录（用户名和密码会被直接发送到leetcode网站，不会被保存到本地或其他地方）：\n\n```bash\n$ tslc login\n✔ Username: · xxxxxxxx\n✔ Password: · ********\nLogging in, this may take some time...\nSuccess!\n```\n\n### 解题步骤\n\n1. 创建解答目录\n\n```bash\n$ tslc init invert-binary-tree\n```\n\n需提供题目的短标题作为参数。例如题目的url为`https://leetcode-cn.com/problems/invert-binary-tree/`，则题目的短标题为url路径的最后一部分`invert-binary-tree`\n\n若第一次运行，此命令会创建如下目录结构：\n\n```\nquestions/invert-binary-tree\n├── input\n├── solution.ts -\u003e solution1.ts\n├── solution1.ts\n└── tsconfig.json\n```\n\n2. 编辑`input`中的测试数据\n\n3. 编辑`solution.ts`中的代码\n\n4. 编译\n\n```bash\n$ tslc build\nHash: f5834e34f10e512f08a5\nVersion: webpack 4.44.1\nTime: 1235ms\nBuilt at: 2020-08-15 11:46:53 AM\n      Asset      Size  Chunks             Chunk Names\nsolution.js  7.03 KiB       0  [emitted]  main\nEntrypoint main = solution.js\n[0] ./questions/invert-binary-tree/solution1.ts 868 bytes {0} [built]\n```\n\n5. 测试\n\n```bash\n$ tslc test\nSTARTED\nSTARTED\nSUCCESS\n```\n\n6. 提交\n\n```bash\n$ tslc submit\nSTARTED\nAccepted\nRuntime: 84 ms, 32.27%\nMemory: 40 MB, 5.12%\n```\n\n### 配置`.tslcrc`\n\n* `browserPath`: Google Chrome浏览器路径\n* `mode`: [webpack mode](https://webpack.js.org/configuration/mode/)\n\n### 备注\n\n* `tslc init`可以被多次运行，每次运行会新增一个解答文件\n  * 新文件按照`solution2.ts`, `solution3.ts`的顺序命名\n  * `solution.ts`是指向最新解答文件的软链接，是后续构建测试和提交的输入文件\n  * `tslc select \u003cn\u003e [questionSlug]`会将软链接指向`solution\u003cn\u003e.ts`\n* 如果未向命令行提供题目短标题，则会使用最近一次命令中使用过的短标题\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqszhu%2Fts-leetcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqszhu%2Fts-leetcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqszhu%2Fts-leetcode/lists"}