microsoft / microsoft/TypeScript
Add base class in lib.scripthost.d.ts for Automation objects
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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>> { }
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da lib.scripthost.d.ts e rivedi la dichiarazione proposta di AutomationObject e il suo utilizzo come base per VarDate e SafeArray. Verifica prima la risoluzione degli issue #18283 e #17526; il lavoro è completo quando le dichiarazioni impongono le restrizioni strutturali e di costruzione descritte senza danneggiare le definizioni di scripthost.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100