typescript - Typescript 3.3 不再从 d.ts 文件中获取我的函数的类型
问题描述
在我的库 jQuery 终端中,我有用于类型的 d.ts 文件,我有用于测试类型的 test.ts,它只是使用了几乎所有 API,我正在执行 tsc 而不发出输出文件只是为了测试类型.
我已将 typescript 从 3.0 更新到 3.3,现在我的函数类型已损坏:代码如下所示,此示例更复杂,包含字符串、对象和函数的数组:
$('.term').terminal(["foo.php", obj_interpreter, function(command) {
this.echo(command);
}]);
我有这样的类型:
declare namespace JQueryTerminal {
type interpterFunction = (this: JQueryTerminal, command: string, term: JQueryTerminal) => any;
type terminalObjectFunction = (this: JQueryTerminal, ...args: (string | number | RegExp)[]) => (void | PromiseLike<echoValue>);
type Interpterer = string | interpterFunction | ObjectInterpreter;
type ObjectInterpreter = {
[key: string]: ObjectInterpreter | terminalObjectFunction;
}
...
type echoValue = string | string[] | (() => string | string[]);
...
}
interface JQuery<TElement = HTMLElement> {
terminal(interpreter?: TypeOrArray<JQueryTerminal.Interpterer>, options?: TerminalOptions): JQueryTerminal;
...
}
这在 typescript 3.0 中运行良好,并且我已经在 Emacs 潮中完成了 this.echo 并且函数中的命令就像字符串一样,即使在用户代码中我没有指定类型。现在是否需要明确设置用户代码中的类型,这不是重大变化吗?为什么会这样?
供参考的是我损坏的 travis build。
解决方案
推荐阅读
- sql - 如何在 PostgreSQL 中运行两个单独的 INSERT INTO 语句和一个 WITH
- swift - 如何使用 Firebase 和 Swift/Xcode 创建系统集成测试?
- ubuntu - `code` 命令在信任禁用后请求 root
- r - 找不到 mutate 和 svytable 函数
- sql - 如何在 PostgreSQL 中定义和重用列列表
- scala - 用于 alpakka SQS 的 Scala OpenTracing 库
- python - 如何绘制特定时间戳的昼夜曲线(具有平均值)?
- java - 像 ArrayAdapter 这样的单个项目的 Android 适配器是一个列表吗?
- java - HashSet 是一个写得很好的类吗?
- mongodb - 带有可选字段的 MongoDB 索引