TypeScript Primitives Type 项目教程

TypeScript Primitives Type 项目教程

typescript-primitives-type🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)项目地址:https://gitcode.com/gh_mirrors/ty/typescript-primitives-type

1. 项目的目录结构及介绍

typescript-primitives-type/
├── src/
│   ├── index.ts
│   ├── Course.ts
│   ├── CourseId.ts
│   ├── CourseTitle.ts
│   └── ...
├── tests/
│   ├── Course.test.ts
│   └── ...
├── package.json
├── tsconfig.json
└── README.md
  • src/: 包含项目的源代码文件。
    • index.ts: 项目的入口文件。
    • Course.ts: 定义 Course 类。
    • CourseId.ts: 定义 CourseId 类。
    • CourseTitle.ts: 定义 CourseTitle 类。
    • ...: 其他相关模块文件。
  • tests/: 包含项目的测试文件。
    • Course.test.ts: Course 类的测试文件。
    • ...: 其他测试文件。
  • package.json: 项目的依赖管理文件。
  • tsconfig.json: TypeScript 的配置文件。
  • README.md: 项目的说明文档。

2. 项目的启动文件介绍

项目的启动文件是 src/index.ts。这个文件通常包含项目的初始化逻辑和入口点。例如:

import { Course } from './Course';
import { CourseId } from './CourseId';
import { CourseTitle } from './CourseTitle';

const courseId = new CourseId('12345');
const courseTitle = new CourseTitle('TypeScript Basics');
const course = new Course(courseId, courseTitle);

console.log(course);

3. 项目的配置文件介绍

package.json

package.json 文件包含了项目的依赖、脚本和其他元数据。例如:

{
  "name": "typescript-primitives-type",
  "version": "1.0.0",
  "description": "TypeScript utility type to ensure only primitive types",
  "main": "dist/index.js",
  "scripts": {
    "build": "tsc",
    "test": "jest"
  },
  "dependencies": {
    "typescript": "^4.0.0"
  },
  "devDependencies": {
    "@types/jest": "^26.0.0",
    "jest": "^26.0.0",
    "ts-jest": "^26.0.0"
  }
}

tsconfig.json

tsconfig.json 文件是 TypeScript 的配置文件,定义了编译选项和项目结构。例如:

{
  "compilerOptions": {
    "target": "ES6",
    "module": "CommonJS",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

通过这些配置文件,可以确保项目在开发和构建过程中的一致性和正确性。

typescript-primitives-type🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)项目地址:https://gitcode.com/gh_mirrors/ty/typescript-primitives-type

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

甄旖昀Melanie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值