build(broccoli): make node_trees produce strict-mode scripts
Closes #2575 Closes #2648
This commit is contained in:
parent
2d2ae9b8d8
commit
ed9d9d5096
|
@ -127,27 +127,27 @@ export function makeParamDecorator(annotationCls): any {
|
||||||
if (this instanceof annotationCls) {
|
if (this instanceof annotationCls) {
|
||||||
return annotationInstance;
|
return annotationInstance;
|
||||||
} else {
|
} else {
|
||||||
function ParamDecorator(cls, unusedKey, index) {
|
|
||||||
var parameters: Array<Array<any>> = Reflect.getMetadata('parameters', cls);
|
|
||||||
parameters = parameters || [];
|
|
||||||
|
|
||||||
// there might be gaps if some in between parameters do not have annotations.
|
|
||||||
// we pad with nulls.
|
|
||||||
while (parameters.length <= index) {
|
|
||||||
parameters.push(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
parameters[index] = parameters[index] || [];
|
|
||||||
var annotationsForParam: Array<any> = parameters[index];
|
|
||||||
annotationsForParam.push(annotationInstance);
|
|
||||||
|
|
||||||
Reflect.defineMetadata('parameters', parameters, cls);
|
|
||||||
return cls;
|
|
||||||
}
|
|
||||||
|
|
||||||
(<any>ParamDecorator).annotation = annotationInstance;
|
(<any>ParamDecorator).annotation = annotationInstance;
|
||||||
return ParamDecorator;
|
return ParamDecorator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ParamDecorator(cls, unusedKey, index) {
|
||||||
|
var parameters: Array<Array<any>> = Reflect.getMetadata('parameters', cls);
|
||||||
|
parameters = parameters || [];
|
||||||
|
|
||||||
|
// there might be gaps if some in between parameters do not have annotations.
|
||||||
|
// we pad with nulls.
|
||||||
|
while (parameters.length <= index) {
|
||||||
|
parameters.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters[index] = parameters[index] || [];
|
||||||
|
var annotationsForParam: Array<any> = parameters[index];
|
||||||
|
annotationsForParam.push(annotationInstance);
|
||||||
|
|
||||||
|
Reflect.defineMetadata('parameters', parameters, cls);
|
||||||
|
return cls;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ParamDecoratorFactory.prototype = Object.create(annotationCls.prototype);
|
ParamDecoratorFactory.prototype = Object.create(annotationCls.prototype);
|
||||||
return ParamDecoratorFactory;
|
return ParamDecoratorFactory;
|
||||||
|
|
|
@ -1209,22 +1209,21 @@ export function main() {
|
||||||
// - https://github.com/angular/angular/issues/776
|
// - https://github.com/angular/angular/issues/776
|
||||||
// - https://github.com/angular/angular/commit/81f3f32
|
// - https://github.com/angular/angular/commit/81f3f32
|
||||||
xdescribe('Missing directive checks', () => {
|
xdescribe('Missing directive checks', () => {
|
||||||
|
function expectCompileError(tb, inlineTpl, errMessage, done) {
|
||||||
|
tb.overrideView(MyComp, new viewAnn.View({template: inlineTpl}));
|
||||||
|
PromiseWrapper.then(
|
||||||
|
tb.createView(MyComp),
|
||||||
|
(value) => {
|
||||||
|
throw new BaseException(
|
||||||
|
"Test failure: should not have come here as an exception was expected");
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
expect(err.message).toEqual(errMessage);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (assertionsEnabled()) {
|
if (assertionsEnabled()) {
|
||||||
function expectCompileError(tb, inlineTpl, errMessage, done) {
|
|
||||||
tb.overrideView(MyComp, new viewAnn.View({template: inlineTpl}));
|
|
||||||
PromiseWrapper.then(
|
|
||||||
tb.createView(MyComp),
|
|
||||||
(value) => {
|
|
||||||
throw new BaseException(
|
|
||||||
"Test failure: should not have come here as an exception was expected");
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
expect(err.message).toEqual(errMessage);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
it('should raise an error if no directive is registered for a template with template bindings',
|
it('should raise an error if no directive is registered for a template with template bindings',
|
||||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||||
expectCompileError(tb, '<div><div template="if: foo"></div></div>',
|
expectCompileError(tb, '<div><div template="if: foo"></div></div>',
|
||||||
|
|
|
@ -127,5 +127,12 @@ module.exports = function makeNodeTree(destinationPath) {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Prepend 'use strict' directive to all JS files.
|
||||||
|
// See https://github.com/Microsoft/TypeScript/issues/3576
|
||||||
|
nodeTree = replace(nodeTree, {
|
||||||
|
files: ['**/*.js'],
|
||||||
|
patterns: [{match: /^/, replacement: function() { return `'use strict';` }}]
|
||||||
|
});
|
||||||
|
|
||||||
return destCopy(nodeTree, destinationPath);
|
return destCopy(nodeTree, destinationPath);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue