How to use tsickle - 10 common examples

To help you get started, we’ve selected a few tsickle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github albertnadal / ng2-daterange-picker / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
if (ngOptions_1.flatModuleOutFile && !ngOptions_1.skipMetadataEmit) {
            var _b = createBundleIndexHost(ngOptions_1, rootFileNames_1, host_1), bundleHost = _b.host, indexName = _b.indexName, errors_1 = _b.errors;
            if (errors_1)
                tsc_1.check(errors_1);
            if (indexName)
                addGeneratedFileName_1(indexName);
            host_1 = bundleHost;
        }
        var tsickleCompilerHostOptions = { googmodule: false, untyped: true, convertIndexImportShorthand: false };
        var tsickleHost = {
            shouldSkipTsickleProcessing: function (fileName) { return /\.d\.ts$/.test(fileName); },
            pathToModuleName: function (context, importPath) { return ''; },
            shouldIgnoreWarningsForPath: function (filePath) { return false; },
            fileNameToModuleId: function (fileName) { return fileName; },
        };
        var tsickleCompilerHost_1 = new tsickle.TsickleCompilerHost(host_1, ngOptions_1, tsickleCompilerHostOptions, tsickleHost);
        var program_1 = createProgram_1(tsickleCompilerHost_1);
        var errors = program_1.getOptionsDiagnostics();
        tsc_1.check(errors);
        if (ngOptions_1.skipTemplateCodegen || !codegen) {
            codegen = function () { return Promise.resolve([]); };
        }
        if (diagnostics_1)
            console.time('NG codegen');
        return codegen(ngOptions_1, cliOptions, program_1, host_1).then(function (genFiles) {
            if (diagnostics_1)
                console.timeEnd('NG codegen');
            // Add the generated files to the configuration so they will become part of the program.
            if (ngOptions_1.alwaysCompileGeneratedCode) {
                genFiles.forEach(function (genFileName) { return addGeneratedFileName_1(genFileName); });
            }
            var definitionsHost = tsickleCompilerHost_1;
github VadimDez / ng2-pdf-viewer / build / lib / @angular / tsc-wrapped / src / main.js View on Github external
if (ngOptions_1.flatModuleOutFile && !ngOptions_1.skipMetadataEmit) {
            var _b = createBundleIndexHost(ngOptions_1, rootFileNames_1, host_1), bundleHost = _b.host, indexName = _b.indexName, errors_1 = _b.errors;
            if (errors_1)
                tsc_1.check(errors_1);
            if (indexName)
                addGeneratedFileName_1(indexName);
            host_1 = bundleHost;
        }
        var tsickleCompilerHostOptions = { googmodule: false, untyped: true, convertIndexImportShorthand: true };
        var tsickleHost = {
            shouldSkipTsickleProcessing: function (fileName) { return /\.d\.ts$/.test(fileName); },
            pathToModuleName: function (context, importPath) { return ''; },
            shouldIgnoreWarningsForPath: function (filePath) { return false; },
            fileNameToModuleId: function (fileName) { return fileName; },
        };
        var tsickleCompilerHost_1 = new tsickle.TsickleCompilerHost(host_1, ngOptions_1, tsickleCompilerHostOptions, tsickleHost);
        var program_1 = createProgram_1(tsickleCompilerHost_1);
        var errors = program_1.getOptionsDiagnostics();
        tsc_1.check(errors);
        if (ngOptions_1.skipTemplateCodegen || !codegen) {
            codegen = function () { return Promise.resolve([]); };
        }
        if (diagnostics_1)
            console.time('NG codegen');
        return codegen(ngOptions_1, cliOptions, program_1, host_1).then(function (genFiles) {
            if (diagnostics_1)
                console.timeEnd('NG codegen');
            // Add the generated files to the configuration so they will become part of the program.
            if (ngOptions_1.alwaysCompileGeneratedCode) {
                genFiles.forEach(function (genFileName) { return addGeneratedFileName_1(genFileName); });
            }
            var definitionsHost = tsickleCompilerHost_1;
github bfwg / angular-spring-starter / frontend / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
console.timeEnd('NG flat module index');
            var metadata = JSON.stringify(metadataBundle.metadata);
            var name_1 = path.join(path.dirname(indexModule), ngOptions_1.flatModuleOutFile.replace(JS_EXT, '.ts'));
            var libraryIndex = "./" + path.basename(indexModule);
            var content = index_writer_1.privateEntriesToIndex(libraryIndex, metadataBundle.privates);
            host_1 = new compiler_host_1.SyntheticIndexHost(host_1, { name: name_1, content: content, metadata: metadata });
            addGeneratedFileName_1(name_1);
        }
        var tsickleCompilerHostOptions = { googmodule: false, untyped: true, convertIndexImportShorthand: true };
        var tsickleHost = {
            shouldSkipTsickleProcessing: function (fileName) { return /\.d\.ts$/.test(fileName); },
            pathToModuleName: function (context, importPath) { return ''; },
            shouldIgnoreWarningsForPath: function (filePath) { return false; },
            fileNameToModuleId: function (fileName) { return fileName; },
        };
        var tsickleCompilerHost_1 = new tsickle.TsickleCompilerHost(host_1, ngOptions_1, tsickleCompilerHostOptions, tsickleHost);
        var program_1 = createProgram_1(tsickleCompilerHost_1);
        var errors = program_1.getOptionsDiagnostics();
        tsc_1.check(errors);
        if (ngOptions_1.skipTemplateCodegen || !codegen) {
            codegen = function () { return Promise.resolve([]); };
        }
        if (diagnostics_1)
            console.time('NG codegen');
        return codegen(ngOptions_1, cliOptions, program_1, host_1).then(function (genFiles) {
            if (diagnostics_1)
                console.timeEnd('NG codegen');
            // Add the generated files to the configuration so they will become part of the program.
            if (ngOptions_1.alwaysCompileGeneratedCode) {
                genFiles.forEach(function (genFileName) { return addGeneratedFileName_1(genFileName); });
            }
            var definitionsHost = tsickleCompilerHost_1;
github fossasia / susper.com / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
var content = index_writer_1.privateEntriesToIndex(libraryIndex, metadataBundle.privates);
            host_1 = new compiler_host_1.SyntheticIndexHost(host_1, { name: name_1, content: content, metadata: metadata });
            parsed_1.fileNames.push(name_1);
        }
        var tsickleCompilerHostOptions = {
            googmodule: false,
            untyped: true,
            convertIndexImportShorthand: ngOptions_1.target === ts.ScriptTarget.ES2015,
        };
        var tsickleHost = {
            shouldSkipTsickleProcessing: function (fileName) { return /\.d\.ts$/.test(fileName); },
            pathToModuleName: function (context, importPath) { return ''; },
            shouldIgnoreWarningsForPath: function (filePath) { return false; },
            fileNameToModuleId: function (fileName) { return fileName; },
        };
        var tsickleCompilerHost_1 = new tsickle.TsickleCompilerHost(host_1, ngOptions_1, tsickleCompilerHostOptions, tsickleHost);
        var program_1 = createProgram_1(tsickleCompilerHost_1);
        var errors = program_1.getOptionsDiagnostics();
        tsc_1.check(errors);
        if (ngOptions_1.skipTemplateCodegen || !codegen) {
            codegen = function () { return Promise.resolve(null); };
        }
        if (diagnostics_1)
            console.time('NG codegen');
        return codegen(ngOptions_1, cliOptions, program_1, host_1).then(function () {
            if (diagnostics_1)
                console.timeEnd('NG codegen');
            var definitionsHost = tsickleCompilerHost_1;
            if (!ngOptions_1.skipMetadataEmit) {
                // if tsickle is not not used for emitting, but we do use the MetadataWriterHost,
                // it also needs to emit the js files.
                var emitJsFiles = ngOptions_1.annotationsAs === 'decorators' && !ngOptions_1.annotateForClosureCompiler;
github VadimDez / ng2-pdf-viewer / build / lib / @angular / tsc-wrapped / src / main.js View on Github external
var programForJsEmit = programWithCodegen;
            if (ngOptions_1.annotationsAs !== 'decorators') {
                if (diagnostics_1)
                    console.time('NG downlevel');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL);
                // A program can be re-used only once; save the programWithCodegen to be reused by
                // metadataWriter
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG downlevel');
            }
            if (ngOptions_1.annotateForClosureCompiler) {
                if (diagnostics_1)
                    console.time('NG JSDoc');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE);
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG JSDoc');
            }
            // Emit *.js and *.js.map
            tsc_1.tsc.emit(programForJsEmit);
            // Emit *.d.ts and maybe *.metadata.json
            // Not in the same emit pass with above, because tsickle erases
            // decorators which we want to read or document.
            // Do this emit second since TypeScript will create missing directories for us
            // in the standard emit.
            tsc_1.tsc.emit(programWithCodegen);
            if (diagnostics_1) {
                ts.performance.forEachMeasure(function (name, duration) { console.error("TS " + name + ": " + duration + "ms"); });
            }
github albertnadal / ng2-daterange-picker / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
var programForJsEmit = programWithCodegen;
            if (ngOptions_1.annotationsAs !== 'decorators') {
                if (diagnostics_1)
                    console.time('NG downlevel');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL);
                // A program can be re-used only once; save the programWithCodegen to be reused by
                // metadataWriter
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG downlevel');
            }
            if (ngOptions_1.annotateForClosureCompiler) {
                if (diagnostics_1)
                    console.time('NG JSDoc');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE);
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG JSDoc');
            }
            // Emit *.js and *.js.map
            tsc_1.tsc.emit(programForJsEmit);
            // Emit *.d.ts and maybe *.metadata.json
            // Not in the same emit pass with above, because tsickle erases
            // decorators which we want to read or document.
            // Do this emit second since TypeScript will create missing directories for us
            // in the standard emit.
            tsc_1.tsc.emit(programWithCodegen);
            if (diagnostics_1) {
                ts.performance.forEachMeasure(function (name, duration) { console.error("TS " + name + ": " + duration + "ms"); });
            }
github angular / angular / packages / tsc-wrapped / src / main.ts View on Github external
// Add the generated files to the configuration so they will become part of the program.
      if (ngOptions.alwaysCompileGeneratedCode) {
        genFiles.forEach(genFileName => addGeneratedFileName(genFileName));
      }
      if (!ngOptions.skipMetadataEmit) {
        host = new MetadataWriterHost(host, ngOptions, true);
      }

      // Create a new program since codegen files were created after making the old program
      let programWithCodegen = createProgram(host, program);
      tsc.typeCheck(host, programWithCodegen);

      if (diagnostics) console.time('Emit');
      const {diagnostics: emitDiags} =
          tsickle.emitWithTsickle(programWithCodegen, tsickleHost, host, ngOptions);
      if (diagnostics) console.timeEnd('Emit');
      check(emitDiags);

      if (diagnostics) {
        (ts as any).performance.forEachMeasure(
            (name: string, duration: number) => { console.error(`TS ${name}: ${duration}ms`); });
      }
    });
  } catch (e) {
github angular / tsickle / demo / demo.ts View on Github external
// Run tsickle+TSC to convert inputs to Closure JS files.
  const result = toClosureJS(
      config.options, config.fileNames, settings, (filePath: string, contents: string) => {
        fs.mkdirSync(path.dirname(filePath), {recursive: true});
        fs.writeFileSync(filePath, contents, {encoding: 'utf-8'});
      });
  if (result.diagnostics.length) {
    console.error(ts.formatDiagnostics(result.diagnostics, ts.createCompilerHost(config.options)));
    return 1;
  }

  if (settings.externsPath) {
    fs.mkdirSync(path.dirname(settings.externsPath), {recursive: true});
    fs.writeFileSync(
        settings.externsPath,
        tsickle.getGeneratedExterns(result.externs, config.options.rootDir || ''));
  }
  return 0;
}
github fossasia / susper.com / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
console.timeEnd('NG codegen');
            var definitionsHost = tsickleCompilerHost_1;
            if (!ngOptions_1.skipMetadataEmit) {
                // if tsickle is not not used for emitting, but we do use the MetadataWriterHost,
                // it also needs to emit the js files.
                var emitJsFiles = ngOptions_1.annotationsAs === 'decorators' && !ngOptions_1.annotateForClosureCompiler;
                definitionsHost = new compiler_host_1.MetadataWriterHost(tsickleCompilerHost_1, ngOptions_1, emitJsFiles);
            }
            // Create a new program since codegen files were created after making the old program
            var programWithCodegen = createProgram_1(definitionsHost, program_1);
            tsc_1.tsc.typeCheck(host_1, programWithCodegen);
            var programForJsEmit = programWithCodegen;
            if (ngOptions_1.annotationsAs !== 'decorators') {
                if (diagnostics_1)
                    console.time('NG downlevel');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL);
                // A program can be re-used only once; save the programWithCodegen to be reused by
                // metadataWriter
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG downlevel');
            }
            if (ngOptions_1.annotateForClosureCompiler) {
                if (diagnostics_1)
                    console.time('NG JSDoc');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE);
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG JSDoc');
            }
github bfwg / angular-spring-starter / frontend / node_modules / @angular / tsc-wrapped / src / main.js View on Github external
}
            var definitionsHost = tsickleCompilerHost_1;
            if (!ngOptions_1.skipMetadataEmit) {
                // if tsickle is not not used for emitting, but we do use the MetadataWriterHost,
                // it also needs to emit the js files.
                var emitJsFiles = ngOptions_1.annotationsAs === 'decorators' && !ngOptions_1.annotateForClosureCompiler;
                definitionsHost = new compiler_host_1.MetadataWriterHost(tsickleCompilerHost_1, ngOptions_1, emitJsFiles);
            }
            // Create a new program since codegen files were created after making the old program
            var programWithCodegen = createProgram_1(definitionsHost, program_1);
            tsc_1.tsc.typeCheck(host_1, programWithCodegen);
            var programForJsEmit = programWithCodegen;
            if (ngOptions_1.annotationsAs !== 'decorators') {
                if (diagnostics_1)
                    console.time('NG downlevel');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL);
                // A program can be re-used only once; save the programWithCodegen to be reused by
                // metadataWriter
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG downlevel');
            }
            if (ngOptions_1.annotateForClosureCompiler) {
                if (diagnostics_1)
                    console.time('NG JSDoc');
                tsickleCompilerHost_1.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE);
                programForJsEmit = createProgram_1(tsickleCompilerHost_1);
                tsc_1.check(tsickleCompilerHost_1.diagnostics);
                if (diagnostics_1)
                    console.timeEnd('NG JSDoc');
            }