NestJS Mapped Types 项目教程
mapped-typesConfiguration module for Nest framework (node.js) 🐺 项目地址:https://gitcode.com/gh_mirrors/ma/mapped-types
1. 项目的目录结构及介绍
/nestjs-mapped-types
├── src
│ ├── index.ts
│ ├── utils
│ │ ├── clone-plugin.ts
│ │ ├── merge-plugins.ts
│ │ └── transform.ts
│ ├── types
│ │ ├── partial.ts
│ │ ├── pick.ts
│ │ ├── omit.ts
│ │ └── intersection.ts
│ └── tests
│ ├── partial.spec.ts
│ ├── pick.spec.ts
│ ├── omit.spec.ts
│ └── intersection.spec.ts
├── package.json
├── tsconfig.json
└── README.md
目录结构介绍
- src: 源代码目录,包含主要的 TypeScript 文件。
- index.ts: 项目的入口文件。
- utils: 工具函数目录,包含克隆、合并和转换等工具函数。
- types: 类型定义目录,包含部分、选择、省略和交集等类型定义。
- tests: 测试目录,包含各个类型的单元测试。
- package.json: 项目依赖和脚本配置文件。
- tsconfig.json: TypeScript 编译配置文件。
- README.md: 项目说明文档。
2. 项目的启动文件介绍
src/index.ts
export * from './types/partial';
export * from './types/pick';
export * from './types/omit';
export * from './types/intersection';
- 功能: 导出所有类型定义,使得其他模块可以方便地使用这些类型。
- 入口点: 项目的入口文件,负责导出所有类型定义。
3. 项目的配置文件介绍
package.json
{
"name": "nestjs-mapped-types",
"version": "1.0.0",
"description": "Mapped types utilities for NestJS",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest"
},
"dependencies": {
"@nestjs/common": "^8.0.0",
"typescript": "^4.0.0"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"jest": "^27.0.0",
"ts-jest": "^27.0.0"
}
}
- 功能: 定义项目的名称、版本、描述、入口文件、类型定义文件、脚本命令和依赖项。
- 脚本命令:
build
: 使用 tsc
编译 TypeScript 代码。test
: 使用 jest
运行测试。
- 依赖项:
@nestjs/common
: NestJS 的公共模块。typescript
: TypeScript 编译器。@types/jest
, jest
, ts-jest
: 用于测试的依赖项。
tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
}
- 功能: TypeScript 编译器配置。
- 编译选项:
target
: 指定编译目标为 ES6。module
: 指定模块系统为 CommonJS。outDir
: 指定输出目录为 dist
。strict
: 启用严格模式。esModuleInterop
: 启用 ES 模块互操作。skipLibCheck
: 跳过库文件的类型检查。forceConsistentCasingInFileNames
: 强制文件名大小写一致。
- 包含文件: 包含
src
目录下的
mapped-typesConfiguration module for Nest framework (node.js) 🐺 项目地址:https://gitcode.com/gh_mirrors/ma/mapped-types