Despite my lack of expertise in the inner workings of how a TypeScript library compiles itself to JavaScript before being placed in the node_modules
directory, I have a question:
Coming from a PHP background, I am accustomed to being able to explore any library downloaded via Composer in my vendors
folder and examine the actual PHP code the library is comprised of.
In my current Angular 2 project, upon downloading a TypeScript library, I receive what appears to be an abstract class or some form of contract (possibly a class declaration?):
export declare class FormGroup extends AbstractControl {
controls: {
[key: string]: AbstractControl;
};
constructor(controls: {
[key: string]: AbstractControl;
}, validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn);
/**
* Registers a control with the group's list of controls.
*
* This method does not update value or validity of the control, so for
* most cases you'll want to use {@link FormGroup.addControl} instead.
*/
registerControl(name: string, control: AbstractControl): AbstractControl;
/**
* Add a control to this group.
Subsequently, the class compiled into JavaScript looks like this:
export var FormGroup = (function (_super) {
__extends(FormGroup, _super);
/**
* @param {?} controls
* @param {?=} validator
* @param {?=} asyncValidator
*/
function FormGroup(controls, validator, asyncValidator) {
if (validator === void 0) { validator = null; }
if (asyncValidator === void 0) { asyncValidator = null; }
_super.call(this, validator, asyncValidator);
this.controls = controls;
this._initObservables();
this._setUpControls();
this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
Additionally, there is a mapping provided:
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../modules/@angular/forms/src/model.ts"],
I wonder if it's feasible to pass a parameter to npm in order for this library to download solely in TypeScript, allowing webpack to handle the compilation to JavaScript (strictly for development purposes), thus enabling me to directly access the source code as I develop?
Currently, whenever I wish to review the source, I must browse GitHub. Is this the recommended approach?