Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@angular/tsc-wrapped

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/tsc-wrapped - npm Package Compare versions

Comparing version 4.0.0-beta.4 to 4.0.0-beta.5

src/vinyl_file.d.ts

2

package.json
{
"name": "@angular/tsc-wrapped",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"description": "Wraps the tsc CLI, allowing extensions.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/angular/angular/tree/master/tools/tsc-wrapped",

import * as ts from 'typescript';
import NgOptions from './options';
import { CliOptions } from './cli_options';
import { VinylFile } from './vinyl_file';
export { UserError } from './tsc';
export declare type CodegenExtension = (ngOptions: NgOptions, cliOptions: CliOptions, program: ts.Program, host: ts.CompilerHost) => Promise<void>;
export declare function main(project: string, cliOptions: CliOptions, codegen?: CodegenExtension, options?: ts.CompilerOptions): Promise<any>;
export declare function main(project: string | VinylFile, cliOptions: CliOptions, codegen?: CodegenExtension, options?: ts.CompilerOptions): Promise<any>;

@@ -15,2 +15,3 @@ /**

var cli_options_1 = require('./cli_options');
var vinyl_file_1 = require('./vinyl_file');
var tsc_2 = require('./tsc');

@@ -21,3 +22,7 @@ exports.UserError = tsc_2.UserError;

var projectDir = project;
if (fs.lstatSync(project).isFile()) {
// project is vinyl like file object
if (vinyl_file_1.isVinylFile(project)) {
projectDir = path.dirname(project.path);
}
else if (fs.lstatSync(project).isFile()) {
projectDir = path.dirname(project);

@@ -24,0 +29,0 @@ }

import * as ts from 'typescript';
import AngularCompilerOptions from './options';
import { VinylFile } from './vinyl_file';
/**

@@ -9,3 +10,3 @@ * Our interface to the TypeScript standard compiler.

export interface CompilerInterface {
readConfiguration(project: string, basePath: string, existingOptions?: ts.CompilerOptions): {
readConfiguration(project: string | VinylFile, basePath: string, existingOptions?: ts.CompilerOptions): {
parsed: ts.ParsedCommandLine;

@@ -35,3 +36,3 @@ ngOptions: AngularCompilerOptions;

constructor(readFile?: (path: string, encoding?: string) => string, readDirectory?: (path: string, extensions?: string[], exclude?: string[], include?: string[]) => string[]);
readConfiguration(project: string, basePath: string, existingOptions?: ts.CompilerOptions): {
readConfiguration(project: string | VinylFile, basePath: string, existingOptions?: ts.CompilerOptions): {
parsed: ts.ParsedCommandLine;

@@ -38,0 +39,0 @@ ngOptions: AngularCompilerOptions;

@@ -17,2 +17,3 @@ /**

var ts = require('typescript');
var vinyl_file_1 = require('./vinyl_file');
var UserError = (function (_super) {

@@ -105,2 +106,3 @@ __extends(UserError, _super);

Tsc.prototype.readConfiguration = function (project, basePath, existingOptions) {
var _this = this;
this.basePath = basePath;

@@ -110,3 +112,3 @@ // Allow a directory containing tsconfig.json as the project value

try {
if (this.readDirectory(project).length > 0) {
if (!vinyl_file_1.isVinylFile(project) && this.readDirectory(project).length > 0) {
project = path.join(project, 'tsconfig.json');

@@ -117,3 +119,11 @@ }

}
var _a = ts.readConfigFile(project, this.readFile), config = _a.config, error = _a.error;
var _a = (function () {
// project is vinyl like file object
if (vinyl_file_1.isVinylFile(project)) {
return { config: JSON.parse(project.contents.toString()), error: null };
}
else {
return ts.readConfigFile(project, _this.readFile);
}
})(), config = _a.config, error = _a.error;
check([error]);

@@ -120,0 +130,0 @@ // Do not inline `host` into `parseJsonConfigFileContent` until after

@@ -57,2 +57,29 @@ /**

});
it('should pre-process sources using config from vinyl like object', function (done) {
var config = {
path: basePath + '/tsconfig.json',
contents: new Buffer(JSON.stringify({
compilerOptions: {
experimentalDecorators: true,
types: [],
outDir: 'built',
declaration: true,
moduleResolution: 'node',
target: 'es2015'
},
angularCompilerOptions: { annotateForClosureCompiler: true },
files: ['test.ts']
}))
};
main_1.main(config, { basePath: basePath })
.then(function () {
var out = readOut('js');
// Expand `export *` and fix index import
expect(out).toContain("export { A, B } from './dep/index'");
// Annotated for Closure compiler
expect(out).toContain('* @param {?} x');
done();
})
.catch(function (e) { return done.fail(e); });
});
it('should allow all options disabled', function (done) {

@@ -59,0 +86,0 @@ write('tsconfig.json', "{\n \"compilerOptions\": {\n \"experimentalDecorators\": true,\n \"types\": [],\n \"outDir\": \"built\",\n \"declaration\": false,\n \"module\": \"es2015\",\n \"moduleResolution\": \"node\"\n },\n \"angularCompilerOptions\": {\n \"annotateForClosureCompiler\": false,\n \"annotationsAs\": \"decorators\",\n \"skipMetadataEmit\": true,\n \"skipTemplateCodegen\": true\n },\n \"files\": [\"test.ts\"]\n }");

@@ -12,3 +12,5 @@ /**

describe('options parsing', function () {
var tsc = new tsc_1.Tsc(function () { return "\n{\n \"angularCompilerOptions\": {\n \"googleClosureOutput\": true\n },\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"outDir\": \"built\"\n }\n}"; }, function () { return ['tsconfig.json']; });
var configData = "\n{\n \"angularCompilerOptions\": {\n \"googleClosureOutput\": true\n },\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"outDir\": \"built\"\n }\n}";
var tsc = new tsc_1.Tsc(function () { return configData; }, function () { return ['tsconfig.json']; });
var config = { path: 'basePath/tsconfig.json', contents: new Buffer(configData) };
it('should combine all options into ngOptions', function () {

@@ -25,3 +27,13 @@ var _a = tsc.readConfiguration('projectDir', 'basePath', { target: ts.ScriptTarget.ES2015 }), parsed = _a.parsed, ngOptions = _a.ngOptions;

});
it('should combine all options into ngOptions from vinyl like object', function () {
var _a = tsc_1.tsc.readConfiguration(config, 'basePath'), parsed = _a.parsed, ngOptions = _a.ngOptions;
expect(ngOptions).toEqual({
genDir: 'basePath',
googleClosureOutput: true,
module: ts.ModuleKind.CommonJS,
outDir: 'basePath/built',
configFilePath: undefined
});
});
});
//# sourceMappingURL=tsc.spec.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc