私のライブラリjQueryターミナルには、タイプ用のd.tsファイルがあり、タイプをテストするためのtest.tsがあります。これは、APIのほぼすべてのpiceを使用するだけであり、タイプをテストするためだけに出力ファイルを発行せずに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 をここに示します。