Merge branch 'master' into abstractConstructorAssignability

This commit is contained in:
Arthur Ozga
2015-07-06 09:40:20 -07:00
13 changed files with 180 additions and 78 deletions
+66 -66
View File
@@ -4,84 +4,84 @@ let async = require('async');
let glob = require('glob');
fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => {
if (err) {
throw err;
}
let messages = JSON.parse(data);
let keys = Object.keys(messages);
console.log('Loaded ' + keys.length + ' errors');
if (err) {
throw err;
}
for (let k of keys) {
messages[k]['seen'] = false;
}
let messages = JSON.parse(data);
let keys = Object.keys(messages);
console.log('Loaded ' + keys.length + ' errors');
let errRegex = /\(\d+,\d+\): error TS([^:]+):/g;
for (let k of keys) {
messages[k]['seen'] = false;
}
let baseDir = 'tests/baselines/reference/';
fs.readdir(baseDir, (err, files) => {
files = files.filter(f => f.indexOf('.errors.txt') > 0);
let tasks: Array<(callback: () => void) => void> = [];
files.forEach(f => tasks.push(done => {
fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
if (err) throw err;
let errRegex = /\(\d+,\d+\): error TS([^:]+):/g;
let g: string[];
while (g = errRegex.exec(baseline)) {
var errCode = +g[1];
let msg = keys.filter(k => messages[k].code === errCode)[0];
messages[msg]['seen'] = true;
}
let baseDir = 'tests/baselines/reference/';
fs.readdir(baseDir, (err, files) => {
files = files.filter(f => f.indexOf('.errors.txt') > 0);
let tasks: Array<(callback: () => void) => void> = [];
files.forEach(f => tasks.push(done => {
fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
if (err) throw err;
done();
});
}));
let g: string[];
while (g = errRegex.exec(baseline)) {
var errCode = +g[1];
let msg = keys.filter(k => messages[k].code === errCode)[0];
messages[msg]['seen'] = true;
}
async.parallelLimit(tasks, 25, done => {
console.log('== List of errors not present in baselines ==');
let count = 0;
for (let k of keys) {
if (messages[k]['seen'] !== true) {
console.log(k);
count++;
}
}
console.log(count + ' of ' + keys.length + ' errors are not in baselines');
});
});
done();
});
}));
async.parallelLimit(tasks, 25, done => {
console.log('== List of errors not present in baselines ==');
let count = 0;
for (let k of keys) {
if (messages[k]['seen'] !== true) {
console.log(k);
count++;
}
}
console.log(count + ' of ' + keys.length + ' errors are not in baselines');
});
});
});
fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => {
let errorRegexp = /\s(\w+): \{ code/g;
let errorNames: string[] = [];
let errMatch: string[];
while (errMatch = errorRegexp.exec(data)) {
errorNames.push(errMatch[1]);
}
let errorRegexp = /\s(\w+): \{ code/g;
let errorNames: string[] = [];
let errMatch: string[];
while (errMatch = errorRegexp.exec(data)) {
errorNames.push(errMatch[1]);
}
let allSrc: string = '';
glob('./src/**/*.ts', {}, (err, files) => {
console.log('Reading ' + files.length + ' source files');
for(let file of files) {
if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) {
continue;
}
let allSrc: string = '';
glob('./src/**/*.ts', {}, (err, files) => {
console.log('Reading ' + files.length + ' source files');
for (let file of files) {
if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) {
continue;
}
let src = fs.readFileSync(file, 'utf-8');
allSrc = allSrc + src;
}
let src = fs.readFileSync(file, 'utf-8');
allSrc = allSrc + src;
}
console.log('Consumed ' + allSrc.length + ' characters of source');
console.log('Consumed ' + allSrc.length + ' characters of source');
let count = 0;
console.log('== List of errors not used in source ==')
for(let errName of errorNames) {
if (allSrc.indexOf(errName) < 0) {
console.log(errName);
count++;
}
}
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
});
let count = 0;
console.log('== List of errors not used in source ==')
for (let errName of errorNames) {
if (allSrc.indexOf(errName) < 0) {
console.log(errName);
count++;
}
}
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
});
});
+2 -2
View File
@@ -764,8 +764,8 @@ namespace ts {
}
Node.prototype = {
kind: kind,
pos: 0,
end: 0,
pos: -1,
end: -1,
flags: 0,
parent: undefined,
};
+1 -1
View File
@@ -1979,8 +1979,8 @@ namespace ts {
function parseParameter(): ParameterDeclaration {
let node = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
node.decorators = parseDecorators();
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
setModifiers(node, parseModifiers());
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
// FormalParameter [Yield,Await]:
// BindingElement[?Yield,?Await]
+1 -3
View File
@@ -144,7 +144,7 @@ namespace ts {
return true;
}
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken;
}
export function nodeIsPresent(node: Node) {
@@ -1428,8 +1428,6 @@ namespace ts {
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
let node = <SynthesizedNode>createNode(kind);
node.pos = -1;
node.end = -1;
node.startsOnNewLine = startsOnNewLine;
return node;
}
+8 -6
View File
@@ -3062,7 +3062,7 @@ namespace ts {
}
return true;
}
else if(jsxContainer) {
else if (jsxContainer) {
let attrsType: Type;
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
// Cursor is inside a JSX self-closing element or opening element
@@ -3162,7 +3162,7 @@ namespace ts {
switch (previousToken.kind) {
case SyntaxKind.CommaToken:
return containingNodeKind === SyntaxKind.CallExpression // func( a, |
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
|| containingNodeKind === SyntaxKind.NewExpression // new C(a, |
|| containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, |
|| containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, |
@@ -3173,10 +3173,12 @@ namespace ts {
|| containingNodeKind === SyntaxKind.Constructor // constructor( |
|| containingNodeKind === SyntaxKind.NewExpression // new C(a|
|| containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a|
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
case SyntaxKind.OpenBracketToken:
return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ |
return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ |
|| containingNodeKind === SyntaxKind.IndexSignature // [ | : string ]
|| containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */
case SyntaxKind.ModuleKeyword: // module |
case SyntaxKind.NamespaceKeyword: // namespace |
@@ -7385,8 +7387,8 @@ namespace ts {
}
let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = 0;
proto.end = 0;
proto.pos = -1;
proto.end = -1;
proto.flags = 0;
proto.parent = undefined;
Node.prototype = proto;
@@ -0,0 +1,21 @@
tests/cases/compiler/restParamModifier.ts(2,17): error TS2370: A rest parameter must be of an array type.
tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: '=' expected.
tests/cases/compiler/restParamModifier.ts(2,27): error TS2304: Cannot find name 'rest'.
tests/cases/compiler/restParamModifier.ts(2,31): error TS1005: ',' expected.
tests/cases/compiler/restParamModifier.ts(2,39): error TS1005: '=' expected.
==== tests/cases/compiler/restParamModifier.ts (5 errors) ====
class C {
constructor(...public rest: string[]) {}
~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
~~~~
!!! error TS1005: '=' expected.
~~~~
!!! error TS2304: Cannot find name 'rest'.
~
!!! error TS1005: ',' expected.
~
!!! error TS1005: '=' expected.
}
@@ -0,0 +1,12 @@
//// [restParamModifier.ts]
class C {
constructor(...public rest: string[]) {}
}
//// [restParamModifier.js]
var C = (function () {
function C(public, string) {
if (string === void 0) { string = []; }
}
return C;
})();
@@ -0,0 +1,9 @@
tests/cases/compiler/restParamModifier2.ts(2,24): error TS1005: ',' expected.
==== tests/cases/compiler/restParamModifier2.ts (1 errors) ====
class C {
constructor(public ...rest: string[]) {}
~~~
!!! error TS1005: ',' expected.
}
@@ -0,0 +1,15 @@
//// [restParamModifier2.ts]
class C {
constructor(public ...rest: string[]) {}
}
//// [restParamModifier2.js]
var C = (function () {
function C(public) {
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
}
return C;
})();
@@ -0,0 +1,3 @@
class C {
constructor(...public rest: string[]) {}
}
@@ -0,0 +1,3 @@
class C {
constructor(public ...rest: string[]) {}
}
@@ -0,0 +1,20 @@
/// <reference path='fourslash.ts' />
////interface I<T> {
//// [/*1*/]: T;
//// [/*2*/]: T;
////}
////
////class C {
//// [/*3*/]: string;
//// [str/*4*/: string]: number;
////}
////
////type T = {
//// [x/*5*/yz: number]: boolean;
//// [/*6*/
for (let marker of test.markers()) {
goTo.position(marker.position);
verify.completionListAllowsNewIdentifier();
}
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
////interface I<T> {
//// [x: /*1*/]: T;
//// [: /*2*/]: T
////}
////
////class C {
//// [a: /*3*/]: string;
//// [str: string/*4*/]: number;
////}
////
////type T = {
//// [xyz: /*5*/
for (let marker of test.markers()) {
goTo.position(marker.position);
verify.not.completionListAllowsNewIdentifier();
}