microsoft / microsoft/TypeScript

Add base class in lib.scripthost.d.ts for Automation objects

オープン
#18,407 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: lib.d.ts In Discussion Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 2.5.0 / nightly (2.6.0-dev.20170902)

Code

// in lib.scripthost.d.ts
class AutomationObject<T> {
  private constructor();
  private typekey: AutomationObject<T>;
}

// in activex-excel.d.ts
declare namespace Excel {
    class Application extends AutomationObject<Application> {
        Workbooks: any;
    }
}

interface ActiveXObject {
    new(progid: 'Excel.Application'): Excel.Application;
}
    
// usage
let x: Excel.Application = new ActiveXObject('Excel.Application');

This currently wouldn't compile, because of the private constructor in the base class; but pending resolution of #18283, it would be possible.

This would prevent assigning structurally matching objects to the inheriting types:

// Compiler error
x = {
    Workbooks: [];
};

and also prevent using new to create a new instance of the inheriting type:

// Compiler error
x = new Excel.Application();

I've opened an issue to define similar behavior for VarDate and SafeArray<T> in lib.scripthost.d.ts. If AutomationObject<T> is defined, then it could be used in lib.scripthost.d.ts as a base class for these types as well:

declare class VarDate extends AutomationObject<VarDate> { }
declare class SafeArray<T> extends AutomationObject<SafeArray<T>> { }

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

lib.scripthost.d.ts から始め、提案されている AutomationObject の宣言と、VarDate および SafeArray の基底としての使用を確認します。まず issue #18283 と #17526 の解決内容を確認してください。完了とは、宣言によって説明されている構造上および構築上の制約が適用され、scripthost の定義を壊さないことを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。