{"id":20037599,"url":"https://github.com/mrdulin/typescript-playground","last_synced_at":"2026-04-11T22:46:10.060Z","repository":{"id":55507902,"uuid":"127864365","full_name":"mrdulin/typescript-playground","owner":"mrdulin","description":"TypeScript Playground","archived":false,"fork":false,"pushed_at":"2023-10-27T10:44:08.000Z","size":1042,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T06:27:17.363Z","etag":null,"topics":["jest","ts-jest","ts-node","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/mrdulin.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":"2018-04-03T06:53:32.000Z","updated_at":"2021-11-24T08:38:34.000Z","dependencies_parsed_at":"2023-01-18T15:30:50.510Z","dependency_job_id":"bff17bf1-2a98-41db-8741-8320c7928aae","html_url":"https://github.com/mrdulin/typescript-playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrdulin/typescript-playground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Ftypescript-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Ftypescript-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Ftypescript-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Ftypescript-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrdulin","download_url":"https://codeload.github.com/mrdulin/typescript-playground/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Ftypescript-playground/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27283996,"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","status":"online","status_checked_at":"2025-11-26T02:00:06.075Z","response_time":193,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["jest","ts-jest","ts-node","typescript"],"created_at":"2024-11-13T10:20:28.365Z","updated_at":"2025-11-27T22:03:03.943Z","avatar_url":"https://github.com/mrdulin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Playground\n\n## `TypeScript`简介\n\n- 静态代码分析。为了消除潜在的运行时问题，`ts`被设计成强类型语言，在编译阶段可以进行静态类型检查。`ts`还有一个语言服务层，用来给开发者提供一些工具。例如，生成一些信息给 IDE 或者编辑器提供更好的特性支持，`IntelliSense`或者自动化重构。语言服务支持一系列典型的编辑器操作比如语句自动补全，函数签名提示，代码格式化和突出高亮，着色等。基本的重构功能比如重命名，调试接口辅助功能比如验证断点，还有 TypeScript 特有的功能比如支持增量编译（在命令行上使用--watch）。语言服务是被设计用来有效的处理在一个长期存在的编译上下文中文件随着时间改变的情况；在这样的情况下，语言服务提供了与其它编译器接口不同的角度来处理程序和源文件。\n\n- 与`js`高度兼容，`ts`是`js`的超集，任何有效的`js`代码对`ts`同样有效。\n\n- `ts`可以更好的组织代码结构。`ts`加入了了类(`class`)，接口(`interface`)和模块系统(`module`)，这些特性可以帮助我们更好的组织代码。在团队开发中，可以减少潜在的代码集成问题，并且，还可以增强代码的可维护性，可伸缩性。\n\n- `ts`明确了代码设计阶段和运行阶段，我们在代码设计阶段用`ts`编写代码，在运行阶段，用`ts`编译而成的`js`的代码。`ts`增加的一些新特性，只是用在代码设计阶段。例如，我们可以在`ts`代码中声明（`declare`）接口(`interface`)，但是`js`是不支持接口(`interface`)的，`ts`编译器(`compiler`)在将`ts`代码编译成`js`的过程中，也不会在`js`代码中加入模拟这些特性的代码。\n\n- `ts`编译器(`compiler`)提供代码转换（转换`ts`特性代码为`js`实现），类型擦除（移除静态类型注解），类型擦除不仅仅移除类型注解，还有`ts`独有的特性，例如接口（`interface`）。经过`ts`编译出来的`js`代码，在浏览器环境中有很好的兼容性，通过编译器配置设定，可以设定生成的目标`js`代码为`ecmascript 3`, `ecmascript 5`或者`ecmascript 6`。\n\n- 遵循`ecmascript`标准规范，最新版的`ts`中加入的特性都是基于`ecmascript`标准规范。这表示，将来，很多`ts`文件的代码将自动变为有效的`js`代码。\n\n- 成为跨平台开发工具，可以运行在很多主流系统中。\n\n- TypeScript 作为 JavaScript 的超集，在开发过程中不可避免要引用其他第三方的 JavaScript 的库。虽然通过直接引用可以调用库的类和方法，但是却无法使用 TypeScript 诸如类型检查等特性功能。为了解决这个问题，需要将这些库里的函数和方法体去掉后只保留导出类型声明，而产生了一个描述 JavaScript 库和模块信息的声明文件。通过引用这个声明文件，就可以借用 TypeScript 的各种特性来使用库文件了。\n\n## 说明\n\n- `npm run test:w`，监视文件变动（变动是指`git`没有 commit 的文件）并重新运行单元测试\n- `tsc`使用`tsconfig.json`作为编译器配置，`tsconfig.json`还可以提供项目的全局配置。例如，我们可以在项目根目录下运行`tsc`，编译器将会递归的查找项目的根目录和子目录，并编译所有`ts`文件。\n- 使用`tsc --init`快速生成`tsconfig.json`文件。\n- `tsc`允许项目中有多个`tsconfig.json`文件，这样就可以实现不同目录下使用该目录下的`tsconfig.json`编译器配置文件进行编译。\n\n## 关于`TypeScript`的第三方库的描述文件`@types/xxx`\n\n`TypeScript`最早使用`tsd`作为管理`TypeScript`应用中描述文件的工具，见[repo](https://github.com/DefinitelyTyped/tsd), 但是由于本身有缺陷和性能问题，被废弃。\n见[link](https://stackoverflow.com/questions/35598876/why-is-tsd-deprecated)。\n逐渐被`typings`取代。`typescript 2.0`之前（不包括 2.0），使用[Typings](https://github.com/typings/typings)工具来对`TypeScript`应用中的描述文件进行管理。\n\n`TypeScript 2.0`开始，可以使用`npm`, `yarn`这些包管理工具直接安装第三方描述文件，详见[link](https://tslang.cn/docs/handbook/declaration-files/consumption.html)\n\n## FAQ\n\n- 使用`git clean -f -n`查看可以被删除的`untracked files`。\n- 使用`git clean -f`， 删除`untracked files`。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Ftypescript-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdulin%2Ftypescript-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Ftypescript-playground/lists"}