Skip to content

Instantly share code, notes, and snippets.

@stelcheck
Last active May 24, 2017 00:07
Show Gist options
  • Save stelcheck/c26d97cc9af9905ca9bdf3729215ebc2 to your computer and use it in GitHub Desktop.
Save stelcheck/c26d97cc9af9905ca9bdf3729215ebc2 to your computer and use it in GitHub Desktop.
TypeScript Compiler API
import * as path from 'path'
import * as ts from 'typescript'
const glob = require('glob')
const globPattern = path.join(this.projectPath, 'lib/modules/**/usercommands/*.ts')
const userCommandFiles = glob.sync(globPattern)
// Build a program using the set of root file names in fileNames
const program = ts.createProgram(this.userCommandFiles, {
target: ts.ScriptTarget.ES2017, module: ts.ModuleKind.CommonJS
})
// Get the checker, we will use it to find more about classes
const checker = this.program.getTypeChecker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment