I am encountering an issue while trying to utilize the createProgram
function. The error message states that ts.sys is undefined
when running the following code:
try {
createProgram(Utils.getFileNames(), {
lib: ['lib.es6.d.ts']
// target: ScriptTarget.ES5,
// module: ModuleKind.CommonJS
});
} catch (ex) {
debugger;
}
I have attempted both ways, with and without the commented part as well as including the lib
option.
Below is the stack trace provided:
createCompilerHost@http://localhost:4200/vendor.js:203082:13
createProgram@http://localhost:4200/vendor.js:203374:24
./src/app/docs/generator.ts/Generator.generate@http://localhost:4200/main.js:1855:13
GettingStartedComponent@http://localhost:4200/main.js:3352:9
createClass@http://localhost:4200/vendor.js:42397:20
createDirectiveInstance@http://localhost:4200/vendor.js:42284:20
createViewNodes@http://localhost:4200/vendor.js:43504:36
createRootView@http://localhost:4200/vendor.js:43418:5
callWithDebugContext@http://localhost:4200/vendor.js:44449:22
debugCreateRootView@http://localhost:4200/vendor.js:43936:12
./node_modules/@angular/core/fesm5/core.js/</ComponentFactory_.prototype.create@http://localhost:4200/vendor.js:41764:20
./node_modules/@angular/core/fesm5/core.js/</ComponentFactoryBoundToModule.prototype.create@http://localhost:4200/vendor.js:36416:16
./node_modules/@angular/core/fesm5/core.js/</ViewContainerRef_.prototype.createComponent@http://localhost:4200/vendor.js:41874:28
Highlighted sections of interest include:
createCompilerHost@http://localhost:4200/vendor.js:203082:13
createProgram@http://localhost:4200/vendor.js:203374:24
The code example I am using can be found on TypeScript's wiki page here: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#using-the-type-checker
I have researched this issue but could not find a solution. Could it be a missing package or configuration problem? Any assistance would be greatly appreciated...
Here are my imports:
import {
Node,
createProgram,
forEachChild,
isClassDeclaration,
isModuleDeclaration,
TypeChecker,
ScriptTarget,
ModuleKind
} from 'typescript';