Skip to content

Commit 4054eca

Browse files
Merge branch 'master' into jsSigHelp
Conflicts: tests/baselines/reference/APISample_compile.js tests/baselines/reference/APISample_compile.types tests/baselines/reference/APISample_linter.js tests/baselines/reference/APISample_linter.types tests/baselines/reference/APISample_linter.types.pull tests/baselines/reference/APISample_transform.js tests/baselines/reference/APISample_transform.types tests/baselines/reference/APISample_watcher.js tests/baselines/reference/APISample_watcher.types
2 parents 78a7914 + 68b38b3 commit 4054eca

121 files changed

Lines changed: 3091 additions & 41727 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/checker.ts

Lines changed: 310 additions & 18 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ module ts {
156156
shortName: "w",
157157
type: "boolean",
158158
description: Diagnostics.Watch_input_files,
159+
},
160+
{
161+
name: "emitDecoratorMetadata",
162+
type: "boolean",
163+
experimental: true
159164
}
160165
];
161166

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ module ts {
167167
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
168168
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
169169
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
170-
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1210, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
170+
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
171+
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
171172
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
172173
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
173174
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

src/compiler/diagnosticMessages.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,13 @@
659659
"category": "Error",
660660
"code": 1209
661661
},
662+
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
663+
"category": "Error",
664+
"code": 1210
665+
},
662666
"A class declaration without the 'default' modifier must have a name": {
663667
"category": "Error",
664-
"code": 1210
668+
"code": 1211
665669
},
666670
"Duplicate identifier '{0}'.": {
667671
"category": "Error",

src/compiler/emitter.ts

Lines changed: 272 additions & 142 deletions
Large diffs are not rendered by default.

src/compiler/parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,9 +4756,7 @@ module ts {
47564756
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration {
47574757
// In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code
47584758
let savedStrictModeContext = inStrictModeContext();
4759-
if (languageVersion >= ScriptTarget.ES6) {
4760-
setStrictModeContext(true);
4761-
}
4759+
setStrictModeContext(true);
47624760

47634761
var node = <ClassLikeDeclaration>createNode(kind, fullStart);
47644762
node.decorators = decorators;

src/compiler/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ module ts {
12551255
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
12561256
resolvesToSomeValue(location: Node, name: string): boolean;
12571257
getBlockScopedVariableId(node: Identifier): number;
1258+
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
1259+
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
1260+
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
12581261
}
12591262

12601263
export const enum SymbolFlags {
@@ -1380,6 +1383,7 @@ module ts {
13801383
EnumValuesComputed = 0x00000080,
13811384
BlockScopedBindingInLoop = 0x00000100,
13821385
EmitDecorate = 0x00000200, // Emit __decorate
1386+
EmitParam = 0x00000400, // Emit __param helper for decorators
13831387
}
13841388

13851389
export interface NodeLinks {
@@ -1605,6 +1609,7 @@ module ts {
16051609
version?: boolean;
16061610
watch?: boolean;
16071611
separateCompilation?: boolean;
1612+
emitDecoratorMetadata?: boolean;
16081613
/* @internal */ stripInternal?: boolean;
16091614
[option: string]: string | number | boolean;
16101615
}

src/compiler/utilities.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,18 @@ module ts {
449449
return false;
450450
}
451451

452+
export function isAccessor(node: Node): boolean {
453+
if (node) {
454+
switch (node.kind) {
455+
case SyntaxKind.GetAccessor:
456+
case SyntaxKind.SetAccessor:
457+
return true;
458+
}
459+
}
460+
461+
return false;
462+
}
463+
452464
export function isFunctionLike(node: Node): boolean {
453465
if (node) {
454466
switch (node.kind) {
@@ -514,6 +526,19 @@ module ts {
514526
// the *body* of the container.
515527
node = node.parent;
516528
break;
529+
case SyntaxKind.Decorator:
530+
// Decorators are always applied outside of the body of a class or method.
531+
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
532+
// If the decorator's parent is a Parameter, we resolve the this container from
533+
// the grandparent class declaration.
534+
node = node.parent.parent;
535+
}
536+
else if (isClassElement(node.parent)) {
537+
// If the decorator's parent is a class element, we resolve the 'this' container
538+
// from the parent class declaration.
539+
node = node.parent;
540+
}
541+
break;
517542
case SyntaxKind.ArrowFunction:
518543
if (!includeArrowFunctions) {
519544
continue;
@@ -556,6 +581,19 @@ module ts {
556581
// the *body* of the container.
557582
node = node.parent;
558583
break;
584+
case SyntaxKind.Decorator:
585+
// Decorators are always applied outside of the body of a class or method.
586+
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
587+
// If the decorator's parent is a Parameter, we resolve the this container from
588+
// the grandparent class declaration.
589+
node = node.parent.parent;
590+
}
591+
else if (isClassElement(node.parent)) {
592+
// If the decorator's parent is a class element, we resolve the 'this' container
593+
// from the parent class declaration.
594+
node = node.parent;
595+
}
596+
break;
559597
case SyntaxKind.FunctionDeclaration:
560598
case SyntaxKind.FunctionExpression:
561599
case SyntaxKind.ArrowFunction:
@@ -907,6 +945,7 @@ module ts {
907945
case SyntaxKind.MethodDeclaration:
908946
case SyntaxKind.GetAccessor:
909947
case SyntaxKind.SetAccessor:
948+
case SyntaxKind.MethodSignature:
910949
case SyntaxKind.IndexSignature:
911950
return true;
912951
default:

src/harness/harness.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ module Harness {
781781

782782
public reset() { this.fileCollection = {}; }
783783

784-
public toArray(): { fileName: string; file: WriterAggregator; }[] {
784+
public toArray(): { fileName: string; file: WriterAggregator; }[]{
785785
var result: { fileName: string; file: WriterAggregator; }[] = [];
786786
for (var p in this.fileCollection) {
787787
if (this.fileCollection.hasOwnProperty(p)) {
@@ -944,6 +944,10 @@ module Harness {
944944

945945
var newLine = '\r\n';
946946

947+
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
948+
// Treat them as library files, so include them in build, but not in baselines.
949+
var includeBuiltFiles: { unitName: string; content: string }[] = [];
950+
947951
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
948952
this.settings.forEach(setting => {
949953
switch (setting.flag.toLowerCase()) {
@@ -1061,18 +1065,19 @@ module Harness {
10611065
break;
10621066

10631067
case 'includebuiltfile':
1064-
inputFiles.push({ unitName: setting.value, content: normalizeLineEndings(IO.readFile(libFolder + setting.value), newLine) });
1068+
let builtFileName = libFolder + setting.value;
1069+
includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) });
10651070
break;
10661071

10671072
default:
10681073
throw new Error('Unsupported compiler setting ' + setting.flag);
10691074
}
10701075
});
1071-
1076+
10721077
var fileOutputs: GeneratedFile[] = [];
10731078

1074-
var programFiles = inputFiles.map(file => file.unitName);
1075-
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(otherFiles),
1079+
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
1080+
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles),
10761081
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
10771082
options.target, useCaseSensitiveFileNames, currentDirectory));
10781083

@@ -1295,7 +1300,7 @@ module Harness {
12951300
});
12961301

12971302
var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
1298-
return diagnostic.fileName && isLibraryFile(diagnostic.fileName);
1303+
return diagnostic.fileName && (isLibraryFile(diagnostic.fileName) || isBuiltFile(diagnostic.fileName));
12991304
});
13001305

13011306
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
@@ -1698,6 +1703,10 @@ module Harness {
16981703
return (Path.getFileName(filePath) === 'lib.d.ts') || (Path.getFileName(filePath) === 'lib.core.d.ts');
16991704
}
17001705

1706+
export function isBuiltFile(filePath: string): boolean {
1707+
return filePath.indexOf(Harness.libFolder) === 0;
1708+
}
1709+
17011710
export function getDefaultLibraryFile(): { unitName: string, content: string } {
17021711
var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts";
17031712
return {

src/lib/core.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,4 +1168,4 @@ interface TypedPropertyDescriptor<T> {
11681168
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
11691169
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
11701170
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
1171-
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
1171+
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;

0 commit comments

Comments
 (0)