microsoft / microsoft/TypeScript

In scripthost.d.ts add `WScript` interface for extendibility

Open
#42,610 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

lib Update Request

I want to write a type lib to extend WScript, allow CreateObject to recognize some specified ProgId, and make the returned COMObject typed:

var app = WScript.CreateObject("Microsoft.Excel");
//   ^^ 
//   make this typed

But in scripthost.d.ts, The type of WScript is inlined with it's declearation:

declare var WScript: { /* inlined type definition */ };

To make it possible to extend, we can add a interface using the same name WScript and set this as the type of the var WScript:

interface WScript { /* type definition of WScript */ }

declare var WScript: WScript;

In thiry part lib, they could extend WScript var by extends the interface WScript. for example, In my lib, I could write:

interface WScript {
    CreateObject("Microsoft.Excel"): Excel.App;
}

declare namespace Excel {
    interface App {
        //...
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scripthost.d.ts by locating the inline WScript declaration and the CreateObject signature. Refactor the declaration so WScript is an interface used by the global variable, and confirm that a third-party interface augmentation can specialize CreateObject for a specified ProgId and return a typed COM object.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.