Merge pull request #4510 from Microsoft/mergeMasterInRelease1.6

Merge master in release1.6
This commit is contained in:
Mohamed Hegazy 2015-08-27 16:43:57 -07:00
Родитель b83b4a8d5a 0369ecd213
Коммит 637b378783
21 изменённых файлов: 304 добавлений и 4 удалений

Просмотреть файл

@ -3119,7 +3119,7 @@ namespace ts {
}
function resolveTupleTypeMembers(type: TupleType) {
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noDeduplication*/ true)));
let members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@ -7161,7 +7161,7 @@ namespace ts {
let propertiesTable: SymbolTable = {};
let propertiesArray: Symbol[] = [];
let contextualType = getContextualType(node);
let typeFlags: TypeFlags;
let typeFlags: TypeFlags = 0;
for (let memberDecl of node.properties) {
let member = memberDecl.symbol;
@ -7210,7 +7210,8 @@ namespace ts {
let stringIndexType = getIndexType(IndexKind.String);
let numberIndexType = getIndexType(IndexKind.Number);
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags);
let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral;
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
return result;
function getIndexType(kind: IndexKind) {
@ -12613,6 +12614,7 @@ namespace ts {
if (baseTypes.length && produceDiagnostics) {
let baseType = baseTypes[0];
let staticBaseType = getBaseConstructorTypeOfClass(type);
checkSourceElement(baseTypeNode.expression);
if (baseTypeNode.typeArguments) {
forEach(baseTypeNode.typeArguments, checkSourceElement);
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
@ -13682,6 +13684,8 @@ namespace ts {
case SyntaxKind.VariableDeclaration:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.HeritageClause:
case SyntaxKind.ExpressionWithTypeArguments:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.EnumMember:
case SyntaxKind.ExportAssignment:

Просмотреть файл

@ -184,6 +184,12 @@ namespace ts {
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
paramType: Diagnostics.LOCATION,
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
description: Diagnostics.Suppress_excess_property_checks_for_object_literals,
experimental: true
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",

Просмотреть файл

@ -569,6 +569,7 @@ namespace ts {
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },

Просмотреть файл

@ -2266,6 +2266,10 @@
"category": "Message",
"code": 6071
},
"Suppress excess property checks for object literals.": {
"category": "Message",
"code": 6072
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",

Просмотреть файл

@ -2048,6 +2048,7 @@ namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;

Просмотреть файл

@ -1203,6 +1203,10 @@ module Harness {
options.isolatedModules = setting.value === "true";
break;
case "suppressexcesspropertyerrors":
options.suppressExcessPropertyErrors = setting.value === "true";
break;
case "suppressimplicitanyindexerrors":
options.suppressImplicitAnyIndexErrors = setting.value === "true";
break;
@ -1567,7 +1571,7 @@ module Harness {
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"includebuiltfile", "suppressexcesspropertyerrors", "suppressimplicitanyindexerrors", "stripinternal",
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata", "experimentaldecorators",
"skipdefaultlibcheck", "jsx"];

Просмотреть файл

@ -0,0 +1,7 @@
//// [excessPropertyErrorsSuppressed.ts]
var x: { a: string } = { a: "hello", b: 42 }; // No error
//// [excessPropertyErrorsSuppressed.js]
var x = { a: "hello", b: 42 }; // No error

Просмотреть файл

@ -0,0 +1,8 @@
=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts ===
var x: { a: string } = { a: "hello", b: 42 }; // No error
>x : Symbol(x, Decl(excessPropertyErrorsSuppressed.ts, 1, 3))
>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 8))
>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 24))
>b : Symbol(b, Decl(excessPropertyErrorsSuppressed.ts, 1, 36))

Просмотреть файл

@ -0,0 +1,11 @@
=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts ===
var x: { a: string } = { a: "hello", b: 42 }; // No error
>x : { a: string; }
>a : string
>{ a: "hello", b: 42 } : { a: string; b: number; }
>a : string
>"hello" : string
>b : number
>42 : number

Просмотреть файл

@ -0,0 +1,12 @@
tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ====
class George extends class { reset() { return this.y; } } {
~
!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'.
constructor() {
super();
}
}

Просмотреть файл

@ -0,0 +1,26 @@
//// [missingPropertiesOfClassExpression.ts]
class George extends class { reset() { return this.y; } } {
constructor() {
super();
}
}
//// [missingPropertiesOfClassExpression.js]
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; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var George = (function (_super) {
__extends(George, _super);
function George() {
_super.call(this);
}
return George;
})((function () {
function class_1() {
}
class_1.prototype.reset = function () { return this.y; };
return class_1;
})());

Просмотреть файл

@ -0,0 +1,20 @@
//// [recursiveTupleTypes1.ts]
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree1];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
//// [recursiveTupleTypes1.js]
var tree1;
var tree2;
tree1 = tree2;
tree2 = tree1;

Просмотреть файл

@ -0,0 +1,35 @@
=== tests/cases/compiler/recursiveTupleTypes1.ts ===
interface Tree1 {
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
children: [Tree1, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 0, 17))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
}
interface Tree2 {
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
children: [Tree2, Tree1];
>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 4, 17))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
}
let tree1: Tree1;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0))
let tree2: Tree2;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1))
tree1 = tree2;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
tree2 = tree1;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3))
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3))

Просмотреть файл

@ -0,0 +1,37 @@
=== tests/cases/compiler/recursiveTupleTypes1.ts ===
interface Tree1 {
>Tree1 : Tree1
children: [Tree1, Tree2];
>children : [Tree1, Tree2]
>Tree1 : Tree1
>Tree2 : Tree2
}
interface Tree2 {
>Tree2 : Tree2
children: [Tree2, Tree1];
>children : [Tree2, Tree1]
>Tree2 : Tree2
>Tree1 : Tree1
}
let tree1: Tree1;
>tree1 : Tree1
>Tree1 : Tree1
let tree2: Tree2;
>tree2 : Tree2
>Tree2 : Tree2
tree1 = tree2;
>tree1 = tree2 : Tree2
>tree1 : Tree1
>tree2 : Tree2
tree2 = tree1;
>tree2 = tree1 : Tree1
>tree2 : Tree2
>tree1 : Tree1

Просмотреть файл

@ -0,0 +1,20 @@
//// [recursiveTupleTypes2.ts]
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree2];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;
//// [recursiveTupleTypes2.js]
var tree1;
var tree2;
tree1 = tree2;
tree2 = tree1;

Просмотреть файл

@ -0,0 +1,35 @@
=== tests/cases/compiler/recursiveTupleTypes2.ts ===
interface Tree1 {
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
children: [Tree1, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 0, 17))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
}
interface Tree2 {
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
children: [Tree2, Tree2];
>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 4, 17))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
}
let tree1: Tree1;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))
>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0))
let tree2: Tree2;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1))
tree1 = tree2;
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
tree2 = tree1;
>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3))
>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3))

Просмотреть файл

@ -0,0 +1,37 @@
=== tests/cases/compiler/recursiveTupleTypes2.ts ===
interface Tree1 {
>Tree1 : Tree1
children: [Tree1, Tree2];
>children : [Tree1, Tree2]
>Tree1 : Tree1
>Tree2 : Tree2
}
interface Tree2 {
>Tree2 : Tree2
children: [Tree2, Tree2];
>children : [Tree2, Tree2]
>Tree2 : Tree2
>Tree2 : Tree2
}
let tree1: Tree1;
>tree1 : Tree1
>Tree1 : Tree1
let tree2: Tree2;
>tree2 : Tree2
>Tree2 : Tree2
tree1 = tree2;
>tree1 = tree2 : Tree2
>tree1 : Tree1
>tree2 : Tree2
tree2 = tree1;
>tree2 = tree1 : Tree1
>tree2 : Tree2
>tree1 : Tree1

Просмотреть файл

@ -0,0 +1,3 @@
//@suppressExcessPropertyErrors: true
var x: { a: string } = { a: "hello", b: 42 }; // No error

Просмотреть файл

@ -0,0 +1,5 @@
class George extends class { reset() { return this.y; } } {
constructor() {
super();
}
}

Просмотреть файл

@ -0,0 +1,12 @@
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree1];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;

Просмотреть файл

@ -0,0 +1,12 @@
interface Tree1 {
children: [Tree1, Tree2];
}
interface Tree2 {
children: [Tree2, Tree2];
}
let tree1: Tree1;
let tree2: Tree2;
tree1 = tree2;
tree2 = tree1;