Merge branch 'release-1.5'

This commit is contained in:
Jason Freeman 2015-06-03 17:56:53 -07:00
commit abf18c5a11
33 changed files with 353 additions and 40 deletions

View File

@ -129,7 +129,8 @@ var harnessSources = [
"services/preProcessFile.ts",
"services/patternMatcher.ts",
"versionCache.ts",
"convertToBase64.ts"
"convertToBase64.ts",
"transpile.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([

View File

@ -4884,6 +4884,21 @@ var ts;
return result;
}
ts.convertToBase64 = convertToBase64;
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function getNewLineCharacter(options) {
if (options.newLine === 0) {
return carriageReturnLineFeed;
}
else if (options.newLine === 1) {
return lineFeed;
}
else if (ts.sys) {
return ts.sys.newLine;
}
return carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -15409,6 +15424,9 @@ var ts;
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body) {
if (!node.type) {
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
if (node.body.kind === 180) {
checkSourceElement(node.body);
}
@ -26055,8 +26073,6 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "1.5.3";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -26127,9 +26143,7 @@ var ts;
}
}
}
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
options.newLine === 1 ? lineFeed :
ts.sys.newLine;
var newLine = ts.getNewLineCharacter(options);
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -26197,6 +26211,7 @@ var ts;
getGlobalDiagnostics: getGlobalDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getDeclarationDiagnostics: getDeclarationDiagnostics,
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
getTypeChecker: getTypeChecker,
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@ -26277,6 +26292,11 @@ var ts;
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
}
}
function getCompilerOptionsDiagnostics() {
var allDiagnostics = [];
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
var typeChecker = getDiagnosticsProducingTypeChecker();
var allDiagnostics = [];

View File

@ -4759,6 +4759,21 @@ var ts;
return result;
}
ts.convertToBase64 = convertToBase64;
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function getNewLineCharacter(options) {
if (options.newLine === 0) {
return carriageReturnLineFeed;
}
else if (options.newLine === 1) {
return lineFeed;
}
else if (ts.sys) {
return ts.sys.newLine;
}
return carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -15799,6 +15814,9 @@ var ts;
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body) {
if (!node.type) {
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
if (node.body.kind === 180) {
checkSourceElement(node.body);
}
@ -26445,8 +26463,6 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "1.5.3";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -26517,9 +26533,7 @@ var ts;
}
}
}
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
options.newLine === 1 ? lineFeed :
ts.sys.newLine;
var newLine = ts.getNewLineCharacter(options);
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -26587,6 +26601,7 @@ var ts;
getGlobalDiagnostics: getGlobalDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getDeclarationDiagnostics: getDeclarationDiagnostics,
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
getTypeChecker: getTypeChecker,
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@ -26667,6 +26682,11 @@ var ts;
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
}
}
function getCompilerOptionsDiagnostics() {
var allDiagnostics = [];
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
var typeChecker = getDiagnosticsProducingTypeChecker();
var allDiagnostics = [];
@ -32389,11 +32409,14 @@ var ts;
var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
options.isolatedModules = true;
options.allowNonTsExtensions = true;
options.noLib = true;
options.noResolve = true;
var inputFileName = fileName || "module.ts";
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
if (diagnostics && sourceFile.parseDiagnostics) {
diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
}
var newLine = ts.getNewLineCharacter(options);
var outputText;
var compilerHost = {
getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; },
@ -32405,11 +32428,11 @@ var ts;
useCaseSensitiveFileNames: function () { return false; },
getCanonicalFileName: function (fileName) { return fileName; },
getCurrentDirectory: function () { return ""; },
getNewLine: function () { return (ts.sys && ts.sys.newLine) || "\r\n"; }
getNewLine: function () { return newLine; }
};
var program = ts.createProgram([inputFileName], options, compilerHost);
if (diagnostics) {
diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics());
diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics());
}
program.emit();
ts.Debug.assert(outputText !== undefined, "Output generation failed");

View File

@ -6159,6 +6159,21 @@ var ts;
return result;
}
ts.convertToBase64 = convertToBase64;
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function getNewLineCharacter(options) {
if (options.newLine === 0 /* CarriageReturnLineFeed */) {
return carriageReturnLineFeed;
}
else if (options.newLine === 1 /* LineFeed */) {
return lineFeed;
}
else if (ts.sys) {
return ts.sys.newLine;
}
return carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -18778,6 +18793,14 @@ var ts;
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body) {
if (!node.type) {
// There are some checks that are only performed in getReturnTypeFromBody, that may produce errors
// we need. An example is the noImplicitAny errors resulting from widening the return expression
// of a function. Because checking of function expression bodies is deferred, there was never an
// appropriate time to do this during the main walk of the file (see the comment at the top of
// checkFunctionExpressionBodies). So it must be done now.
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
if (node.body.kind === 180 /* Block */) {
checkSourceElement(node.body);
}
@ -30945,8 +30968,6 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "1.5.3";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -31020,9 +31041,7 @@ var ts;
}
}
}
var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
options.newLine === 1 /* LineFeed */ ? lineFeed :
ts.sys.newLine;
var newLine = ts.getNewLineCharacter(options);
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -31090,6 +31109,7 @@ var ts;
getGlobalDiagnostics: getGlobalDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getDeclarationDiagnostics: getDeclarationDiagnostics,
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
getTypeChecker: getTypeChecker,
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@ -31181,6 +31201,11 @@ var ts;
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
}
}
function getCompilerOptionsDiagnostics() {
var allDiagnostics = [];
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
var typeChecker = getDiagnosticsProducingTypeChecker();
var allDiagnostics = [];
@ -38000,12 +38025,20 @@ var ts;
* Extra compiler options that will unconditionally be used bu this function are:
* - isolatedModules = true
* - allowNonTsExtensions = true
* - noLib = true
* - noResolve = true
*/
function transpile(input, compilerOptions, fileName, diagnostics) {
var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
options.isolatedModules = true;
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
// We are not returning a sourceFile for lib file when asked by the program,
// so pass --noLib to avoid reporting a file not found error.
options.noLib = true;
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
// Parse
var inputFileName = fileName || "module.ts";
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
@ -38013,6 +38046,7 @@ var ts;
if (diagnostics && sourceFile.parseDiagnostics) {
diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
}
var newLine = ts.getNewLineCharacter(options);
// Output
var outputText;
// Create a compilerHost object to allow the compiler to read and write files
@ -38026,11 +38060,11 @@ var ts;
useCaseSensitiveFileNames: function () { return false; },
getCanonicalFileName: function (fileName) { return fileName; },
getCurrentDirectory: function () { return ""; },
getNewLine: function () { return (ts.sys && ts.sys.newLine) || "\r\n"; }
getNewLine: function () { return newLine; }
};
var program = ts.createProgram([inputFileName], options, compilerHost);
if (diagnostics) {
diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics());
diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics());
}
// Emit
program.emit();

View File

@ -6159,6 +6159,21 @@ var ts;
return result;
}
ts.convertToBase64 = convertToBase64;
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function getNewLineCharacter(options) {
if (options.newLine === 0 /* CarriageReturnLineFeed */) {
return carriageReturnLineFeed;
}
else if (options.newLine === 1 /* LineFeed */) {
return lineFeed;
}
else if (ts.sys) {
return ts.sys.newLine;
}
return carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -18778,6 +18793,14 @@ var ts;
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body) {
if (!node.type) {
// There are some checks that are only performed in getReturnTypeFromBody, that may produce errors
// we need. An example is the noImplicitAny errors resulting from widening the return expression
// of a function. Because checking of function expression bodies is deferred, there was never an
// appropriate time to do this during the main walk of the file (see the comment at the top of
// checkFunctionExpressionBodies). So it must be done now.
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
if (node.body.kind === 180 /* Block */) {
checkSourceElement(node.body);
}
@ -30945,8 +30968,6 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "1.5.3";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -31020,9 +31041,7 @@ var ts;
}
}
}
var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
options.newLine === 1 /* LineFeed */ ? lineFeed :
ts.sys.newLine;
var newLine = ts.getNewLineCharacter(options);
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -31090,6 +31109,7 @@ var ts;
getGlobalDiagnostics: getGlobalDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getDeclarationDiagnostics: getDeclarationDiagnostics,
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
getTypeChecker: getTypeChecker,
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@ -31181,6 +31201,11 @@ var ts;
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
}
}
function getCompilerOptionsDiagnostics() {
var allDiagnostics = [];
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics() {
var typeChecker = getDiagnosticsProducingTypeChecker();
var allDiagnostics = [];
@ -38000,12 +38025,20 @@ var ts;
* Extra compiler options that will unconditionally be used bu this function are:
* - isolatedModules = true
* - allowNonTsExtensions = true
* - noLib = true
* - noResolve = true
*/
function transpile(input, compilerOptions, fileName, diagnostics) {
var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
options.isolatedModules = true;
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
// We are not returning a sourceFile for lib file when asked by the program,
// so pass --noLib to avoid reporting a file not found error.
options.noLib = true;
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
// Parse
var inputFileName = fileName || "module.ts";
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
@ -38013,6 +38046,7 @@ var ts;
if (diagnostics && sourceFile.parseDiagnostics) {
diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
}
var newLine = ts.getNewLineCharacter(options);
// Output
var outputText;
// Create a compilerHost object to allow the compiler to read and write files
@ -38026,11 +38060,11 @@ var ts;
useCaseSensitiveFileNames: function () { return false; },
getCanonicalFileName: function (fileName) { return fileName; },
getCurrentDirectory: function () { return ""; },
getNewLine: function () { return (ts.sys && ts.sys.newLine) || "\r\n"; }
getNewLine: function () { return newLine; }
};
var program = ts.createProgram([inputFileName], options, compilerHost);
if (diagnostics) {
diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics());
diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics());
}
// Emit
program.emit();

View File

@ -1646,6 +1646,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
// When diagnosing whether the expression needs parentheses, the decision should be based
// on the innermost expression in a chain of nested type assertions.
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
expr = (<TypeAssertion>expr).expression;
}
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
// to parenthesize the expression before a dot. The known exceptions are:
//
@ -1654,7 +1660,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
// NumberLiteral
// 1.x -> not the same as (1).x
//
if (isLeftHandSideExpression(expr) && expr.kind !== SyntaxKind.NewExpression && expr.kind !== SyntaxKind.NumericLiteral) {
if (isLeftHandSideExpression(expr) &&
expr.kind !== SyntaxKind.NewExpression &&
expr.kind !== SyntaxKind.NumericLiteral) {
return <LeftHandSideExpression>expr;
}
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
@ -1941,7 +1950,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function emitParenExpression(node: ParenthesizedExpression) {
if (!node.parent || node.parent.kind !== SyntaxKind.ArrowFunction) {
// If the node is synthesized, it means the emitter put the parentheses there,
// not the user. If we didn't want them, the emitter would not have put them
// there.
if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) {
if (node.expression.kind === SyntaxKind.TypeAssertionExpression) {
let operand = (<TypeAssertion>node.expression).expression;

View File

@ -10,9 +10,6 @@ module ts {
/** The version of the TypeScript compiler release */
export const version = "1.5.3";
const carriageReturnLineFeed = "\r\n";
const lineFeed = "\n";
export function findConfigFile(searchPath: string): string {
var fileName = "tsconfig.json";
while (true) {
@ -94,10 +91,7 @@ module ts {
}
}
let newLine =
options.newLine === NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed :
options.newLine === NewLineKind.LineFeed ? lineFeed :
sys.newLine;
const newLine = getNewLineCharacter(options);
return {
getSourceFile,
@ -175,6 +169,7 @@ module ts {
getGlobalDiagnostics,
getSemanticDiagnostics,
getDeclarationDiagnostics,
getCompilerOptionsDiagnostics,
getTypeChecker,
getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: () => commonSourceDirectory,
@ -291,6 +286,12 @@ module ts {
}
}
function getCompilerOptionsDiagnostics(): Diagnostic[] {
let allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics(): Diagnostic[] {
let typeChecker = getDiagnosticsProducingTypeChecker();

View File

@ -1197,6 +1197,7 @@ module ts {
getGlobalDiagnostics(): Diagnostic[];
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
/* @internal */ getCompilerOptionsDiagnostics(): Diagnostic[];
/**
* Gets a type checker that can be used to semantically analyze source fils in the program.

View File

@ -1985,6 +1985,21 @@ module ts {
return result;
}
const carriageReturnLineFeed = "\r\n";
const lineFeed = "\n";
export function getNewLineCharacter(options: CompilerOptions): string {
if (options.newLine === NewLineKind.CarriageReturnLineFeed) {
return carriageReturnLineFeed;
}
else if (options.newLine === NewLineKind.LineFeed) {
return lineFeed;
}
else if (sys) {
return sys.newLine
}
return carriageReturnLineFeed;
}
}
module ts {

View File

@ -1765,6 +1765,8 @@ module ts {
* Extra compiler options that will unconditionally be used bu this function are:
* - isolatedModules = true
* - allowNonTsExtensions = true
* - noLib = true
* - noResolve = true
*/
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
@ -1774,15 +1776,25 @@ module ts {
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
// We are not returning a sourceFile for lib file when asked by the program,
// so pass --noLib to avoid reporting a file not found error.
options.noLib = true;
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
// Parse
var inputFileName = fileName || "module.ts";
var sourceFile = createSourceFile(inputFileName, input, options.target);
let inputFileName = fileName || "module.ts";
let sourceFile = createSourceFile(inputFileName, input, options.target);
// Store syntactic diagnostics
if (diagnostics && sourceFile.parseDiagnostics) {
diagnostics.push(...sourceFile.parseDiagnostics);
}
let newLine = getNewLineCharacter(options);
// Output
let outputText: string;
@ -1797,13 +1809,13 @@ module ts {
useCaseSensitiveFileNames: () => false,
getCanonicalFileName: fileName => fileName,
getCurrentDirectory: () => "",
getNewLine: () => (sys && sys.newLine) || "\r\n"
getNewLine: () => newLine
};
var program = createProgram([inputFileName], options, compilerHost);
if (diagnostics) {
diagnostics.push(...program.getGlobalDiagnostics());
diagnostics.push(...program.getCompilerOptionsDiagnostics());
}
// Emit

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts(1,18): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts (1 errors) ====
var { x } = <any>foo();
~~~
!!! error TS2304: Cannot find name 'foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_1.ts]
var { x } = <any>foo();
//// [destructuringTypeAssertionsES5_1.js]
var x = foo().x;

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts(1,19): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts (1 errors) ====
var { x } = (<any>foo());
~~~
!!! error TS2304: Cannot find name 'foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_2.ts]
var { x } = (<any>foo());
//// [destructuringTypeAssertionsES5_2.js]
var x = foo().x;

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts(1,19): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts (1 errors) ====
var { x } = <any>(foo());
~~~
!!! error TS2304: Cannot find name 'foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_3.ts]
var { x } = <any>(foo());
//// [destructuringTypeAssertionsES5_3.js]
var x = (foo()).x;

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts(1,23): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts (1 errors) ====
var { x } = <any><any>foo();
~~~
!!! error TS2304: Cannot find name 'foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_4.ts]
var { x } = <any><any>foo();
//// [destructuringTypeAssertionsES5_4.js]
var x = foo().x;

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_5.ts]
var { x } = <any>0;
//// [destructuringTypeAssertionsES5_5.js]
var x = (0).x;

View File

@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
var { x } = <any>0;
>x : Symbol(x, Decl(destructuringTypeAssertionsES5_5.ts, 0, 5))

View File

@ -0,0 +1,6 @@
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
var { x } = <any>0;
>x : any
><any>0 : any
>0 : number

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts(1,22): error TS2304: Cannot find name 'Foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts (1 errors) ====
var { x } = <any>new Foo;
~~~
!!! error TS2304: Cannot find name 'Foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_6.ts]
var { x } = <any>new Foo;
//// [destructuringTypeAssertionsES5_6.js]
var x = (new Foo).x;

View File

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts(1,27): error TS2304: Cannot find name 'Foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts (1 errors) ====
var { x } = <any><any>new Foo;
~~~
!!! error TS2304: Cannot find name 'Foo'.

View File

@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_7.ts]
var { x } = <any><any>new Foo;
//// [destructuringTypeAssertionsES5_7.js]
var x = (new Foo).x;

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any>foo();

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = (<any>foo());

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any>(foo());

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any><any>foo();

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any>0;

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any>new Foo;

View File

@ -0,0 +1,2 @@
//@target: ES5
var { x } = <any><any>new Foo;

View File

@ -0,0 +1,59 @@
/// <reference path="..\..\..\src\harness\harness.ts" />
module ts {
describe("Transpile", () => {
function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void {
let diagnostics: Diagnostic[] = [];
let result = transpile(input, compilerOptions, "file.ts", diagnostics);
for (let i = 0; i < expectedDiagnosticCodes.length; i++) {
assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`);
}
assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected");
if (expectedOutput !== undefined) {
assert.equal(result, expectedOutput);
}
}
it("Generates correct compilerOptions diagnostics", () => {
// Expecting 5047: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher."
runTest(`var x = 0;`, {}, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]);
});
it("Generates no diagnostics with valid inputs", () => {
// No errors
runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates no diagnostics for missing file references", () => {
runTest(`/// <reference path="file2.ts" />
var x = 0;`,
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates no diagnostics for missing module imports", () => {
runTest(`import {a} from "module2";`,
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates expected syntactic diagnostics", () => {
runTest(`a b`,
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected
});
it("Does not generate semantic diagnostics", () => {
runTest(`var x: string = 0;`,
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates module output", () => {
runTest(`var x = 0;`, { module: ModuleKind.AMD }, `define(["require", "exports"], function (require, exports) {\r\n var x = 0;\r\n});\r\n`);
});
it("Uses correct newLine character", () => {
runTest(`var x = 0;`, { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed }, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []);
});
});
}