Skip to content

Fixes helpers in strict mode #2989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ scripts/*.js.map
coverage/
internal/
**/.DS_Store
.settings/
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ scripts
src
tests
Jakefile
.travis.yml
.travis.yml
.settings/
8 changes: 4 additions & 4 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module ts {
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult {
// emit output for the __extends helper function
const extendsHelper = `
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand All @@ -27,7 +27,7 @@ var __extends = this.__extends || function (d, b) {

// emit output for the __decorate helper function
const decorateHelper = `
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
Expand All @@ -38,13 +38,13 @@ if (typeof __decorate !== "function") __decorate = function (decorators, target,

// emit output for the __metadata helper function
const metadataHelper = `
if (typeof __metadata !== "function") __metadata = function (k, v) {
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};`;

// emit output for the __param helper function
const paramHelper = `
if (typeof __param !== "function") __param = function (paramIndex, decorator) {
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module A {


//// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module A {


//// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ColoredPoint extends Point {


//// [accessOverriddenBaseClassMember1.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LanguageSpec_section_4_5_inference {
}

//// [accessors_spec_section-4.5_inference.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInAccessorsOfClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsage1_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInArray_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInFunctionExpression_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInGenericFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInGenericFunction_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInIndexerOfClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInIndexerOfClass_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInObjectLiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInObjectLiteral_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInOrExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInOrExpression_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand All @@ -48,7 +48,7 @@ var VisualizationModel = (function (_super) {
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInTypeArgumentOfExtendsClause_main.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasUsageInVarAssignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var Model = (function () {
})();
exports.Model = Model;
//// [aliasUsageInVarAssignment_moduleA.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/ambiguousOverloadResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var x: B;
var t: number = f(x, x); // Not an error

//// [ambiguousOverloadResolution.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/apparentTypeSubtyping.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Derived2<U extends String> extends Base2 { // error because of the prototy
//// [apparentTypeSubtyping.js]
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/apparentTypeSupertype.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Derived<U extends String> extends Base { // error
//// [apparentTypeSupertype.js]
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayAssignmentTest1.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ arr_any = c3; // should be an error - is
arr_any = i1; // should be an error - is

//// [arrayAssignmentTest1.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayAssignmentTest2.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ arr_any = i1; // should be an error - is


//// [arrayAssignmentTest2.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayBestCommonTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module NonEmptyTypes {


//// [arrayBestCommonTypes.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiteralTypeInference.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var z3: { id: number }[] =


//// [arrayLiteralTypeInference.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiterals.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var context4: Base[] = [new Derived1(), new Derived1()];

//// [arrayLiterals.js]
// Empty array literal with no contextual type has type Undefined[]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var myDerivedList: DerivedList<number>;
var as = [list, myDerivedList]; // List<number>[]

//// [arrayLiteralsWithRecursiveGenerics.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrowFunctionContexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var asserted2: any;


//// [arrowFunctionContexts.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ b18 = a18; // ok

//// [assignmentCompatWithCallSignatures3.js]
// these are all permitted with the current rules, since we do not do contextual signature instantiation
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Errors {

//// [assignmentCompatWithCallSignatures4.js]
// These are mostly permitted with the current loose rules. All ok unless otherwise noted.
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ b18 = a18; // ok

//// [assignmentCompatWithCallSignatures5.js]
// checking assignment compat for function types. No errors in this file
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ b16 = x.a16;

//// [assignmentCompatWithCallSignatures6.js]
// checking assignment compatibility relations for function types. All valid
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ b18 = a18; // ok

//// [assignmentCompatWithConstructSignatures3.js]
// checking assignment compatibility relations for function types. All of these are valid.
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Errors {

//// [assignmentCompatWithConstructSignatures4.js]
// checking assignment compatibility relations for function types.
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ b18 = a18; // ok

//// [assignmentCompatWithConstructSignatures5.js]
// checking assignment compat for function types. All valid
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ b16 = x.a16;

//// [assignmentCompatWithConstructSignatures6.js]
// checking assignment compatibility relations for function types. All valid.
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module Generics {

//// [assignmentCompatWithNumericIndexer.js]
// Derived type indexer must be subtype of base type indexer
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Generics {

//// [assignmentCompatWithNumericIndexer3.js]
// Derived type indexer must be subtype of base type indexer
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module WithBase {

//// [assignmentCompatWithObjectMembers4.js]
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module SourceHasOptional {

//// [assignmentCompatWithObjectMembersOptionality.js]
// Derived member is not optional but base member is, should be ok
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module SourceHasOptional {
//// [assignmentCompatWithObjectMembersOptionality2.js]
// M is optional and S contains no property with the same name as M
// N is optional and T contains no property with the same name as N
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module Generics {

//// [assignmentCompatWithStringIndexer.js]
// index signatures must be compatible in assignments
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/assignmentLHSIsValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ foo() = value;
(foo()) = value;

//// [assignmentLHSIsValue.js]
var __extends = this.__extends || function (d, b) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
Expand Down
Loading