mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix merge conflicts with master
This commit is contained in:
@@ -1,67 +1,67 @@
|
||||
//// [APISample_linter.ts]
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var process: any;
|
||||
declare var console: any;
|
||||
declare var readFileSync: any;
|
||||
|
||||
import * as ts from "typescript";
|
||||
|
||||
export function delint(sourceFile: ts.SourceFile) {
|
||||
delintNode(sourceFile);
|
||||
|
||||
function delintNode(node: ts.Node) {
|
||||
switch (node.kind) {
|
||||
case ts.SyntaxKind.ForStatement:
|
||||
case ts.SyntaxKind.ForInStatement:
|
||||
case ts.SyntaxKind.WhileStatement:
|
||||
case ts.SyntaxKind.DoStatement:
|
||||
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.IfStatement:
|
||||
let ifStatement = (<ts.IfStatement>node);
|
||||
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.BinaryExpression:
|
||||
let op = (<ts.BinaryExpression>node).operatorToken.kind;
|
||||
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
|
||||
report(node, "Use '===' and '!=='.")
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ts.forEachChild(node, delintNode);
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(fileName => {
|
||||
// Parse a file
|
||||
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var process: any;
|
||||
declare var console: any;
|
||||
declare var readFileSync: any;
|
||||
|
||||
import * as ts from "typescript";
|
||||
|
||||
export function delint(sourceFile: ts.SourceFile) {
|
||||
delintNode(sourceFile);
|
||||
|
||||
function delintNode(node: ts.Node) {
|
||||
switch (node.kind) {
|
||||
case ts.SyntaxKind.ForStatement:
|
||||
case ts.SyntaxKind.ForInStatement:
|
||||
case ts.SyntaxKind.WhileStatement:
|
||||
case ts.SyntaxKind.DoStatement:
|
||||
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.IfStatement:
|
||||
let ifStatement = (<ts.IfStatement>node);
|
||||
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.BinaryExpression:
|
||||
let op = (<ts.BinaryExpression>node).operatorToken.kind;
|
||||
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
|
||||
report(node, "Use '===' and '!=='.")
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ts.forEachChild(node, delintNode);
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(fileName => {
|
||||
// Parse a file
|
||||
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
});
|
||||
|
||||
//// [APISample_linter.js]
|
||||
@@ -75,26 +75,26 @@ function delint(sourceFile) {
|
||||
delintNode(sourceFile);
|
||||
function delintNode(node) {
|
||||
switch (node.kind) {
|
||||
case 188 /* ForStatement */:
|
||||
case 189 /* ForInStatement */:
|
||||
case 187 /* WhileStatement */:
|
||||
case 186 /* DoStatement */:
|
||||
if (node.statement.kind !== 181 /* Block */) {
|
||||
case 189 /* ForStatement */:
|
||||
case 190 /* ForInStatement */:
|
||||
case 188 /* WhileStatement */:
|
||||
case 187 /* DoStatement */:
|
||||
if (node.statement.kind !== 182 /* Block */) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 185 /* IfStatement */:
|
||||
case 186 /* IfStatement */:
|
||||
var ifStatement = node;
|
||||
if (ifStatement.thenStatement.kind !== 181 /* Block */) {
|
||||
if (ifStatement.thenStatement.kind !== 182 /* Block */) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 181 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 185 /* IfStatement */) {
|
||||
ifStatement.elseStatement.kind !== 182 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 186 /* IfStatement */) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 171 /* BinaryExpression */:
|
||||
case 172 /* BinaryExpression */:
|
||||
var op = node.operatorToken.kind;
|
||||
if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) {
|
||||
report(node, "Use '===' and '!=='.");
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1110: Type expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (1 errors) ====
|
||||
var v = (a): => {
|
||||
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
~~
|
||||
!!! error TS1110: Type expected.
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ for (let v of []) {
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var v = _a[_i];
|
||||
v;
|
||||
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
|
||||
for (var _b = 0, _c = [v_1]; _b < _c.length; _b++) {
|
||||
var v_1 = _c[_b];
|
||||
var x = v_1;
|
||||
v_1++;
|
||||
|
||||
@@ -10,7 +10,7 @@ for (let v of []) {
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var v = _a[_i];
|
||||
var v_1;
|
||||
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
|
||||
for (var _b = 0, _c = [v_2]; _b < _c.length; _b++) {
|
||||
var v_2 = _c[_b];
|
||||
var v_3;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
-1
@@ -16,6 +16,5 @@ var A;
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
A.beez;
|
||||
A.beez2 = new Array();
|
||||
})(A || (A = {}));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ====
|
||||
function * foo(a = yield => yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ====
|
||||
function * yield() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
~~~~~
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ====
|
||||
function*foo(a = yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ====
|
||||
function*bar() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
var v = { [yield]: foo }
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ====
|
||||
var v = function * () { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ====
|
||||
var v = function * foo() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ====
|
||||
var v = { *foo() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*foo() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ====
|
||||
class C {
|
||||
public * foo() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration
|
||||
class C {
|
||||
*[foo]() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ====
|
||||
class C {
|
||||
*foo<T>() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts(3,8): error TS1123: Variable declaration list cannot be empty.
|
||||
tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts(4,5): error TS2304: Cannot find name 'let'.
|
||||
tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts(5,10): error TS1123: Variable declaration list cannot be empty.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts (3 errors) ====
|
||||
|
||||
module Inner {
|
||||
var;
|
||||
|
||||
!!! error TS1123: Variable declaration list cannot be empty.
|
||||
let;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'let'.
|
||||
const;
|
||||
|
||||
!!! error TS1123: Variable declaration list cannot be empty.
|
||||
|
||||
export var a;
|
||||
export let b;
|
||||
export var c: string;
|
||||
export let d: number;
|
||||
class A {}
|
||||
export var e: A;
|
||||
export let f: A;
|
||||
|
||||
namespace B {
|
||||
export let a = 1, b, c = 2;
|
||||
export let x, y, z;
|
||||
}
|
||||
|
||||
module C {
|
||||
export var a = 1, b, c = 2;
|
||||
export var x, y, z;
|
||||
}
|
||||
|
||||
// Shouldn't be filtered
|
||||
export var a1 = 1;
|
||||
export let b1 = 1;
|
||||
export var c1: string = 'a';
|
||||
export let d1: number = 1;
|
||||
class D {}
|
||||
export var e1 = new D;
|
||||
export let f1 = new D;
|
||||
export var g1: D = new D;
|
||||
export let h1: D = new D;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//// [NonInitializedExportInInternalModule.ts]
|
||||
|
||||
module Inner {
|
||||
var;
|
||||
let;
|
||||
const;
|
||||
|
||||
export var a;
|
||||
export let b;
|
||||
export var c: string;
|
||||
export let d: number;
|
||||
class A {}
|
||||
export var e: A;
|
||||
export let f: A;
|
||||
|
||||
namespace B {
|
||||
export let a = 1, b, c = 2;
|
||||
export let x, y, z;
|
||||
}
|
||||
|
||||
module C {
|
||||
export var a = 1, b, c = 2;
|
||||
export var x, y, z;
|
||||
}
|
||||
|
||||
// Shouldn't be filtered
|
||||
export var a1 = 1;
|
||||
export let b1 = 1;
|
||||
export var c1: string = 'a';
|
||||
export let d1: number = 1;
|
||||
class D {}
|
||||
export var e1 = new D;
|
||||
export let f1 = new D;
|
||||
export var g1: D = new D;
|
||||
export let h1: D = new D;
|
||||
}
|
||||
|
||||
//// [NonInitializedExportInInternalModule.js]
|
||||
var Inner;
|
||||
(function (Inner) {
|
||||
var ;
|
||||
let;
|
||||
var ;
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B;
|
||||
(function (B) {
|
||||
B.a = 1, B.c = 2;
|
||||
})(B || (B = {}));
|
||||
var C;
|
||||
(function (C) {
|
||||
C.a = 1, C.c = 2;
|
||||
})(C || (C = {}));
|
||||
// Shouldn't be filtered
|
||||
Inner.a1 = 1;
|
||||
Inner.b1 = 1;
|
||||
Inner.c1 = 'a';
|
||||
Inner.d1 = 1;
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
Inner.e1 = new D;
|
||||
Inner.f1 = new D;
|
||||
Inner.g1 = new D;
|
||||
Inner.h1 = new D;
|
||||
})(Inner || (Inner = {}));
|
||||
-2
@@ -39,14 +39,12 @@ var A;
|
||||
(function (A) {
|
||||
var B;
|
||||
(function (B) {
|
||||
B.x;
|
||||
})(B = A.B || (A.B = {}));
|
||||
})(A || (A = {}));
|
||||
var A;
|
||||
(function (A) {
|
||||
var B;
|
||||
(function (B) {
|
||||
B.x;
|
||||
})(B || (B = {}));
|
||||
})(A || (A = {}));
|
||||
// ensure the right var decl is exported
|
||||
|
||||
@@ -35,14 +35,14 @@ function f1(x: Color | string) {
|
||||
}
|
||||
|
||||
function f2(x: Color | string | string[]) {
|
||||
>f2 : (x: string | string[] | Color) => void
|
||||
>x : string | string[] | Color
|
||||
>f2 : (x: string | Color | string[]) => void
|
||||
>x : string | Color | string[]
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "object") {
|
||||
>typeof x === "object" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"object" : string
|
||||
|
||||
var y = x;
|
||||
@@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"number" : string
|
||||
|
||||
var z = x;
|
||||
@@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "string") {
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"string" : string
|
||||
|
||||
var a = x;
|
||||
@@ -89,11 +89,11 @@ function f2(x: Color | string | string[]) {
|
||||
}
|
||||
else {
|
||||
var b = x;
|
||||
>b : string[] | Color
|
||||
>x : string[] | Color
|
||||
>b : Color | string[]
|
||||
>x : Color | string[]
|
||||
|
||||
var b: Color | string[];
|
||||
>b : string[] | Color
|
||||
>b : Color | string[]
|
||||
>Color : Color
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,11): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (2 errors) ====
|
||||
var v = { * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,5): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ====
|
||||
class C {
|
||||
*foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ====
|
||||
@@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): erro
|
||||
constructor() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,19): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ====
|
||||
function* foo() { yield }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ====
|
||||
@@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): erro
|
||||
foo() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ====
|
||||
var v = () => {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
function bar() {
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ====
|
||||
@@ -10,4 +10,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err
|
||||
~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
|
||||
"use strict";
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@@ -1,19 +1,16 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(4,7): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (2 errors) ====
|
||||
function*foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
function bar() {
|
||||
function* quux() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ====
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@@ -1,16 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
yield
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield;
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
yield;
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,9): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (2 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield*foo
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
~~~
|
||||
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ====
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ====
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
function* foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,9): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (2 errors) ====
|
||||
var v = function*() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts (2 errors) ====
|
||||
yield * [];
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [YieldStarExpression1_es6.ts]
|
||||
yield * [];
|
||||
|
||||
//// [YieldStarExpression1_es6.js]
|
||||
yield * [];
|
||||
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,8): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts (2 errors) ====
|
||||
yield *;
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [YieldStarExpression2_es6.ts]
|
||||
yield *;
|
||||
|
||||
//// [YieldStarExpression2_es6.js]
|
||||
yield * ;
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts(2,12): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts (1 errors) ====
|
||||
function *g() {
|
||||
yield *;
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [YieldStarExpression3_es6.ts]
|
||||
function *g() {
|
||||
yield *;
|
||||
}
|
||||
|
||||
//// [YieldStarExpression3_es6.js]
|
||||
function g() {
|
||||
yield* ;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(2,13): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (2 errors) ====
|
||||
function *g() {
|
||||
~
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
yield * [];
|
||||
~~
|
||||
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [YieldStarExpression4_es6.ts]
|
||||
function *g() {
|
||||
yield * [];
|
||||
}
|
||||
|
||||
//// [YieldStarExpression4_es6.js]
|
||||
function g() {
|
||||
yield* [];
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -55,7 +55,6 @@ var E;
|
||||
})(E || (E = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
M.a;
|
||||
})(M || (M = {}));
|
||||
var a;
|
||||
var b;
|
||||
|
||||
@@ -56,7 +56,6 @@ var E;
|
||||
})(E || (E = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
M.a;
|
||||
})(M || (M = {}));
|
||||
var a;
|
||||
var b;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/aliasErrors.ts(11,12): error TS2304: Cannot find name 'no'.
|
||||
tests/cases/compiler/aliasErrors.ts(12,13): error TS2304: Cannot find name 'no'.
|
||||
tests/cases/compiler/aliasErrors.ts(11,12): error TS2503: Cannot find namespace 'no'.
|
||||
tests/cases/compiler/aliasErrors.ts(12,13): error TS2503: Cannot find namespace 'no'.
|
||||
tests/cases/compiler/aliasErrors.ts(13,12): error TS1003: Identifier expected.
|
||||
tests/cases/compiler/aliasErrors.ts(14,12): error TS1003: Identifier expected.
|
||||
tests/cases/compiler/aliasErrors.ts(15,12): error TS1003: Identifier expected.
|
||||
tests/cases/compiler/aliasErrors.ts(16,12): error TS2304: Cannot find name 'undefined'.
|
||||
tests/cases/compiler/aliasErrors.ts(16,12): error TS2503: Cannot find namespace 'undefined'.
|
||||
tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'.
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' h
|
||||
|
||||
import m = no;
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'no'.
|
||||
!!! error TS2503: Cannot find namespace 'no'.
|
||||
import m2 = no.mod;
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'no'.
|
||||
!!! error TS2503: Cannot find namespace 'no'.
|
||||
import n = 5;
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
@@ -35,7 +35,7 @@ tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' h
|
||||
!!! error TS1003: Identifier expected.
|
||||
import r = undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'undefined'.
|
||||
!!! error TS2503: Cannot find namespace 'undefined'.
|
||||
|
||||
|
||||
var p = new provide.Provide();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,7 +19,6 @@ export var a = function () {
|
||||
|
||||
|
||||
//// [aliasUsedAsNameValue_0.js]
|
||||
exports.id;
|
||||
//// [aliasUsedAsNameValue_1.js]
|
||||
function b(a) { return null; }
|
||||
exports.b = b;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(7,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(8,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts (4 errors) ====
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
c = b,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
d = (c) + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
e = 10 << 2 * 8,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ambientEnumDeclaration1.ts]
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
c = b,
|
||||
d = (c) + 1,
|
||||
e = 10 << 2 * 8,
|
||||
}
|
||||
|
||||
//// [ambientEnumDeclaration1.js]
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [ambientEnumDeclaration2.ts]
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
a, // E.a
|
||||
b, // E.b
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
a, // E.a = 0
|
||||
b, // E.b = 1
|
||||
}
|
||||
|
||||
//// [ambientEnumDeclaration2.js]
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/ambient/ambientEnumDeclaration2.ts ===
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
>E : Symbol(E, Decl(ambientEnumDeclaration2.ts, 0, 0))
|
||||
|
||||
a, // E.a
|
||||
>a : Symbol(E.a, Decl(ambientEnumDeclaration2.ts, 3, 16))
|
||||
|
||||
b, // E.b
|
||||
>b : Symbol(E.b, Decl(ambientEnumDeclaration2.ts, 4, 6))
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
>E1 : Symbol(E1, Decl(ambientEnumDeclaration2.ts, 6, 1))
|
||||
|
||||
a, // E.a = 0
|
||||
>a : Symbol(E1.a, Decl(ambientEnumDeclaration2.ts, 8, 23))
|
||||
|
||||
b, // E.b = 1
|
||||
>b : Symbol(E1.b, Decl(ambientEnumDeclaration2.ts, 9, 6))
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/ambient/ambientEnumDeclaration2.ts ===
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
>E : E
|
||||
|
||||
a, // E.a
|
||||
>a : E
|
||||
|
||||
b, // E.b
|
||||
>b : E
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
a, // E.a = 0
|
||||
>a : E1
|
||||
|
||||
b, // E.b = 1
|
||||
>b : E1
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(16,5): error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
Property '0' is missing in type '(string | number | boolean)[]'.
|
||||
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(17,5): error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(18,5): error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type '(string | number)[]' is not assignable to type '[any, any]'.
|
||||
Property '0' is missing in type '(string | number)[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts (3 errors) ====
|
||||
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
|
||||
function foo({x: [a, b], y: {c, d, e}}) { }
|
||||
function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { }
|
||||
function baz(x: [string, number, boolean]) { }
|
||||
|
||||
var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
foo(o1); // Not error since x has contextual type of tuple namely [string, number]
|
||||
foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error
|
||||
|
||||
var array = ["string", 1, true];
|
||||
var tuple: [string, number, boolean] = ["string", 1, true];
|
||||
baz(tuple);
|
||||
baz(["string", 1, true]);
|
||||
|
||||
baz(array); // Error
|
||||
~~~~~
|
||||
!!! error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
!!! error TS2345: Property '0' is missing in type '(string | number | boolean)[]'.
|
||||
baz(["string", 1, true, ...array]); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
foo(o); // Error because x has an array type namely (string|number)[]
|
||||
~
|
||||
!!! error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type '(string | number)[]' is not assignable to type '[any, any]'.
|
||||
!!! error TS2345: Property '0' is missing in type '(string | number)[]'.
|
||||
@@ -0,0 +1,40 @@
|
||||
//// [argumentExpressionContextualTyping.ts]
|
||||
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
|
||||
function foo({x: [a, b], y: {c, d, e}}) { }
|
||||
function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { }
|
||||
function baz(x: [string, number, boolean]) { }
|
||||
|
||||
var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
foo(o1); // Not error since x has contextual type of tuple namely [string, number]
|
||||
foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error
|
||||
|
||||
var array = ["string", 1, true];
|
||||
var tuple: [string, number, boolean] = ["string", 1, true];
|
||||
baz(tuple);
|
||||
baz(["string", 1, true]);
|
||||
|
||||
baz(array); // Error
|
||||
baz(["string", 1, true, ...array]); // Error
|
||||
foo(o); // Error because x has an array type namely (string|number)[]
|
||||
|
||||
//// [argumentExpressionContextualTyping.js]
|
||||
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
|
||||
function foo(_a) {
|
||||
var _b = _a.x, a = _b[0], b = _b[1], _c = _a.y, c = _c.c, d = _c.d, e = _c.e;
|
||||
}
|
||||
function bar(_a) {
|
||||
var _b = _a.x, a = _b[0], _c = _b[1], b = _c === void 0 ? 10 : _c, _d = _a.y, c = _d.c, d = _d.d, _e = _d.e, e = _e === void 0 ? { f: 1 } : _e;
|
||||
}
|
||||
function baz(x) { }
|
||||
var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
var o1 = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
|
||||
foo(o1); // Not error since x has contextual type of tuple namely [string, number]
|
||||
foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error
|
||||
var array = ["string", 1, true];
|
||||
var tuple = ["string", 1, true];
|
||||
baz(tuple);
|
||||
baz(["string", 1, true]);
|
||||
baz(array); // Error
|
||||
baz(["string", 1, true].concat(array)); // Error
|
||||
foo(o); // Error because x has an array type namely (string|number)[]
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/argumentsObjectIterator01_ES5.ts(4,21): error TS2495: Type 'IArguments' is not an array type or a string type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/argumentsObjectIterator01_ES5.ts (1 errors) ====
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
~~~~~~~~~
|
||||
!!! error TS2495: Type 'IArguments' is not an array type or a string type.
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [argumentsObjectIterator01_ES5.ts]
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
//// [argumentsObjectIterator01_ES5.js]
|
||||
function doubleAndReturnAsArray(x, y, z) {
|
||||
var result = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
var arg = arguments[_i];
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [argumentsObjectIterator01_ES6.ts]
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
//// [argumentsObjectIterator01_ES6.js]
|
||||
function doubleAndReturnAsArray(x, y, z) {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator01_ES6.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(argumentsObjectIterator01_ES6.ts, 1, 32))
|
||||
>y : Symbol(y, Decl(argumentsObjectIterator01_ES6.ts, 1, 42))
|
||||
>z : Symbol(z, Decl(argumentsObjectIterator01_ES6.ts, 1, 53))
|
||||
|
||||
let result = [];
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
|
||||
|
||||
for (let arg of arguments) {
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
|
||||
>arguments : Symbol(arguments)
|
||||
|
||||
result.push(arg + arg);
|
||||
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
|
||||
>x : number
|
||||
>y : number
|
||||
>z : number
|
||||
|
||||
let result = [];
|
||||
>result : any[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (let arg of arguments) {
|
||||
>arg : any
|
||||
>arguments : IArguments
|
||||
|
||||
result.push(arg + arg);
|
||||
>result.push(arg + arg) : number
|
||||
>result.push : (...items: any[]) => number
|
||||
>result : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>arg + arg : any
|
||||
>arg : any
|
||||
>arg : any
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
><[any, any, any]>result : [any, any, any]
|
||||
>result : any[]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
tests/cases/compiler/argumentsObjectIterator02_ES5.ts(3,26): error TS2304: Cannot find name 'Symbol'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/argumentsObjectIterator02_ES5.ts (1 errors) ====
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'Symbol'.
|
||||
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [argumentsObjectIterator02_ES5.ts]
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [argumentsObjectIterator02_ES5.js]
|
||||
function doubleAndReturnAsArray(x, y, z) {
|
||||
var blah = arguments[Symbol.iterator];
|
||||
var result = [];
|
||||
for (var _i = 0, _a = blah(); _i < _a.length; _i++) {
|
||||
var arg = _a[_i];
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [argumentsObjectIterator02_ES6.ts]
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [argumentsObjectIterator02_ES6.js]
|
||||
function doubleAndReturnAsArray(x, y, z) {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator02_ES6.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(argumentsObjectIterator02_ES6.ts, 1, 32))
|
||||
>y : Symbol(y, Decl(argumentsObjectIterator02_ES6.ts, 1, 42))
|
||||
>z : Symbol(z, Decl(argumentsObjectIterator02_ES6.ts, 1, 53))
|
||||
|
||||
let blah = arguments[Symbol.iterator];
|
||||
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
|
||||
|
||||
let result = [];
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
|
||||
|
||||
for (let arg of blah()) {
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
|
||||
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
|
||||
|
||||
result.push(arg + arg);
|
||||
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
|
||||
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
|
||||
>x : number
|
||||
>y : number
|
||||
>z : number
|
||||
|
||||
let blah = arguments[Symbol.iterator];
|
||||
>blah : () => IterableIterator<any>
|
||||
>arguments[Symbol.iterator] : () => IterableIterator<any>
|
||||
>arguments : IArguments
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
let result = [];
|
||||
>result : any[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (let arg of blah()) {
|
||||
>arg : any
|
||||
>blah() : IterableIterator<any>
|
||||
>blah : () => IterableIterator<any>
|
||||
|
||||
result.push(arg + arg);
|
||||
>result.push(arg + arg) : number
|
||||
>result.push : (...items: any[]) => number
|
||||
>result : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>arg + arg : any
|
||||
>arg : any
|
||||
>arg : any
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
><[any, any, any]>result : [any, any, any]
|
||||
>result : any[]
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/argumentsObjectIterator03_ES5.ts(3,9): error TS2461: Type 'IArguments' is not an array type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/argumentsObjectIterator03_ES5.ts (1 errors) ====
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
let [x, y, z] = arguments;
|
||||
~~~~~~~~~
|
||||
!!! error TS2461: Type 'IArguments' is not an array type.
|
||||
|
||||
return [z, y, x];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [argumentsObjectIterator03_ES5.ts]
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
let [x, y, z] = arguments;
|
||||
|
||||
return [z, y, x];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [argumentsObjectIterator03_ES5.js]
|
||||
function asReversedTuple(a, b, c) {
|
||||
var x = arguments[0], y = arguments[1], z = arguments[2];
|
||||
return [z, y, x];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [argumentsObjectIterator03_ES6.ts]
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
let [x, y, z] = arguments;
|
||||
|
||||
return [z, y, x];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [argumentsObjectIterator03_ES6.js]
|
||||
function asReversedTuple(a, b, c) {
|
||||
let [x, y, z] = arguments;
|
||||
return [z, y, x];
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
>asReversedTuple : Symbol(asReversedTuple, Decl(argumentsObjectIterator03_ES6.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(argumentsObjectIterator03_ES6.ts, 1, 25))
|
||||
>b : Symbol(b, Decl(argumentsObjectIterator03_ES6.ts, 1, 35))
|
||||
>c : Symbol(c, Decl(argumentsObjectIterator03_ES6.ts, 1, 46))
|
||||
|
||||
let [x, y, z] = arguments;
|
||||
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
|
||||
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
|
||||
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
|
||||
>arguments : Symbol(arguments)
|
||||
|
||||
return [z, y, x];
|
||||
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
|
||||
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
|
||||
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
>asReversedTuple : (a: number, b: string, c: boolean) => [boolean, string, number]
|
||||
>a : number
|
||||
>b : string
|
||||
>c : boolean
|
||||
|
||||
let [x, y, z] = arguments;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
>arguments : IArguments
|
||||
|
||||
return [z, y, x];
|
||||
>[z, y, x] : [any, any, any]
|
||||
>z : any
|
||||
>y : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts (2 errors) ====
|
||||
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
|
||||
// the type of the property with the numeric name N in the contextual type, if any, or otherwise
|
||||
// the numeric index type of the contextual type, if any.
|
||||
var array = [1, 2, 3];
|
||||
var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type
|
||||
var tup: [number, number, number] = [1, 2, 3, 4];
|
||||
var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"];
|
||||
var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// In a contextually typed array literal expression containing one or more spread elements,
|
||||
// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any.
|
||||
var spr = [1, 2, 3, ...array];
|
||||
var spr1 = [1, 2, 3, ...tup];
|
||||
var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
!!! error TS2322: Property '0' is missing in type 'number[]'.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [arrayLiteralExpressionContextualTyping.ts]
|
||||
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
|
||||
// the type of the property with the numeric name N in the contextual type, if any, or otherwise
|
||||
// the numeric index type of the contextual type, if any.
|
||||
var array = [1, 2, 3];
|
||||
var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type
|
||||
var tup: [number, number, number] = [1, 2, 3, 4];
|
||||
var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"];
|
||||
var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error
|
||||
|
||||
// In a contextually typed array literal expression containing one or more spread elements,
|
||||
// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any.
|
||||
var spr = [1, 2, 3, ...array];
|
||||
var spr1 = [1, 2, 3, ...tup];
|
||||
var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error
|
||||
|
||||
|
||||
//// [arrayLiteralExpressionContextualTyping.js]
|
||||
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
|
||||
// the type of the property with the numeric name N in the contextual type, if any, or otherwise
|
||||
// the numeric index type of the contextual type, if any.
|
||||
var array = [1, 2, 3];
|
||||
var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type
|
||||
var tup = [1, 2, 3, 4];
|
||||
var tup1 = [1, 2, 3, "string"];
|
||||
var tup2 = [1, 2, 3, "string"]; // Error
|
||||
// In a contextually typed array literal expression containing one or more spread elements,
|
||||
// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any.
|
||||
var spr = [1, 2, 3].concat(array);
|
||||
var spr1 = [1, 2, 3].concat(tup);
|
||||
var spr2 = [1, 2, 3].concat(tup); // Error
|
||||
@@ -26,7 +26,7 @@ function f2() {
|
||||
//// [arrayLiteralSpread.js]
|
||||
function f0() {
|
||||
var a = [1, 2, 3];
|
||||
var a1 = a;
|
||||
var a1 = a.slice();
|
||||
var a2 = [1].concat(a);
|
||||
var a3 = [1, 2].concat(a);
|
||||
var a4 = a.concat([1]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : (string[] | number[])[]
|
||||
>[[], [1], ['']] : (string[] | number[])[]
|
||||
>arr1 : (number[] | string[])[]
|
||||
>[[], [1], ['']] : (number[] | string[])[]
|
||||
>[] : undefined[]
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
@@ -11,8 +11,8 @@ var arr1= [[], [1], ['']];
|
||||
>'' : string
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : (string[] | number[])[]
|
||||
>[[null], [1], ['']] : (string[] | number[])[]
|
||||
>arr2 : (number[] | string[])[]
|
||||
>[[null], [1], ['']] : (number[] | string[])[]
|
||||
>[null] : null[]
|
||||
>null : null
|
||||
>[1] : number[]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user