microsoft / microsoft/TypeScript

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

Offen
#18,407 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Domain: lib.d.ts In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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>> { }

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit lib.scripthost.d.ts und überprüfe die vorgeschlagene Deklaration von AutomationObject sowie deren Verwendung als Basis für VarDate und SafeArray. Überprüfe zuerst die Behebung der Issues #18283 und #17526; als erledigt gilt die Aufgabe, wenn die Deklarationen die beschriebenen strukturellen und Konstruktionsbeschränkungen durchsetzen, ohne die scripthost-Definitionen zu beschädigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.