{"id":16697004,"url":"https://github.com/shetharp/ts-prep","last_synced_at":"2025-05-16T05:32:37.363Z","repository":{"id":79024150,"uuid":"290413558","full_name":"shetharp/ts-prep","owner":"shetharp","description":"🧩 A TypeScript starter for solving LeetCode problems with test-driven development","archived":false,"fork":false,"pushed_at":"2020-08-30T00:51:05.000Z","size":68,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T21:04:06.410Z","etag":null,"topics":["javascript","jest","leetcode","leetcode-typescript","nodejs","tdd","tdd-typescript","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shetharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-26T06:23:01.000Z","updated_at":"2024-05-02T21:48:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"f6f88817-79bb-4952-b535-21c828eb15ad","html_url":"https://github.com/shetharp/ts-prep","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetharp%2Fts-prep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetharp%2Fts-prep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetharp%2Fts-prep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetharp%2Fts-prep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shetharp","download_url":"https://codeload.github.com/shetharp/ts-prep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474717,"owners_count":22077349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","jest","leetcode","leetcode-typescript","nodejs","tdd","tdd-typescript","typescript"],"created_at":"2024-10-12T17:45:44.753Z","updated_at":"2025-05-16T05:32:37.357Z","avatar_url":"https://github.com/shetharp.png","language":"TypeScript","readme":"# ts-prep\n\n_🧩 A TypeScript starter for solving LeetCode problems with test-driven development_\n\n# Usage\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003ePrerequisites\u003c/strong\u003e\n  \u003c/summary\u003e\n\n  - Ensure you have \n  [Node](https://nodejs.org/en/download/)\n  installed on your machine before proceeding.\n\n  - Clone this repo locally and `cd` into it\n\u003c/details\u003e\n\n1. Install dependencies\n   ```shell\n   npm install\n   ```\n \n 2. Start test-driven-development (TDD)\n    ```shell\n    npm start\n    ```\n    _This script runs [Jest](https://jestjs.io/) in watch mode._\n\n3. Start making changes! \n   - You will see your changes be validated against your test cases.\n   - [Add a new problem](#add-a-new-problem) with the script (or manually)\n   - [Test your solution](#jest-tips-for-test-driven-development) with Jest using TDD\n\n\n## Add a new problem\n\nIn the root directory of the repo, run\n```shell\nnpm run new-problem '\u003ctitle\u003e'\n```\n\u003cdetails\u003e\n \u003csummary\u003e\n  Where \u003ccode\u003e\u0026lt;title\u0026gt;\u003c/code\u003e is the LeetCode problem's title.\n\u003c/summary\u003e\n\n- The format of the title should be: `{number}. {name}`\n- The title must start with a number, followed by a period. Otherwise, the script won't work!\n- The title should be wrapped in quotes for the argument to get passed into the script\n\u003c/details\u003e\n\nFor example, if you want to set up starter files for problem _[202. Happy Number](https://leetcode.com/problems/happy-number/)_, you would run\n```shell\nnpm run new-problem '202. Happy Number'\n```\n\n\u003cdetails\u003e\n \u003csummary\u003e\n  About this script\n \u003c/summary\u003e\n\nThis repo comes with a script to quickly set up starter files for new LeetCode problems\u0026mdash;letting you focus on the real problem solving!\n\nThis script is defined in the `package.json`. \nIt uses your local Node runtime environment to execute the `scripts/new-problem.js` file.\nThe script parses the inputted title and uses the templates to auto-generate the boilerplate `.md` and `.ts` files.\n\nYou could run this script directly from the repo root:\n```shell\nnode ./scripts/new-problem.js -t '\u003ctitle\u003e'\n```\n\u003c/details\u003e\n\n_Alternatively, you can add a new problem manually by following the repo [structure](#structure)._\n\n## Jest Tips for Test-Driven Development\n\nIf you are running Jest (`npm start`), you can press the `w` key to get a list of watch usage commands.\nFor example, you can press `p` to filter by a filename pattern and run tests only in those files.\n\n#### Unit Test\nUnit tests are typically denoted using the `it()` function, which is an alias for the `test()` function.\n\n#### Focus Test\nTo run only specific tests and skip all others, rename the desired test(s) to **`fit()`** instead of `it()`.\n\n#### Exclude Test\nTo run all tests except specific tests, rename the desire test(s) to **`xit()`** instead of `it()`.\n\n# Structure\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      \u003ccode\u003esrc/\u003c/code\u003e\n    \u003c/strong\u003e\n    \u0026ndash; In general, you should do all your work here\n  \u003c/summary\u003e\n\n- Each LeetCode problem should have its own directory\n- Add a `.md` file in the problem directory for the problem description and discussion\n- Add a `.ts` file in the problem directory to solve and test\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      \u003ccode\u003escripts/\u003c/code\u003e\n    \u003c/strong\u003e\n    \u0026ndash; Contains custom scripts and templates\n  \u003c/summary\u003e\n\n- The `new-problem.js` script is used to set up starter files for new LeetCode problems\n- The `templates` directory contains files that define the boilerplate content for auto-generating `.md` and `.ts` files\n- Feel free to add or modify scripts or templates to fit your needs\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      \u003ccode\u003ejest.config.js\u003c/code\u003e\n    \u003c/strong\u003e\n    \u0026ndash; Defines our custom Jest configuration\n  \u003c/summary\u003e\n\n- We match test cases defined in regular `.ts` files\n  - By default, Jest matches `.ts` files in a `__tests__` dir or if the filename ends with `.spec.ts` or `.test.ts`\n  - Our custom `testMatch` rule lets write code to solve and test in one file\n- We use `ts-jest` as a dependency to transform `.ts` files for Jest\n  - By default, Jest only works with JavaScript\n- Learn how to configure [Jest for TypeScript](https://basarat.gitbook.io/typescript/intro-1/jest)\n\u003c/details\u003e\n\n# How to Contribute\n\nPlease note that this repo is meant to be a _starter_, so we don't need contributors to submit LeetCode problems solved with TypeScript.\nHowever, any tooling or documentation that you would like to contribute to make the developer experience better is welcomed!\n\n1. Fork this repo and set it up locally\n2. Make your desired changes and commit them to a feature branch in your forked repo\n3. Open up a PR from your forked repo branch against this repository\n\nThanks for making this project better! 💪\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetharp%2Fts-prep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshetharp%2Fts-prep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetharp%2Fts-prep/lists"}