Skip to content

index.d.ts 当前无法通过 TypeScript declaration check #2

Description

@evan188199-tech

环境

  • commit: df10fd33f31765976f2a981190aca2b3ae9b2c32
  • TypeScript: 5.9.3

最小复现

git clone https://github.com/marginnoteapp/AddonLib.git
cd AddonLib
git checkout df10fd33f31765976f2a981190aca2b3ae9b2c32
npx tsc@5.9.3 --noEmit --target es2015 --skipLibCheck false index.d.ts

命令退出码为 2。为避免粘贴完整长日志,这里按错误类型归纳:

  • TS1036 / TS1038 / TS1183:ambient context 中存在语句、重复 declare 或实现,例如 index.d.ts:202index.d.ts:659index.d.ts:3864
  • TS2300NSURLConnectionindex.d.ts:660index.d.ts:712 重复声明。
  • TS1040 / TS2371:ambient declaration 中使用 async 或参数默认值,例如 index.d.ts:3253index.d.ts:3861
  • TS1095:setter 声明带返回类型,例如 index.d.ts:3399 起多处。
  • TS2304 / TS2552UIFontTextStyleNSArrayUIBarButtonItemNSUndoManagerUIKeyModifierFlagsUIScreenTimeZoneNSValueExtensionPanelControllerTpath 等名称未声明。

另外,部分运行时公共对象和方法没有出现在 index.d.ts 中,例如:

  • runtime.js 中的 Runtime
  • mnnote.js 中的 MNDocumentMNNotebook
  • mnutils.js 中的 ResponseHeaders
  • mnutils.js 中推荐使用的 MNConnection.fetchDev

建议

可以先分两批处理,并且不改变任何运行时行为:

  1. 先修 declaration 语法基线:移除非法实现语法、重复声明、setter 返回类型、ambient async / 默认参数等问题,并加入固定 TypeScript 版本的 declaration check。
  2. 再按现有运行时代码补齐 RuntimeResponseHeadersMNDocumentMNNotebookMNConnection.fetchDev 等公共类型。

请问维护者是否接受加入一个最小的 TypeScript declaration check?如果接受,我可以先提交只包含语法基线修复的小 PR,再单独提交公共 API 类型补齐。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions