How to use the createProgram function from typescript

Find comprehensive JavaScript typescript.createProgram code examples handpicked from public code repositorys.

109
110
111
112
113
114
115
116
117
118
var tsOptions = getTsOptions(options);
if (!checkFiles(fileNames, "File for compiling is not found"))
    return;
var host = ts.createCompilerHost(tsOptions);
// Build a program using the set of root file names in fileNames
var program = ts.createProgram(fileNames, tsOptions, host);
// Get the checker, we will use it to find more about classes
var checker = program.getTypeChecker();
var outputClasses = [];
var outputPMEs = [];
fork icon3
star icon4
watch icon4

+ 17 other calls in file

25
26
27
28
29
30
31
32
33
34
}
const tsConfig = buildTsConfig(params);
// NOTE(krishan711): I couldn't find a way to filter node_modules in the glob (filtering needed for lerna repos)
const files = glob.sync(path.join(params.directory || './src', '**', '*.{ts, tsx}'));
const filteredFiles = files.filter((file) => !file.includes('/node_modules/'));
const program = typescript.createProgram(filteredFiles, {
  ...tsConfig.compilerOptions,
  ...(customConfig.compilerOptions || {}),
  noEmit: true,
});
fork icon1
star icon2
watch icon2

+ 441 other calls in file

142
143
144
145
146
147
148
149
150
151
  transformers: {
    before: [transformClassConstructor],
  },
});

const program = ts.createProgram({
  rootNames: [filePath],
  options: {
    module: ts.ModuleKind.CommonJS,
    target: ts.ScriptTarget.ES5,
fork icon0
star icon0
watch icon1

+ 18 other calls in file

84
85
86
87
88
89
90
91
92
93
    } else {
      throw new Error('Expected only one dependency.');
    }
  },
};
const program = ts.createProgram(
  ['lib.d.ts', 'jest.d.ts', contentFilename],
  tsOptions,
  compilerHost
);
fork icon0
star icon0
watch icon1

15
16
17
18
19
20
21
22
23
24
        } });
});
async function generateLinks() {
    pluginFacade_2.coreUtil.logInfo('generateLinks');
    const boxes = pluginFacade.getFileBoxIterator();
    let boxChunk = []; // calling ts.createProgram(..) with many files is magnitude faster than calling many times with one file
    while (await boxes.hasNext()) {
        const box = await boxes.next();
        if (box.getSrcPath().endsWith('.ts')) {
            boxChunk.push(box);
fork icon0
star icon0
watch icon1

+ 7 other calls in file

53
54
55
56
57
58
59
60
61
62
        for (const key in additionalFiles) {
            compilerHost.writeFile(basePath + key, additionalFiles[key], false);
        }
    }
    // Create the TypeScript program.
    const program = ts.createProgram([fileName], compilerOptions, compilerHost);
    return { compilerHost, program };
}
exports.createTypescriptContext = createTypescriptContext;
function transformTypescript(content, transformers, program, compilerHost) {
fork icon0
star icon0
watch icon1

96
97
98
99
100
101
102
103
104
105
    getNewLine: () => '\n',
    fileExists: (fileName) => fileName === tempFilename,
    readFile: (_fileName) => '',
    writeFile: (fileName, text) => outputs.set(fileName, text),
};
const program = ts.createProgram([tempFilename], tsOptions, host);
const diagnostics = program.getSyntacticDiagnostics(tempSourceFile);
if (!validateDiagnostics(diagnostics, strict)) {
    return {
        content: null,
fork icon0
star icon0
watch icon1

Other functions in typescript

Sorted by popularity

function icon

typescript.SyntaxKind is the most popular function in typescript (82777 examples)