@defold-typescript/library-types

中文文档
0.55.0发布于 2026/10/31MITES Module构建来源已验证近 30 天下载 2015

Vendored TypeScript types for popular Defold Lua libraries, core-type-renamed against @defold-typescript/types.

原始使用文档
文档目录5 节
  1. Why it exists
  2. What's inside
  3. Provenance
  4. Direct use
  5. License

@defold-typescript/library-types

Vendored TypeScript type declarations for a curated set of popular Defold Lua libraries, core-type-renamed against @defold-typescript/types.

This is a support package for the @defold-typescript toolchain. You normally do not install it directly — it ships as a dependency of @defold-typescript/cli, which reads it at runtime.

Why it exists

Many popular Defold libraries are plain Lua, installed through the editor's Fetch Libraries and carrying no .script_api, so there is nothing for the CLI's resolve command to extract types from. For a curated set of those, this package ships hand-vetted, ready-to-use TypeScript declarations.

When resolve encounters a declared dependency with no .script_api, it matches it against this corpus by source identity, verifies the match against the downloaded archive's Lua require paths, and prints the corresponding declarations into the project's .defold-types/libraries/ from the archive the project depends on, or from the sources pinned here. The import specifier is the Lua require path — e.g. import * as dicebag from 'dicebag.dicebag' — so it matches what Fetch Libraries installs at runtime.

What's inside

This package holds the inputs the CLI prints declarations from, and no printed declarations.

  • data/<version>/ — library data, in folders named by the first CLI version that reads them. A CLI reads the highest folder at or below its own version. Each folder holds one folder per library, named for its repository (the URL's last path segment, lowercased, without .git):

    • library.json — the upstream repository and license, the hand-written declaration forks, the native extension, and the base each of the library's index slots counts from.
    • reviewed.json — the upstream ref the library data was reviewed at.
    • recipe.json — the modules generated from the library's LuaLS annotations or .script_api, when it has any.
    • fork/ — the hand-written declarations: forked modules, and the @globalTable declaration of a native extension that ships no .script_api, which resolve installs as written.
    • source/ — the pinned upstream sources each generated module prints from; source/upstream/ holds the upstream files the parity checks measure against.

    Beside the library folders, index-slot-classifications.json holds the base each index slot counts from for the extension pages no library folder holds.

  • library-classification.json, library-targets.json — the ts-defold/library registries the classification tooling keeps.

  • api-doc/<module>.json — ref-doc JSON extracted from each declaration, consumed by the documentation site to render per-library API pages.

  • NOTICE — upstream attribution for every vendored library.

Provenance

The CLI prints each module through the lane its target file names: LuaLS annotations, a .script_api, or a hand-written declaration fork. Many forks descend from ts-defold/library (MIT) at the commit pinned in library-targets.json. ts-defold's hand-written declare module files already model these libraries faithfully; the only surface that differs is core-type naming. A codemod (packages/cli/src/library/sync-library-types.ts) walks the TypeScript AST and rewrites type references only — property names, JSDoc, declare module, and passthrough extensions (LuaMultiReturn, LuaMap) stay byte-identical:

ts-defold@defold-typescript/types
hash, urlHash, Url
vmath.vector3 / vmath.vector4 / vmath.matrix4 / vmath.quatVector3 / Vector4 / Matrix4 / Quaternion
node, texture, … (engine handles)Opaque<"node">, Opaque<"texture">, …

The renamed names resolve against the ambient globals in @defold-typescript/types, so no import injection is needed. Any vmath.* reference with no mapping is a hard error, so a missing rename fails loud rather than degrading to any.

Check every target's printed declarations after changing a lane or re-pinning a source:

bun test packages/cli/src/library

Direct use

This package exposes no declarations of its own: the CLI prints them from the inputs here. Let @defold-typescript/cli resolve write them into your project; see the toolchain docs.

License

MIT. Vendored declarations retain their upstream authors' licenses, credited in NOTICE.

版本与发布记录

@defold-typescript/library-types 共发布 65 个版本,首次发布于 2026/07/08;过去 12 个月发布了 65 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.55.0latest2026/10/3114 天前
0.54.02026/10/2916 天前
0.53.02026/10/2124 天前
0.52.02026/10/1827 天前
0.51.02026/10/1530 天前
0.50.12026/10/141 个月前

关于 @defold-typescript/library-types 的常见问题

@defold-typescript/library-types 是什么?

Vendored TypeScript types for popular Defold Lua libraries, core-type-renamed against @defold-typescript/types.

如何安装 @defold-typescript/library-types?

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

@defold-typescript/library-types 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/defold-typescript__library-types 是否存在。

@defold-typescript/library-types 支持 ESM 还是 CommonJS?

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

@defold-typescript/library-types 可以商用吗?

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

@defold-typescript/library-types 的下载量有多少?

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

@defold-typescript/library-types 还在维护吗?

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