Catalog npm
Back to packageRELEASE DETAILS

0.2.0

npm

0type

ts类型包

tstypetypescript
Published27 Dec 2024
Direct dependencies24
Transitive dependenciesNot calculated

README

Current package documentation

描述

ts 内置常用 & 拓展

  • 拓展内置类型名前加E, 表示对原有的类型进行拓展

Record<K, T>

  • 生成属性为K, 类型为T的类型几何
  • K 只支持 number, string , symbol 的类型
 const t1: Record<'s' |  -1 | symbol, number> = {
  's': 123,
  '-1': 123,
  [Symbol(1)]: 123
 }

ERcord<K, T>

  • 拓展K的支持类型 null, undefined, boolean
 const te1: ERecord<null | undefined| true | false | '12', 1> = {
  null: 1,
  undefined: 1,
  false: 1,
  true: 1,
  12: 1
 }

Partial<T>

  • 全部变可选
 type tt = {
  a: number,
  b: number
 }

 const t2: Partial<tt> = {}

Required<T>

  • 全部变必填
 type tt = {
  a?: number,
  b: number
 }

 const t3: Required<tt> = {
  a: 0,
  b: 0
 }

Readonly<T>

  • 全部变只读
 type tt = {
  a: number,
  b: number
 }
 type t1 = Readonly<tt>
 // 等同于
 type t2 = {
  readonly a: number;
  readonly b: number;
 }

Pick<T,K>

  • 提取指定属性
 type tt = {
  n: number,
  n2: number,
  s: string,
  s2: string,
 }
 const t1: Pick<tt, 'n'> = {
  n: 1
 }
 const t2: Pick<tt, 'n'|'s'> = {
  n: 1,
  s: 's'
 }

Exclude<T,U>

  • 从T中排除掉所有包含U的属性
 type tt = number | string | boolean
 const t1: Exclude<tt, number|string> =  true
 const t2: Exclude<tt, number|boolean> = '12'

Extact<T,U>

  • 提取T和U都有的
 type tt = number | string | boolean
 const t1: Extract<tt, number> =  12
 const t2: Extract<tt, boolean> = true

NonNullable<T>

  • 去除掉null和underfined
// 不可以为 null 和 undefined
const t1: NonNullable<number> = 1
const t2: NonNullable<123> = 123

Omit<T,K>

  • 忽略T中的K属性

基础类型

类型描述预期
NumberLike可转number的类型 number | `${number}`
CanStringified可转string的类型string | number | bigint | boolean | null | undefined

ts拓展

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 24

Native requirements
24 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@commitlint/cli
Environment
{
  "local_name": "@commitlint/cli",
  "alias": false,
  "peer_metadata": null
}
^12.1.4development
@commitlint/config-conventional
Environment
{
  "local_name": "@commitlint/config-conventional",
  "alias": false,
  "peer_metadata": null
}
^12.1.4development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^16.11.22development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.12.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.12.0development
commitizen
Environment
{
  "local_name": "commitizen",
  "alias": false,
  "peer_metadata": null
}
^4.2.4development
commitlint-config-cz
Environment
{
  "local_name": "commitlint-config-cz",
  "alias": false,
  "peer_metadata": null
}
^0.13.3development
cz-conventional-changelog
Environment
{
  "local_name": "cz-conventional-changelog",
  "alias": false,
  "peer_metadata": null
}
^3.3.0development
cz-customizable
Environment
{
  "local_name": "cz-customizable",
  "alias": false,
  "peer_metadata": null
}
^6.3.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.9.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^8.3.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.23.4development
eslint-plugin-jsx-a11y
Environment
{
  "local_name": "eslint-plugin-jsx-a11y",
  "alias": false,
  "peer_metadata": null
}
^6.4.1development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^3.4.0development
eslint-plugin-react
Environment
{
  "local_name": "eslint-plugin-react",
  "alias": false,
  "peer_metadata": null
}
^7.24.0development
eslint-plugin-react-hooks
Environment
{
  "local_name": "eslint-plugin-react-hooks",
  "alias": false,
  "peer_metadata": null
}
^4.2.0development
eslint-plugin-simple-import-sort
Environment
{
  "local_name": "eslint-plugin-simple-import-sort",
  "alias": false,
  "peer_metadata": null
}
^7.0.0development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^7.0.4development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^12.3.4development
node-notifier
Environment
{
  "local_name": "node-notifier",
  "alias": false,
  "peer_metadata": null
}
^8.0.2development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^3.0.2development
ts-node-dev
Environment
{
  "local_name": "ts-node-dev",
  "alias": false,
  "peer_metadata": null
}
^1.1.8development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.5.5development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-4bBJmMeXt7fgqyKjwV0a5gEoYbfx7+N/ctd766iFNHumlEeufCZqMFAiYapLWB38F9RPdd/HNwhqOcPDHKIGFA==",
  "shasum": "6ea6748aa2901b121a2c8735d0c3d80ea0689717",
  "tarball": "https://registry.npmjs.org/0type/-/0type-0.2.0.tgz",
  "fileCount": 9,
  "unpackedSize": 5801,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQDSJLeWV+Y990S+QD1iUqsE1yuI6QGBtGRHEqaAZzuF2QIgW7XW+akV6weaZV+U0aw1rz5dkmaTWCV6nVX+JtV5Ms4="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:45 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:6aa7e5c77534b96affc1c548496a5e6198687a9afb9df09ce01503ce02ff6f3c

Other collected versions

0.1.07 Apr0.0.37 Apr0.0.27 Apr0.0.128 NovView all collected versions →