microsoft / microsoft/TypeScript

Using createProgram outside node environment throws unhelpful exception message

Open
#28,368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: API In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

When running createProgram from inside my angular app I'm thrown the 'ts.sys is undefined' error. This error is not helpful since I'm not given the reason for it. It took me a lot of time researching and eventually a question on SO (https://stackoverflow.com/questions/52969177/typescript-createprogram-throwing-ts-sys-is-undefined) to get the answer.

A more elaborate error message would've had been of great help.

TypeScript Version: 3.1.3

Search Terms: 'ts.sys is undefined'

Code

try {
    createProgram(Utils.getFileNames(), {
        lib: ['lib.es6.d.ts']
        // target: ScriptTarget.ES5,
        // module: ModuleKind.CommonJS
    });
} catch (ex) {
    debugger;
}

Expected behavior:

An exception message explaining I should run this code from node environment or pass my own compiler.

Actual behavior:

Throws 'ts.sys is undefined'

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 at the createProgram API path and reproduce the shown call from an Angular or other non-Node environment. Done means the exception explains that the code should run in Node or receive a custom compiler, instead of only reporting that ts.sys is undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.