@citestyle/types

中文文档
1.0.1发布于 2026/04/27MITTypeScriptES Module零依赖近 30 天下载 1864

TypeScript type definitions for CSL-JSON, compiled styles, and registry

原始使用文档
文档目录8 节
  1. Installation
  2. Types
  3. CSL-JSON data
  4. Compiled style modules
  5. Registry
  6. Compiler
  7. Formatting helpers
  8. Usage

@citestyle/types

TypeScript type definitions for the Citestyle ecosystem. Covers CSL-JSON data structures, compiled style modules, the citation registry, and all public APIs.

You get these types automatically when using any @citestyle/* package — each package's exports map includes a types condition that points here. Install this package directly only if you need to import types without pulling in a runtime package.

Installation

npm install -D @citestyle/types

Types

CSL-JSON data

TypeDescription
CslItemA citation item with all standard CSL-JSON fields (70+), plus year-suffix and an index signature for extended fields
CslNameName object: family, given, non-dropping-particle, dropping-particle, suffix, literal
CslDateDate object: date-parts, literal, raw, season, circa
CslItemTypeUnion of all 40+ CSL item type strings

Compiled style modules

TypeDescription
CompiledStyleA compiled style module: meta, bibliography(), citation(), bibliographySort()
StyleMetaStyle metadata: id, title, class, disambiguation settings, collapse mode, delimiters
FormattedEntryBibliography output: { text, html, parts, links }
FormattedCitationCitation output: { text, html }

Registry

TypeDescription
RegistryRegistry interface: addItems(), getItem(), cite(), getBibliography(), size
RegistryOptionsOptions for createRegistry(): subsequentAuthorSubstitute
CiteRefA citation reference: id, item, locator, label, prefix, suffix
FormatContextRuntime context passed to style functions: _secOpts, _disambig
DisambiguationContextPer-cite disambiguation state: addNames, addGivenname, givenname

Compiler

TypeDescription
CompileOptionsOptions for compile(): locale, format
CompileResultCompiler output: { code, meta }

Formatting helpers

TypeDescription
NameFormatConfigConfiguration for formatNames(): et-al, particles, sort order, initialization
DateFormatConfigConfiguration for formatDate(): date parts, month terms, ranges
ValidationResultOutput of validateItem(): { valid, warnings }

Usage

import type { CslItem, CslName, FormattedEntry, CompiledStyle } from '@citestyle/types'

const item: CslItem = {
  id: '1',
  type: 'article-journal',
  title: 'A groundbreaking study',
  author: [{ family: 'Smith', given: 'Jane' }],
  issued: { 'date-parts': [[2024, 6]] },
  'container-title': 'Nature',
  DOI: '10.1038/example',
}

function formatBibliography(style: CompiledStyle, items: CslItem[]): FormattedEntry[] {
  return items.map(item => style.bibliography!(item))
}
import type { Registry, CiteRef, FormattedCitation } from '@citestyle/types'

function citeItems(registry: Registry, ids: string[]): FormattedCitation {
  const cites: CiteRef[] = ids.map(id => ({ id }))
  return registry.cite(cites)
}

版本与发布记录

@citestyle/types 共发布 3 个版本,首次发布于 2026/03/13;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.1latest2026/04/276 个月前
1.0.02026/03/137 个月前
0.0.22026/03/137 个月前

关于 @citestyle/types 的常见问题

@citestyle/types 是什么?

TypeScript type definitions for CSL-JSON, compiled styles, and registry

如何安装 @citestyle/types?

在项目目录运行 npm install @citestyle/types,或使用 pnpm add / yarn add / bun add。

@citestyle/types 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@citestyle/types 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@citestyle/types 可以商用吗?

@citestyle/types 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@citestyle/types 的下载量有多少?

根据 npm 官方下载统计,@citestyle/types 在 2026/10/10 – 2026/11/08 这 30 天内被下载 1,864 次,日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@citestyle/types 还在维护吗?

最新版本 1.0.1 发布于 2026/04/27(6 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/03/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。