Merge branch 'master' into getOccurancesAssert

This commit is contained in:
Mohamed Hegazy
2014-12-02 20:16:50 -08:00
167 changed files with 5695 additions and 1013 deletions
+26 -11
View File
@@ -1,6 +1,7 @@
// This file contains the build logic for the public repo
var fs = require("fs");
var os = require("os");
var path = require("path");
var child_process = require("child_process");
@@ -148,7 +149,7 @@ var compilerFilename = "tsc.js";
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
* @param noOutFile: true to compile without using --out
*/
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations) {
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, callback) {
file(outFile, prereqs, function() {
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
var options = "-removeComments --module commonjs -noImplicitAny ";
@@ -180,6 +181,11 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
prependFile(prefixes[i], outFile);
}
}
if (callback) {
callback();
}
complete();
});
ex.addListener("error", function() {
@@ -224,7 +230,7 @@ compileFile(processDiagnosticMessagesJs,
[processDiagnosticMessagesTs],
[processDiagnosticMessagesTs],
[],
false);
/*useBuiltCompiler*/ false);
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
@@ -244,7 +250,6 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
ex.run();
}, {async: true})
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
task("generate-diagnostics", [diagnosticInfoMapTs])
@@ -255,13 +260,24 @@ compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(co
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var servicesDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ true, /*noOutFile:*/ false, /*generateDeclarations:*/ true);
compileFile(servicesFile,
servicesSources,
[builtLocalDirectory, copyright].concat(servicesSources),
[copyright],
/*useBuiltCompiler*/ true,
/*noOutFile*/ false,
/*generateDeclarations*/ true,
/*callback*/ fixDeclarationFile);
function fixDeclarationFile() {
fs.appendFileSync(servicesDefinitionsFile, os.EOL + "export = ts;")
}
// Local target to build the compiler and services
desc("Builds the full compiler and services");
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile]);
// Local target to build the compiler and services
desc("Sets release mode flag");
task("release", function() {
@@ -278,7 +294,6 @@ task("clean", function() {
jake.rmRf(builtDirectory);
});
// Generate Markdown spec
var word2mdJs = path.join(scriptsDirectory, "word2md.js");
var word2mdTs = path.join(scriptsDirectory, "word2md.ts");
@@ -292,7 +307,7 @@ compileFile(word2mdJs,
[word2mdTs],
[word2mdTs],
[],
false);
/*useBuiltCompiler*/ false);
// The generated spec.md; built for the 'generate-spec' task
file(specMd, [word2mdJs, specWord], function () {
@@ -444,7 +459,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
// Browser tests
var nodeServerOutFile = 'tests/webTestServer.js'
var nodeServerInFile = 'tests/webTestServer.ts'
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], true, true);
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true);
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
@@ -525,7 +540,7 @@ task("baseline-accept-test262", function() {
// Webhost
var webhostPath = "tests/webhost/webtsc.ts";
var webhostJsPath = "tests/webhost/webtsc.js";
compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], true);
compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], /*useBuiltCompiler*/true);
desc("Builds the tsc web host");
task("webhost", [webhostJsPath], function() {
@@ -535,7 +550,7 @@ task("webhost", [webhostJsPath], function() {
// Perf compiler
var perftscPath = "tests/perftsc.ts";
var perftscJsPath = "built/local/perftsc.js";
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], true);
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
desc("Builds augmented version of the compiler for perf tests");
task("perftsc", [perftscJsPath]);
@@ -559,7 +574,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], true);
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], /*useBuiltCompiler*/ true);
desc("Builds an instrumented tsc.js");
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
+5 -5
View File
@@ -348,8 +348,8 @@ module ts {
bindChildren(node, symbolKind, isBlockScopeContainer);
}
function bindCatchVariableDeclaration(node: CatchBlock) {
var symbol = createSymbol(SymbolFlags.FunctionScopedVariable, node.variable.text || "__missing");
function bindCatchVariableDeclaration(node: CatchClause) {
var symbol = createSymbol(SymbolFlags.FunctionScopedVariable, node.name.text || "__missing");
addDeclarationToSymbol(symbol, node, SymbolFlags.FunctionScopedVariable);
var saveParent = parent;
var savedBlockScopeContainer = blockScopeContainer;
@@ -444,8 +444,8 @@ module ts {
case SyntaxKind.ArrowFunction:
bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true);
break;
case SyntaxKind.CatchBlock:
bindCatchVariableDeclaration(<CatchBlock>node);
case SyntaxKind.CatchClause:
bindCatchVariableDeclaration(<CatchClause>node);
break;
case SyntaxKind.ClassDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes, /*isBlockScopeContainer*/ false);
@@ -478,7 +478,7 @@ module ts {
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
+64 -48
View File
@@ -85,7 +85,6 @@ module ts {
getDiagnostics,
getDeclarationDiagnostics,
getGlobalDiagnostics,
checkProgram,
getParentOfSymbol,
getNarrowedTypeOfSymbol,
getDeclaredTypeOfSymbol,
@@ -415,8 +414,8 @@ module ts {
break loop;
}
break;
case SyntaxKind.CatchBlock:
var id = (<CatchBlock>location).variable;
case SyntaxKind.CatchClause:
var id = (<CatchClause>location).name;
if (name === id.text) {
result = location.symbol;
break loop;
@@ -546,14 +545,18 @@ module ts {
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
}
function resolveExternalModuleName(location: Node, moduleExpression: Expression): Symbol {
if (moduleExpression.kind !== SyntaxKind.StringLiteral) {
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol {
if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral) {
return;
}
var moduleLiteral = <LiteralExpression>moduleExpression;
var moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
var searchPath = getDirectoryPath(getSourceFile(location).filename);
var moduleName = moduleLiteral.text;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = escapeIdentifier(moduleReferenceLiteral.text);
if (!moduleName) return;
var isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
@@ -574,10 +577,10 @@ module ts {
if (sourceFile.symbol) {
return getResolvedExportSymbol(sourceFile.symbol);
}
error(moduleLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.filename);
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.filename);
return;
}
error(moduleLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
}
function getResolvedExportSymbol(moduleSymbol: Symbol): Symbol {
@@ -756,7 +759,7 @@ module ts {
//
// x is an optional parameter, but it is a required property.
return propertySymbol.valueDeclaration &&
propertySymbol.valueDeclaration.flags & NodeFlags.QuestionMark &&
hasQuestionToken(propertySymbol.valueDeclaration) &&
propertySymbol.valueDeclaration.kind !== SyntaxKind.Parameter;
}
@@ -1437,11 +1440,11 @@ module ts {
}
function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, typeStack?: Type[]) {
if (getDeclarationFlagsFromSymbol(p) & NodeFlags.Rest) {
if (hasDotDotDotToken(p.valueDeclaration)) {
writePunctuation(writer, SyntaxKind.DotDotDotToken);
}
appendSymbolNameOnly(p, writer);
if (p.valueDeclaration.flags & NodeFlags.QuestionMark || (<VariableDeclaration>p.valueDeclaration).initializer) {
if (hasQuestionToken(p.valueDeclaration) || (<VariableDeclaration>p.valueDeclaration).initializer) {
writePunctuation(writer, SyntaxKind.QuestionToken);
}
writePunctuation(writer, SyntaxKind.ColonToken);
@@ -1711,7 +1714,7 @@ module ts {
}
// Rest parameters default to type any[], other parameters default to type any
var type = declaration.flags & NodeFlags.Rest ? createArrayType(anyType) : anyType;
var type = hasDotDotDotToken(declaration) ? createArrayType(anyType) : anyType;
checkImplicitAny(type);
return type;
@@ -1733,9 +1736,9 @@ module ts {
var diagnostic = Diagnostics.Member_0_implicitly_has_an_1_type;
break;
case SyntaxKind.Parameter:
var diagnostic = declaration.flags & NodeFlags.Rest ?
Diagnostics.Rest_parameter_0_implicitly_has_an_any_type :
Diagnostics.Parameter_0_implicitly_has_an_1_type;
var diagnostic = hasDotDotDotToken(declaration)
? Diagnostics.Rest_parameter_0_implicitly_has_an_any_type
: Diagnostics.Parameter_0_implicitly_has_an_1_type;
break;
default:
var diagnostic = Diagnostics.Variable_0_implicitly_has_an_1_type;
@@ -1753,7 +1756,7 @@ module ts {
}
// Handle catch clause variables
var declaration = symbol.valueDeclaration;
if (declaration.kind === SyntaxKind.CatchBlock) {
if (declaration.kind === SyntaxKind.CatchClause) {
return links.type = anyType;
}
// Handle variable, parameter or property
@@ -2527,7 +2530,7 @@ module ts {
hasStringLiterals = true;
}
if (minArgumentCount < 0) {
if (param.initializer || param.flags & (NodeFlags.QuestionMark | NodeFlags.Rest)) {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
minArgumentCount = i;
}
}
@@ -4375,7 +4378,7 @@ module ts {
case SyntaxKind.ThrowStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
return forEachChild(node, isAssignedIn);
}
@@ -6673,7 +6676,7 @@ module ts {
!(parameterDeclaration.parent.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>parameterDeclaration.parent).body)) {
error(parameterDeclaration, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
if (parameterDeclaration.flags & NodeFlags.Rest) {
if (parameterDeclaration.dotDotDotToken) {
if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) {
error(parameterDeclaration, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
}
@@ -7020,20 +7023,23 @@ module ts {
return;
}
function getCanonicalOverload(overloads: Declaration[], implementation: FunctionLikeDeclaration) {
// Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
// Error on all deviations from this canonical set of flags
// The caveat is that if some overloads are defined in lib.d.ts, we don't want to
// report the errors on those. To achieve this, we will say that the implementation is
// the canonical signature only if it is in the same container as the first overload
var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
}
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void {
// Error if some overloads have a flag that is not shared by all overloads. To find the
// deviations, we XOR someOverloadFlags with allOverloadFlags
var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
if (someButNotAllOverloadFlags !== 0) {
// Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
// Error on all deviations from this canonical set of flags
// The caveat is that if some overloads are defined in lib.d.ts, we don't want to
// report the errors on those. To achieve this, we will say that the implementation is
// the canonical signature only if it is in the same container as the first overload
var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
var canonicalFlags = implementationSharesContainerWithFirstOverload
? getEffectiveDeclarationFlags(implementation, flagsToCheck)
: getEffectiveDeclarationFlags(overloads[0], flagsToCheck);
var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
forEach(overloads, o => {
var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
if (deviation & NodeFlags.Export) {
@@ -7045,16 +7051,27 @@ module ts {
else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
}
else if (deviation & NodeFlags.QuestionMark) {
});
}
}
function checkQuestionTokenAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, someHaveQuestionToken: boolean, allHaveQuestionToken: boolean): void {
if (someHaveQuestionToken !== allHaveQuestionToken) {
var canonicalHasQuestionToken = hasQuestionToken(getCanonicalOverload(overloads, implementation));
forEach(overloads, o => {
var deviation = hasQuestionToken(o) !== canonicalHasQuestionToken;
if (deviation) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_optional_or_required);
}
});
}
}
var flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.QuestionMark;
var flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected;
var someNodeFlags: NodeFlags = 0;
var allNodeFlags = flagsToCheck;
var someHaveQuestionToken = false;
var allHaveQuestionToken = true;
var hasOverloads = false;
var bodyDeclaration: FunctionLikeDeclaration;
var lastSeenNonAmbientDeclaration: FunctionLikeDeclaration;
@@ -7128,6 +7145,8 @@ module ts {
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
someNodeFlags |= currentNodeFlags;
allNodeFlags &= currentNodeFlags;
someHaveQuestionToken = someHaveQuestionToken || hasQuestionToken(node);
allHaveQuestionToken = allHaveQuestionToken && hasQuestionToken(node);
if (node.body && bodyDeclaration) {
if (isConstructor) {
@@ -7176,6 +7195,8 @@ module ts {
if (hasOverloads) {
checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
if (bodyDeclaration) {
var signatures = getSignaturesOfSymbol(symbol);
var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
@@ -7725,13 +7746,14 @@ module ts {
function checkSwitchStatement(node: SwitchStatement) {
var expressionType = checkExpression(node.expression);
forEach(node.clauses, clause => {
if (fullTypeCheck && clause.expression) {
if (fullTypeCheck && clause.kind === SyntaxKind.CaseClause) {
var caseClause = <CaseClause>clause;
// TypeScript 1.0 spec (April 2014):5.9
// In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression.
var caseType = checkExpression(clause.expression);
var caseType = checkExpression(caseClause.expression);
if (!isTypeAssignableTo(expressionType, caseType)) {
// check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails
checkTypeAssignableTo(caseType, expressionType, clause.expression, /*headMessage*/ undefined);
checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined);
}
}
forEach(clause.statements, checkSourceElement);
@@ -7748,7 +7770,7 @@ module ts {
function checkTryStatement(node: TryStatement) {
checkBlock(node.tryBlock);
if (node.catchBlock) checkBlock(node.catchBlock);
if (node.catchClause) checkBlock(node.catchClause.block);
if (node.finallyBlock) checkBlock(node.finallyBlock);
}
@@ -8586,7 +8608,7 @@ module ts {
case SyntaxKind.ThrowStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.ClassDeclaration:
@@ -8634,10 +8656,6 @@ module ts {
}
}
function checkProgram() {
forEach(program.getSourceFiles(), checkSourceFile);
}
function getSortedDiagnostics(): Diagnostic[]{
Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode");
@@ -8650,12 +8668,11 @@ module ts {
}
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
if (sourceFile) {
checkSourceFile(sourceFile);
return filter(getSortedDiagnostics(), d => d.file === sourceFile);
}
checkProgram();
forEach(program.getSourceFiles(), checkSourceFile);
return getSortedDiagnostics();
}
@@ -8748,8 +8765,8 @@ module ts {
copySymbol(location.symbol, meaning);
}
break;
case SyntaxKind.CatchBlock:
if ((<CatchBlock>location).variable.text) {
case SyntaxKind.CatchClause:
if ((<CatchClause>location).name.text) {
copySymbol(location.symbol, meaning);
}
break;
@@ -9005,7 +9022,7 @@ module ts {
// This is necessary as an identifier in short-hand property assignment can contains two meaning:
// property name and property value.
if (location && location.kind === SyntaxKind.ShorthandPropertyAssignment) {
return resolveEntityName(location, (<ShortHandPropertyDeclaration>location).name, SymbolFlags.Value);
return resolveEntityName(location, (<ShorthandPropertyDeclaration>location).name, SymbolFlags.Value);
}
return undefined;
}
@@ -9173,9 +9190,9 @@ module ts {
return isImportResolvedToValue(getSymbolOfNode(node));
}
function hasSemanticErrors() {
function hasSemanticErrors(sourceFile?: SourceFile) {
// Return true if there is any semantic error in a file or globally
return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0;
return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0;
}
function isEmitBlocked(sourceFile?: SourceFile): boolean {
@@ -9293,7 +9310,6 @@ module ts {
function invokeEmitter(targetSourceFile?: SourceFile) {
var resolver = createResolver();
checkProgram();
return emitFiles(resolver, targetSourceFile);
}
+86 -52
View File
@@ -943,7 +943,7 @@ module ts {
if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) {
writeTextOfNode(currentSourceFile, node.name);
// If optional property emit ?
if (node.kind === SyntaxKind.Property && (node.flags & NodeFlags.QuestionMark)) {
if (node.kind === SyntaxKind.Property && hasQuestionToken(node)) {
write("?");
}
if (node.kind === SyntaxKind.Property && node.parent.kind === SyntaxKind.TypeLiteral) {
@@ -1124,7 +1124,7 @@ module ts {
}
else {
writeTextOfNode(currentSourceFile, node.name);
if (node.flags & NodeFlags.QuestionMark) {
if (hasQuestionToken(node)) {
write("?");
}
}
@@ -1252,11 +1252,11 @@ module ts {
function emitParameterDeclaration(node: ParameterDeclaration) {
increaseIndent();
emitJsDocComments(node);
if (node.flags & NodeFlags.Rest) {
if (node.dotDotDotToken) {
write("...");
}
writeTextOfNode(currentSourceFile, node.name);
if (node.initializer || (node.flags & NodeFlags.QuestionMark)) {
if (node.initializer || hasQuestionToken(node)) {
write("?");
}
decreaseIndent();
@@ -2142,8 +2142,8 @@ module ts {
return false;
case SyntaxKind.LabeledStatement:
return (<LabeledStatement>node.parent).label === node;
case SyntaxKind.CatchBlock:
return (<CatchBlock>node.parent).variable === node;
case SyntaxKind.CatchClause:
return (<CatchClause>node.parent).name === node;
}
}
@@ -2236,33 +2236,35 @@ module ts {
emitTrailingComments(node);
}
function emitShortHandPropertyAssignment(node: ShortHandPropertyDeclaration) {
function emitAsNormalPropertyAssignment() {
emitLeadingComments(node);
// Emit identifier as an identifier
emit(node.name);
write(": ");
// Even though this is stored as identified because it is in short-hand property assignment,
// treated it as expression
emitExpressionIdentifier(node.name);
emitTrailingComments(node);
}
function emitDownlevelShorthandPropertyAssignment(node: ShorthandPropertyDeclaration) {
emitLeadingComments(node);
// Emit identifier as an identifier
emit(node.name);
write(": ");
// Even though this is stored as identifier treat it as an expression
// Short-hand, { x }, is equivalent of normal form { x: x }
emitExpressionIdentifier(node.name);
emitTrailingComments(node);
}
if (compilerOptions.target < ScriptTarget.ES6) {
emitAsNormalPropertyAssignment();
function emitShorthandPropertyAssignment(node: ShorthandPropertyDeclaration) {
// If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example:
// module m {
// export var y;
// }
// module m {
// export var obj = { y };
// }
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
var prefix = resolver.getExpressionNamePrefix(node.name);
if (prefix) {
emitDownlevelShorthandPropertyAssignment(node);
}
else if (compilerOptions.target >= ScriptTarget.ES6) {
// If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment
var prefix = resolver.getExpressionNamePrefix(node.name);
if (prefix) {
emitAsNormalPropertyAssignment();
}
// If short-hand property has no prefix, emit it as short-hand.
else {
emitLeadingComments(node);
emit(node.name);
emitTrailingComments(node);
}
// If short-hand property has no prefix, emit it as short-hand.
else {
emitLeadingComments(node);
emit(node.name);
emitTrailingComments(node);
}
}
@@ -2624,7 +2626,7 @@ module ts {
function emitCaseOrDefaultClause(node: CaseOrDefaultClause) {
if (node.kind === SyntaxKind.CaseClause) {
write("case ");
emit(node.expression);
emit((<CaseClause>node).expression);
write(":");
}
else {
@@ -2650,7 +2652,7 @@ module ts {
function emitTryStatement(node: TryStatement) {
write("try ");
emit(node.tryBlock);
emit(node.catchBlock);
emit(node.catchClause);
if (node.finallyBlock) {
writeLine();
write("finally ");
@@ -2658,15 +2660,15 @@ module ts {
}
}
function emitCatchBlock(node: CatchBlock) {
function emitCatchClause(node: CatchClause) {
writeLine();
var endPos = emitToken(SyntaxKind.CatchKeyword, node.pos);
write(" ");
emitToken(SyntaxKind.OpenParenToken, endPos);
emit(node.variable);
emitToken(SyntaxKind.CloseParenToken, node.variable.end);
emit(node.name);
emitToken(SyntaxKind.CloseParenToken, node.name.end);
write(" ");
emitBlock(node);
emitBlock(node.block);
}
function emitDebuggerStatement(node: Node) {
@@ -3441,6 +3443,7 @@ module ts {
// Start new file on new line
writeLine();
emitDetachedComments(node);
// emit prologue directives prior to __extends
var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
if (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends) {
@@ -3472,6 +3475,8 @@ module ts {
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
}
emitLeadingComments(node.endOfFileToken);
}
function emitNode(node: Node): void {
@@ -3483,6 +3488,7 @@ module ts {
return emitPinnedOrTripleSlashComments(node);
}
// Check if the node can be emitted regardless of the ScriptTarget
switch (node.kind) {
case SyntaxKind.Identifier:
return emitIdentifier(<Identifier>node);
@@ -3521,8 +3527,6 @@ module ts {
return emitObjectLiteral(<ObjectLiteralExpression>node);
case SyntaxKind.PropertyAssignment:
return emitPropertyAssignment(<PropertyDeclaration>node);
case SyntaxKind.ShorthandPropertyAssignment:
return emitShortHandPropertyAssignment(<ShortHandPropertyDeclaration>node);
case SyntaxKind.ComputedPropertyName:
return emitComputedPropertyName(<ComputedPropertyName>node);
case SyntaxKind.PropertyAccessExpression:
@@ -3599,8 +3603,8 @@ module ts {
return emitThrowStatement(<ThrowStatement>node);
case SyntaxKind.TryStatement:
return emitTryStatement(<TryStatement>node);
case SyntaxKind.CatchBlock:
return emitCatchBlock(<CatchBlock>node);
case SyntaxKind.CatchClause:
return emitCatchClause(<CatchClause>node);
case SyntaxKind.DebuggerStatement:
return emitDebuggerStatement(node);
case SyntaxKind.VariableDeclaration:
@@ -3618,6 +3622,23 @@ module ts {
case SyntaxKind.SourceFile:
return emitSourceFile(<SourceFile>node);
}
// Emit node which needs to be emitted differently depended on ScriptTarget
if (compilerOptions.target < ScriptTarget.ES6) {
// Emit node down-level
switch (node.kind) {
case SyntaxKind.ShorthandPropertyAssignment:
return emitDownlevelShorthandPropertyAssignment(<ShorthandPropertyDeclaration>node);
}
}
else {
// Emit node natively
Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Invalid ScriptTarget. We should emit as ES6 or above");
switch (node.kind) {
case SyntaxKind.ShorthandPropertyAssignment:
return emitShorthandPropertyAssignment(<ShorthandPropertyDeclaration>node);
}
}
}
function hasDetachedComments(pos: number) {
@@ -3791,20 +3812,14 @@ module ts {
}
}
var hasSemanticErrors = resolver.hasSemanticErrors();
var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile);
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
if (!isEmitBlocked) {
emitJavaScript(jsFilePath, sourceFile);
if (!hasSemanticErrors && compilerOptions.declaration) {
writeDeclarationFile(jsFilePath, sourceFile);
}
}
}
var hasSemanticErrors: boolean = false;
var isEmitBlocked: boolean = false;
if (targetSourceFile === undefined) {
// No targetSourceFile is specified (e.g. calling emitter from batch compiler)
hasSemanticErrors = resolver.hasSemanticErrors();
isEmitBlocked = resolver.isEmitBlocked();
forEach(program.getSourceFiles(), sourceFile => {
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js");
@@ -3820,16 +3835,35 @@ module ts {
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
// If shouldEmitToOwnFile returns true or targetSourceFile is an external module file, then emit targetSourceFile in its own output file
hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile);
isEmitBlocked = resolver.isEmitBlocked(targetSourceFile);
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
// Otherwise, if --out is specified and targetSourceFile is not a declaration file,
// Emit all, non-external-module file, into one single output file
forEach(program.getSourceFiles(), sourceFile => {
if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) {
hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile);
isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile);
}
});
emitFile(compilerOptions.out);
}
}
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
if (!isEmitBlocked) {
emitJavaScript(jsFilePath, sourceFile);
if (!hasSemanticErrors && compilerOptions.declaration) {
writeDeclarationFile(jsFilePath, sourceFile);
}
}
}
// Sort and make the unique list of diagnostics
diagnostics.sort(compareDiagnostics);
diagnostics = deduplicateSortedDiagnostics(diagnostics);
+568 -455
View File
File diff suppressed because it is too large Load Diff
+37 -17
View File
@@ -208,7 +208,6 @@ module ts {
ThrowStatement,
TryStatement,
TryBlock,
CatchBlock,
FinallyBlock,
DebuggerStatement,
VariableDeclaration,
@@ -222,12 +221,16 @@ module ts {
ModuleBlock,
ImportDeclaration,
ExportAssignment,
// Module references
ExternalModuleReference,
// Clauses
CaseClause,
DefaultClause,
HeritageClause,
CatchClause,
// Property assignments
PropertyAssignment,
ShorthandPropertyAssignment,
@@ -254,7 +257,7 @@ module ts {
LastTypeNode = ParenthesizedType,
FirstPunctuation = OpenBraceToken,
LastPunctuation = CaretEqualsToken,
FirstToken = EndOfFileToken,
FirstToken = Unknown,
LastToken = TypeKeyword,
FirstTriviaToken = SingleLineCommentTrivia,
LastTriviaToken = WhitespaceTrivia,
@@ -272,8 +275,6 @@ module ts {
export const enum NodeFlags {
Export = 0x00000001, // Declarations
Ambient = 0x00000002, // Declarations
QuestionMark = 0x00000004, // Parameter/Property/Method
Rest = 0x00000008, // Parameter
Public = 0x00000010, // Property/Method
Private = 0x00000020, // Property/Method
Protected = 0x00000040, // Property/Method
@@ -318,7 +319,7 @@ module ts {
hasTrailingComma?: boolean;
}
export interface ModifiersArray extends Array<Node> {
export interface ModifiersArray extends NodeArray<Node> {
flags: number;
}
@@ -369,12 +370,15 @@ module ts {
}
export interface ParameterDeclaration extends Declaration {
dotDotDotToken?: Node;
name: Identifier;
questionToken?: Node;
type?: TypeNode | StringLiteralExpression;
initializer?: Expression;
}
export interface PropertyDeclaration extends Declaration, ClassElement {
questionToken?: Node;
type?: TypeNode;
initializer?: Expression;
}
@@ -382,8 +386,9 @@ module ts {
export type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration;
export type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration;
export interface ShortHandPropertyDeclaration extends Declaration {
export interface ShorthandPropertyDeclaration extends Declaration {
name: Identifier;
questionToken?: Node;
}
/**
@@ -398,6 +403,7 @@ module ts {
_functionLikeDeclarationBrand: any;
asteriskToken?: Node;
questionToken?: Node;
body?: Block | Expression;
}
@@ -668,11 +674,17 @@ module ts {
clauses: NodeArray<CaseOrDefaultClause>;
}
export interface CaseOrDefaultClause extends Node {
export interface CaseClause extends Node {
expression?: Expression;
statements: NodeArray<Statement>;
}
export interface DefaultClause extends Node {
statements: NodeArray<Statement>;
}
export type CaseOrDefaultClause = CaseClause | DefaultClause;
export interface LabeledStatement extends Statement {
label: Identifier;
statement: Statement;
@@ -684,13 +696,14 @@ module ts {
export interface TryStatement extends Statement {
tryBlock: Block;
catchBlock?: CatchBlock;
catchClause?: CatchClause;
finallyBlock?: Block;
}
export interface CatchBlock extends Block, Declaration {
variable: Identifier;
export interface CatchClause extends Declaration {
name: Identifier;
type?: TypeNode;
block: Block;
}
export interface ModuleElement extends Node {
@@ -773,6 +786,7 @@ module ts {
// Source files are declarations when they are external modules.
export interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
endOfFileToken: Node;
filename: string;
text: string;
@@ -782,17 +796,24 @@ module ts {
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
semanticDiagnostics: Diagnostic[];
// Diagnostics reported about the "///<reference" comments in the file.
referenceDiagnostics: Diagnostic[];
// Parse errors refer specifically to things the parser could not understand at all (like
// missing tokens, or tokens it didn't know how to deal with). Grammar errors are for
// things the parser understood, but either the ES6 or TS grammars do not allow (like
// putting an 'public' modifier on a 'class declaration').
// missing tokens, or tokens it didn't know how to deal with).
parseDiagnostics: Diagnostic[];
// Grammar errors are for things the parser understood, but either the ES6 or TS grammars
// do not allow (like putting an 'public' modifier on a 'class declaration').
grammarDiagnostics: Diagnostic[];
// Returns all
// Returns all syntactic diagnostics (i.e. the reference, parser and grammar diagnostics).
getSyntacticDiagnostics(): Diagnostic[];
// File level diagnostics reported by the binder.
semanticDiagnostics: Diagnostic[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node; // The first node that causes this file to be an external module
nodeCount: number;
@@ -861,7 +882,6 @@ module ts {
getIdentifierCount(): number;
getSymbolCount(): number;
getTypeCount(): number;
checkProgram(): void;
emitFiles(targetSourceFile?: SourceFile): EmitResult;
getParentOfSymbol(symbol: Symbol): Symbol;
getNarrowedTypeOfSymbol(symbol: Symbol, node: Node): Type;
@@ -973,7 +993,7 @@ module ts {
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
getEnumMemberValue(node: EnumMember): number;
hasSemanticErrors(): boolean;
hasSemanticErrors(sourceFile?: SourceFile): boolean;
isDeclarationVisible(node: Declaration): boolean;
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
+3 -4
View File
@@ -2217,11 +2217,10 @@ module FourSlash {
// TODO (drosen): We need to enforce checking on these tests.
var program = ts.createProgram([Harness.Compiler.fourslashFilename, fileName], { out: "fourslashTestOutput.js", noResolve: true }, host);
var checker = ts.createTypeChecker(program, /*fullTypeCheckMode*/ true);
checker.checkProgram();
var errs = program.getDiagnostics().concat(checker.getDiagnostics());
if (errs.length > 0) {
throw new Error('Error compiling ' + fileName + ': ' + errs.map(e => e.messageText).join('\r\n'));
var errors = program.getDiagnostics().concat(checker.getDiagnostics());
if (errors.length > 0) {
throw new Error('Error compiling ' + fileName + ': ' + errors.map(e => e.messageText).join('\r\n'));
}
checker.emitFiles();
result = result || ''; // Might have an empty fourslash file
-1
View File
@@ -801,7 +801,6 @@ module Harness {
useCaseSensitiveFileNames));
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
checker.checkProgram();
var isEmitBlocked = checker.isEmitBlocked();
+5 -3
View File
@@ -106,11 +106,13 @@ module ts.BreakpointResolver {
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
return spanInBlock(<Block>node);
case SyntaxKind.CatchClause:
return spanInBlock((<CatchClause>node).block);
case SyntaxKind.ExpressionStatement:
// span on the expression
return textSpan((<ExpressionStatement>node).expression);
@@ -297,7 +299,7 @@ module ts.BreakpointResolver {
function canHaveSpanInParameterDeclaration(parameter: ParameterDeclaration): boolean {
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
return !!parameter.initializer || !!(parameter.flags & NodeFlags.Rest) ||
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
!!(parameter.flags & NodeFlags.Public) || !!(parameter.flags & NodeFlags.Private);
}
@@ -420,7 +422,7 @@ module ts.BreakpointResolver {
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
return spanInNode((<Block>node.parent).statements[(<Block>node.parent).statements.length - 1]);;
+3 -3
View File
@@ -155,10 +155,11 @@ module ts.formatting {
case SyntaxKind.SourceFile:
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
return rangeContainsRange((<Block>parent).statements, node)
return rangeContainsRange((<Block>parent).statements, node);
case SyntaxKind.CatchClause:
return rangeContainsRange((<CatchClause>parent).block.statements, node);
}
return false;
@@ -898,7 +899,6 @@ module ts.formatting {
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
return true;
+2 -3
View File
@@ -525,7 +525,6 @@ module ts.formatting {
case SyntaxKind.SwitchStatement:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
@@ -581,7 +580,7 @@ module ts.formatting {
case SyntaxKind.EnumDeclaration:
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
@@ -603,7 +602,7 @@ module ts.formatting {
case SyntaxKind.WithStatement:
// TODO
// case SyntaxKind.ElseClause:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
return true;
+2 -2
View File
@@ -79,7 +79,8 @@ module ts {
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement) {
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
}
@@ -100,7 +101,6 @@ module ts {
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
+26 -51
View File
@@ -722,6 +722,9 @@ module ts {
public filename: string;
public text: string;
public statements: NodeArray<Statement>;
public endOfFileToken: Node;
// These methods will have their implementation provided by the implementation the
// compiler actually exports off of SourceFile.
public getLineAndCharacterFromPosition: (position: number) => LineAndCharacter;
@@ -732,15 +735,17 @@ module ts {
public amdDependencies: string[];
public amdModuleName: string;
public referencedFiles: FileReference[];
public referenceDiagnostics: Diagnostic[];
public parseDiagnostics: Diagnostic[];
public grammarDiagnostics: Diagnostic[];
public semanticDiagnostics: Diagnostic[];
public hasNoDefaultLib: boolean;
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
public nodeCount: number;
public identifierCount: number;
public symbolCount: number;
public statements: NodeArray<Statement>;
public version: string;
public isOpen: boolean;
public languageVersion: ScriptTarget;
@@ -2576,7 +2581,7 @@ module ts {
isFunction(containingNodeKind);
case SyntaxKind.OpenParenToken:
return containingNodeKind === SyntaxKind.CatchBlock ||
return containingNodeKind === SyntaxKind.CatchClause ||
isFunction(containingNodeKind);
case SyntaxKind.OpenBraceToken:
@@ -3567,8 +3572,8 @@ module ts {
else if (node.kind === SyntaxKind.TryStatement) {
var tryStatement = <TryStatement>node;
if (tryStatement.catchBlock) {
aggregate(tryStatement.catchBlock);
if (tryStatement.catchClause) {
aggregate(tryStatement.catchClause);
}
else {
// Exceptions thrown within a try block lacking a catch clause
@@ -3607,7 +3612,7 @@ module ts {
if (parent.kind === SyntaxKind.TryStatement) {
var tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === child && tryStatement.catchBlock) {
if (tryStatement.tryBlock === child && tryStatement.catchClause) {
return child;
}
}
@@ -3623,8 +3628,8 @@ module ts {
pushKeywordIf(keywords, tryStatement.getFirstToken(), SyntaxKind.TryKeyword);
if (tryStatement.catchBlock) {
pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), SyntaxKind.CatchKeyword);
if (tryStatement.catchClause) {
pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), SyntaxKind.CatchKeyword);
}
if (tryStatement.finallyBlock) {
@@ -3839,8 +3844,8 @@ module ts {
}
forEach(nodes, node => {
if (node.flags & modifierFlag) {
forEach(node.getChildren(), child => pushKeywordIf(keywords, child, modifier));
if (node.modifiers && node.flags & modifierFlag) {
forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier));
}
});
@@ -4670,18 +4675,14 @@ module ts {
function getEmitOutput(filename: string): EmitOutput {
synchronizeHostData();
filename = normalizeSlashes(filename);
var compilerOptions = program.getCompilerOptions();
var targetSourceFile = program.getSourceFile(filename); // Current selected file to be output
// If --out flag is not specified, shouldEmitToOwnFile is true. Otherwise shouldEmitToOwnFile is false.
var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions);
var emitOutput: EmitOutput = {
outputFiles: [],
emitOutputStatus: undefined,
};
var sourceFile = getSourceFile(filename);
var outputFiles: OutputFile[] = [];
function getEmitOutputWriter(filename: string, data: string, writeByteOrderMark: boolean) {
emitOutput.outputFiles.push({
outputFiles.push({
name: filename,
writeByteOrderMark: writeByteOrderMark,
text: data
@@ -4691,41 +4692,15 @@ module ts {
// Initialize writer for CompilerHost.writeFile
writer = getEmitOutputWriter;
var containSyntacticErrors = false;
if (shouldEmitToOwnFile) {
// Check only the file we want to emit
containSyntacticErrors = containErrors(program.getDiagnostics(targetSourceFile));
} else {
// Check the syntactic of only sourceFiles that will get emitted into single output
// Terminate the process immediately if we encounter a syntax error from one of the sourceFiles
containSyntacticErrors = forEach(program.getSourceFiles(), sourceFile => {
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
// If emit to a single file then we will check all files that do not have external module
return containErrors(program.getDiagnostics(sourceFile));
}
return false;
});
}
if (containSyntacticErrors) {
// If there is a syntax error, terminate the process and report outputStatus
emitOutput.emitOutputStatus = EmitReturnStatus.AllOutputGenerationSkipped;
// Reset writer back to undefined to make sure that we produce an error message
// if CompilerHost.writeFile is called when we are not in getEmitOutput
writer = undefined;
return emitOutput;
}
// Perform semantic and force a type check before emit to ensure that all symbols are updated
// EmitFiles will report if there is an error from TypeChecker and Emitter
// Depend whether we will have to emit into a single file or not either emit only selected file in the project, emit all files into a single file
var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile);
emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus;
var emitOutput = getFullTypeCheckChecker().emitFiles(sourceFile);
// Reset writer back to undefined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in getEmitOutput
writer = undefined;
return emitOutput;
return {
outputFiles,
emitOutputStatus: emitOutput.emitResultStatus
};
}
function getMeaningFromDeclaration(node: Node): SemanticMeaning {
@@ -4743,7 +4718,7 @@ module ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.CatchBlock:
case SyntaxKind.CatchClause:
return SemanticMeaning.Value;
case SyntaxKind.TypeParameter:
+7 -1
View File
@@ -912,6 +912,13 @@ module ts {
throw new Error("Invalid operation");
}
}
// Here we expose the TypeScript services as an external module
// so that it may be consumed easily like a node module.
declare var module: any;
if (typeof module !== "undefined" && module.exports) {
module.exports = ts;
}
}
@@ -919,4 +926,3 @@ module ts {
module TypeScript.Services {
export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
}
+1 -1
View File
@@ -524,7 +524,7 @@ module ts.SignatureHelp {
var displayParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
var isOptional = !!(parameter.valueDeclaration.flags & NodeFlags.QuestionMark);
var isOptional = hasQuestionToken(parameter.valueDeclaration);
return {
name: parameter.name,
+2 -2
View File
@@ -328,7 +328,6 @@ module ts.formatting {
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.ObjectLiteralExpression:
@@ -404,12 +403,13 @@ module ts.formatting {
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.SwitchStatement:
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.CatchClause:
return isCompletedNode((<CatchClause>n).block, sourceFile);
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.CallSignature:
case SyntaxKind.CallExpression:
-4
View File
@@ -280,10 +280,6 @@ module ts {
}
function nodeHasTokens(n: Node): boolean {
if (n.kind === SyntaxKind.Unknown) {
return false;
}
// If we have a token or node that has a non-zero width, it must have tokens.
// Note, that getWidth() does not take trivia into account.
return n.getWidth() !== 0;
@@ -1,14 +1,14 @@
tests/cases/compiler/accessorWithRestParam.ts(3,9): error TS1053: A 'set' accessor cannot have rest parameter.
tests/cases/compiler/accessorWithRestParam.ts(4,16): error TS1053: A 'set' accessor cannot have rest parameter.
tests/cases/compiler/accessorWithRestParam.ts(3,11): error TS1053: A 'set' accessor cannot have rest parameter.
tests/cases/compiler/accessorWithRestParam.ts(4,18): error TS1053: A 'set' accessor cannot have rest parameter.
==== tests/cases/compiler/accessorWithRestParam.ts (2 errors) ====
class C {
set X(...v) { }
~
~~~
!!! error TS1053: A 'set' accessor cannot have rest parameter.
static set X(...v2) { }
~
~~~
!!! error TS1053: A 'set' accessor cannot have rest parameter.
}
@@ -83,3 +83,8 @@ function foo(x, y, z) {
y = a;
z = a;
}
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = a;
// y = a;
// z = a;
//}
@@ -52,3 +52,4 @@ var c5c = (function () {
};
return c5c;
})();
//import c5c = require('');
@@ -105,3 +105,6 @@ var e6b;
(function (e6b) {
e6b.y = 2;
})(e6b || (e6b = {})); // should be error
// enum then import, messes with error reporting
//enum e7 { One }
//import e7 = require(''); // should be error
@@ -40,3 +40,5 @@ var e2 = (function () {
};
return e2;
})();
//enum then enum - covered
//enum then import - covered
@@ -93,3 +93,6 @@ var y5b;
})(y5b || (y5b = {})); // should be an error
function y5c() {
}
// function then import, messes with other errors
//function y6() { }
//import y6 = require('');
@@ -48,3 +48,4 @@ var i3;
i3[i3["One"] = 0] = "One";
})(i3 || (i3 = {}));
;
//import i4 = require(''); // error
@@ -268,3 +268,4 @@ var m6;
(function (m6) {
m6.y = 2;
})(m6 || (m6 = {}));
//import m6 = require('');
@@ -80,3 +80,6 @@ var x6b;
(function (x6b) {
x6b.y = 2;
})(x6b || (x6b = {})); // error
// var then import, messes with other error reporting
//var x7 = 1;
//import x7 = require('');
@@ -45,3 +45,37 @@ var Derived = (function (_super) {
})(Base);
var x = null;
var y = x[0];
/*
// Note - the equivalent for normal interface methods works fine:
interface A {
foo(): Base;
}
interface B<TBase extends Base> extends A {
foo(): TBase;
}
var b: B<Derived> = null;
var z: Derived = b.foo();
class Base { private a: string; }
class Derived extends Base { private b: string; }
// Note - commmenting "extends Foo" prevents the error
interface Foo {
[i: number]: Base;
}
interface FooOf<TBase extends Base> extends Foo {
[i: number]: TBase;
}
var x: FooOf<Derived> = null;
var y: Derived = x[0];
/*
// Note - the equivalent for normal interface methods works fine:
interface A {
foo(): Base;
}
interface B<TBase extends Base> extends A {
foo(): TBase;
}
var b: B<Derived> = null;
var z: Derived = b.foo();
@@ -2,19 +2,19 @@ tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Neithe
Property '2' is missing in type '[number, string]'.
tests/cases/conformance/types/tuple/castingTuple.ts(16,21): error TS2352: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other.
Property '2' is missing in type '[C, D]'.
tests/cases/conformance/types/tuple/castingTuple.ts(24,10): error TS2352: Neither type '[number, string]' nor type '[number, number]' is assignable to the other.
tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Neither type '[number, string]' nor type '[number, number]' is assignable to the other.
Types of property '1' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/castingTuple.ts(25,10): error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
Types of property '0' are incompatible.
Type 'C' is not assignable to type 'A'.
tests/cases/conformance/types/tuple/castingTuple.ts(26,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
tests/cases/conformance/types/tuple/castingTuple.ts(26,14): error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
tests/cases/conformance/types/tuple/castingTuple.ts(30,14): error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
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/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot find name 't4'.
tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'.
==== tests/cases/conformance/types/tuple/castingTuple.ts (7 errors) ====
@@ -41,10 +41,14 @@ tests/cases/conformance/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot
!!! error TS2352: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other.
!!! error TS2352: Property '2' is missing in type '[C, D]'.
var eleFromCDA1 = classCDATuple[2]; // A
var eleFromCDA2 = classCDATuple[5]; // {}
var eleFromCDA2 = classCDATuple[5]; // C | D | A
var t10: [E1, E2] = [E1.one, E2.one];
var t11 = <[number, number]>t10;
var array1 = <{}[]>emptyObjTuple;
var unionTuple: [C, string | number] = [new C(), "foo"];
var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
var unionTuple3: [number, string| number] = [10, "foo"];
var unionTuple4 = <[number, number]>unionTuple3;
// error
var t3 = <[number, number]>numStrTuple;
@@ -68,4 +72,5 @@ tests/cases/conformance/types/tuple/castingTuple.ts(27,1): error TS2304: Cannot
!!! error TS2352: Type 'string' is not assignable to type 'number'.
t4[2] = 10;
~~
!!! error TS2304: Cannot find name 't4'.
!!! error TS2304: Cannot find name 't4'.
+12 -3
View File
@@ -16,16 +16,21 @@ var classCDTuple: [C, D] = [new C(), new D()];
var interfaceIITuple = <[I, I]>classCDTuple;
var classCDATuple = <[C, D, A]>classCDTuple;
var eleFromCDA1 = classCDATuple[2]; // A
var eleFromCDA2 = classCDATuple[5]; // {}
var eleFromCDA2 = classCDATuple[5]; // C | D | A
var t10: [E1, E2] = [E1.one, E2.one];
var t11 = <[number, number]>t10;
var array1 = <{}[]>emptyObjTuple;
var unionTuple: [C, string | number] = [new C(), "foo"];
var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
var unionTuple3: [number, string| number] = [10, "foo"];
var unionTuple4 = <[number, number]>unionTuple3;
// error
var t3 = <[number, number]>numStrTuple;
var t9 = <[A, I]>classCDTuple;
var array1 = <number[]>numStrTuple;
t4[2] = 10;
t4[2] = 10;
//// [castingTuple.js]
var __extends = this.__extends || function (d, b) {
@@ -84,10 +89,14 @@ var classCDTuple = [new C(), new D()];
var interfaceIITuple = classCDTuple;
var classCDATuple = classCDTuple;
var eleFromCDA1 = classCDATuple[2]; // A
var eleFromCDA2 = classCDATuple[5]; // {}
var eleFromCDA2 = classCDATuple[5]; // C | D | A
var t10 = [0 /* one */, 0 /* one */];
var t11 = t10;
var array1 = emptyObjTuple;
var unionTuple = [new C(), "foo"];
var unionTuple2 = [new C(), "foo", new D()];
var unionTuple3 = [10, "foo"];
var unionTuple4 = unionTuple3;
// error
var t3 = numStrTuple;
var t9 = classCDTuple;
@@ -0,0 +1,22 @@
//// [commentEmitAtEndOfFile1.ts]
// test
var f = ''
// test #2
module foo {
function bar() { }
}
// test #3
module empty {
}
// test #4
//// [commentEmitAtEndOfFile1.js]
// test
var f = '';
// test #2
var foo;
(function (foo) {
function bar() {
}
})(foo || (foo = {}));
// test #4
@@ -0,0 +1,17 @@
=== tests/cases/compiler/commentEmitAtEndOfFile1.ts ===
// test
var f = ''
>f : string
// test #2
module foo {
>foo : typeof foo
function bar() { }
>bar : () => void
}
// test #3
module empty {
>empty : unknown
}
// test #4
@@ -6,3 +6,4 @@ Input:
//// [commentsAtEndOfFile1.js]
Input: ;
//Testing two
@@ -501,3 +501,4 @@ var r8b8 = b8 !== a8;
var r8b9 = b9 !== a9;
var r8b10 = b10 !== a10;
var r8b11 = b11 !== a11;
//var r8b12 = b12 !== a12;
@@ -427,3 +427,4 @@ var r8b6 = b6 !== a6;
var r8b7 = b7 !== a7;
var r8b8 = b8 !== a8;
var r8b9 = b9 !== a9;
//var r8b10 = b10 !== a10;
@@ -316,3 +316,4 @@ var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
var r8b6 = b6 !== a6;
//var r8b7 = b7 !== a7;
@@ -316,3 +316,4 @@ var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
var r8b6 = b6 !== a6;
//var r8b7 = b7 !== a7;
+45
View File
@@ -43,3 +43,48 @@ interface Array<T> {
var fa;
fa = fa.concat([0]);
fa = fa.concat(0);
/*
declare class C<T> {
public m(p1: C<C<T>>): C<T>;
//public p: T;
}
var c: C<number>;
var cc: C<C<number>>;
c = c.m(cc);
var n1: number[];
/*
interface Array<T> {
concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable
concat(...items: T[]): T[];
}
*/
var fa: number[];
fa = fa.concat([0]);
fa = fa.concat(0);
/*
declare class C<T> {
public m(p1: C<C<T>>): C<T>;
//public p: T;
}
var c: C<number>;
var cc: C<C<number>>;
c = c.m(cc);
@@ -20,6 +20,7 @@ condBoolean ? exprBoolean1 : exprBoolean2;
condBoolean ? exprNumber1 : exprNumber2;
condBoolean ? exprString1 : exprString2;
condBoolean ? exprIsObject1 : exprIsObject2;
condBoolean ? exprString1 : exprBoolean1; // union
//Cond is a boolean type literal
true ? exprAny1 : exprAny2;
@@ -27,6 +28,7 @@ false ? exprBoolean1 : exprBoolean2;
true ? exprNumber1 : exprNumber2;
false ? exprString1 : exprString2;
true ? exprIsObject1 : exprIsObject2;
true ? exprString1 : exprBoolean1; // union
//Cond is a boolean type expression
!true ? exprAny1 : exprAny2;
@@ -34,6 +36,7 @@ typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
2 > 1 ? exprNumber1 : exprNumber2;
null === undefined ? exprString1 : exprString2;
true || false ? exprIsObject1 : exprIsObject2;
null === undefined ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condBoolean ? exprAny1 : exprAny2;
@@ -41,18 +44,22 @@ var resultIsBoolean1 = condBoolean ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condBoolean ? exprNumber1 : exprNumber2;
var resultIsString1 = condBoolean ? exprString1 : exprString2;
var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union
var resultIsAny2 = true ? exprAny1 : exprAny2;
var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = true ? exprNumber1 : exprNumber2;
var resultIsString2 = false ? exprString1 : exprString2;
var resultIsObject2 = true ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union
var resultIsAny3 = !true ? exprAny1 : exprAny2;
var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2;
var resultIsString3 = null === undefined ? exprString1 : exprString2;
var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union
//// [conditionalOperatorConditionIsBooleanType.js]
@@ -74,31 +81,38 @@ condBoolean ? exprBoolean1 : exprBoolean2;
condBoolean ? exprNumber1 : exprNumber2;
condBoolean ? exprString1 : exprString2;
condBoolean ? exprIsObject1 : exprIsObject2;
condBoolean ? exprString1 : exprBoolean1; // union
//Cond is a boolean type literal
true ? exprAny1 : exprAny2;
false ? exprBoolean1 : exprBoolean2;
true ? exprNumber1 : exprNumber2;
false ? exprString1 : exprString2;
true ? exprIsObject1 : exprIsObject2;
true ? exprString1 : exprBoolean1; // union
//Cond is a boolean type expression
!true ? exprAny1 : exprAny2;
typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
2 > 1 ? exprNumber1 : exprNumber2;
null === undefined ? exprString1 : exprString2;
true || false ? exprIsObject1 : exprIsObject2;
null === undefined ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condBoolean ? exprAny1 : exprAny2;
var resultIsBoolean1 = condBoolean ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condBoolean ? exprNumber1 : exprNumber2;
var resultIsString1 = condBoolean ? exprString1 : exprString2;
var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union
var resultIsAny2 = true ? exprAny1 : exprAny2;
var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = true ? exprNumber1 : exprNumber2;
var resultIsString2 = false ? exprString1 : exprString2;
var resultIsObject2 = true ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union
var resultIsAny3 = !true ? exprAny1 : exprAny2;
var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2;
var resultIsString3 = null === undefined ? exprString1 : exprString2;
var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union
@@ -66,6 +66,12 @@ condBoolean ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
condBoolean ? exprString1 : exprBoolean1; // union
>condBoolean ? exprString1 : exprBoolean1 : string | boolean
>condBoolean : boolean
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a boolean type literal
true ? exprAny1 : exprAny2;
>true ? exprAny1 : exprAny2 : any
@@ -92,6 +98,11 @@ true ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
true ? exprString1 : exprBoolean1; // union
>true ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a boolean type expression
!true ? exprAny1 : exprAny2;
>!true ? exprAny1 : exprAny2 : any
@@ -125,6 +136,13 @@ true || false ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
null === undefined ? exprString1 : exprBoolean1; // union
>null === undefined ? exprString1 : exprBoolean1 : string | boolean
>null === undefined : boolean
>undefined : undefined
>exprString1 : string
>exprBoolean1 : boolean
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condBoolean ? exprAny1 : exprAny2;
>resultIsAny1 : any
@@ -161,6 +179,13 @@ var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean1 : string | boolean
>condBoolean ? exprString1 : exprBoolean1 : string | boolean
>condBoolean : boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny2 = true ? exprAny1 : exprAny2;
>resultIsAny2 : any
>true ? exprAny1 : exprAny2 : any
@@ -191,6 +216,18 @@ var resultIsObject2 = true ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean2 : string | boolean
>true ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean3 : string | boolean
>false ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny3 = !true ? exprAny1 : exprAny2;
>resultIsAny3 : any
>!true ? exprAny1 : exprAny2 : any
@@ -228,3 +265,11 @@ var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean4 : string | boolean
>typeof "123" === "string" ? exprString1 : exprBoolean1 : string | boolean
>typeof "123" === "string" : boolean
>typeof "123" : string
>exprString1 : string
>exprBoolean1 : boolean
@@ -20,6 +20,7 @@ condNumber ? exprBoolean1 : exprBoolean2;
condNumber ? exprNumber1 : exprNumber2;
condNumber ? exprString1 : exprString2;
condNumber ? exprIsObject1 : exprIsObject2;
condNumber ? exprString1 : exprBoolean1; // Union
//Cond is a number type literal
1 ? exprAny1 : exprAny2;
@@ -27,6 +28,7 @@ condNumber ? exprIsObject1 : exprIsObject2;
0.123456789 ? exprNumber1 : exprNumber2;
- 10000000000000 ? exprString1 : exprString2;
1000000000000 ? exprIsObject1 : exprIsObject2;
10000 ? exprString1 : exprBoolean1; // Union
//Cond is a number type expression
function foo() { return 1 };
@@ -37,6 +39,7 @@ var array = [1, 2, 3];
"string".length ? exprNumber1 : exprNumber2;
foo() ? exprString1 : exprString2;
foo() / array[1] ? exprIsObject1 : exprIsObject2;
foo() ? exprString1 : exprBoolean1; // Union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condNumber ? exprAny1 : exprAny2;
@@ -44,19 +47,21 @@ var resultIsBoolean1 = condNumber ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condNumber ? exprNumber1 : exprNumber2;
var resultIsString1 = condNumber ? exprString1 : exprString2;
var resultIsObject1 = condNumber ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condNumber ? exprString1 : exprBoolean1; // Union
var resultIsAny2 = 1 ? exprAny1 : exprAny2;
var resultIsBoolean2 = 0 ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = 0.123456789 ? exprNumber1 : exprNumber2;
var resultIsString2 = - 10000000000000 ? exprString1 : exprString2;
var resultIsObject2 = 1000000000000 ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = 10000 ? exprString1 : exprBoolean1; // Union
var resultIsAny3 = 1 * 0 ? exprAny1 : exprAny2;
var resultIsBoolean3 = 1 + 1 ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = "string".length ? exprNumber1 : exprNumber2;
var resultIsString3 = foo() ? exprString1 : exprString2;
var resultIsObject3 = foo() / array[1] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = foo() / array[1] ? exprString1 : exprBoolean1; // Union
//// [conditionalOperatorConditionIsNumberType.js]
//Cond ? Expr1 : Expr2, Cond is of number type, Expr1 and Expr2 have the same type
@@ -77,12 +82,14 @@ condNumber ? exprBoolean1 : exprBoolean2;
condNumber ? exprNumber1 : exprNumber2;
condNumber ? exprString1 : exprString2;
condNumber ? exprIsObject1 : exprIsObject2;
condNumber ? exprString1 : exprBoolean1; // Union
//Cond is a number type literal
1 ? exprAny1 : exprAny2;
0 ? exprBoolean1 : exprBoolean2;
0.123456789 ? exprNumber1 : exprNumber2;
-10000000000000 ? exprString1 : exprString2;
1000000000000 ? exprIsObject1 : exprIsObject2;
10000 ? exprString1 : exprBoolean1; // Union
//Cond is a number type expression
function foo() {
return 1;
@@ -94,19 +101,23 @@ var array = [1, 2, 3];
"string".length ? exprNumber1 : exprNumber2;
foo() ? exprString1 : exprString2;
foo() / array[1] ? exprIsObject1 : exprIsObject2;
foo() ? exprString1 : exprBoolean1; // Union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condNumber ? exprAny1 : exprAny2;
var resultIsBoolean1 = condNumber ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condNumber ? exprNumber1 : exprNumber2;
var resultIsString1 = condNumber ? exprString1 : exprString2;
var resultIsObject1 = condNumber ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condNumber ? exprString1 : exprBoolean1; // Union
var resultIsAny2 = 1 ? exprAny1 : exprAny2;
var resultIsBoolean2 = 0 ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = 0.123456789 ? exprNumber1 : exprNumber2;
var resultIsString2 = -10000000000000 ? exprString1 : exprString2;
var resultIsObject2 = 1000000000000 ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = 10000 ? exprString1 : exprBoolean1; // Union
var resultIsAny3 = 1 * 0 ? exprAny1 : exprAny2;
var resultIsBoolean3 = 1 + 1 ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = "string".length ? exprNumber1 : exprNumber2;
var resultIsString3 = foo() ? exprString1 : exprString2;
var resultIsObject3 = foo() / array[1] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = foo() / array[1] ? exprString1 : exprBoolean1; // Union
@@ -66,6 +66,12 @@ condNumber ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
condNumber ? exprString1 : exprBoolean1; // Union
>condNumber ? exprString1 : exprBoolean1 : string | boolean
>condNumber : number
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a number type literal
1 ? exprAny1 : exprAny2;
>1 ? exprAny1 : exprAny2 : any
@@ -93,6 +99,11 @@ condNumber ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
10000 ? exprString1 : exprBoolean1; // Union
>10000 ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a number type expression
function foo() { return 1 };
>foo : () => number
@@ -137,6 +148,13 @@ foo() / array[1] ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
foo() ? exprString1 : exprBoolean1; // Union
>foo() ? exprString1 : exprBoolean1 : string | boolean
>foo() : number
>foo : () => number
>exprString1 : string
>exprBoolean1 : boolean
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condNumber ? exprAny1 : exprAny2;
>resultIsAny1 : any
@@ -173,6 +191,13 @@ var resultIsObject1 = condNumber ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean1 = condNumber ? exprString1 : exprBoolean1; // Union
>resultIsStringOrBoolean1 : string | boolean
>condNumber ? exprString1 : exprBoolean1 : string | boolean
>condNumber : number
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny2 = 1 ? exprAny1 : exprAny2;
>resultIsAny2 : any
>1 ? exprAny1 : exprAny2 : any
@@ -204,6 +229,12 @@ var resultIsObject2 = 1000000000000 ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean2 = 10000 ? exprString1 : exprBoolean1; // Union
>resultIsStringOrBoolean2 : string | boolean
>10000 ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny3 = 1 * 0 ? exprAny1 : exprAny2;
>resultIsAny3 : any
>1 * 0 ? exprAny1 : exprAny2 : any
@@ -245,3 +276,14 @@ var resultIsObject3 = foo() / array[1] ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean3 = foo() / array[1] ? exprString1 : exprBoolean1; // Union
>resultIsStringOrBoolean3 : string | boolean
>foo() / array[1] ? exprString1 : exprBoolean1 : string | boolean
>foo() / array[1] : number
>foo() : number
>foo : () => number
>array[1] : number
>array : number[]
>exprString1 : string
>exprBoolean1 : boolean
@@ -23,6 +23,7 @@ condObject ? exprBoolean1 : exprBoolean2;
condObject ? exprNumber1 : exprNumber2;
condObject ? exprString1 : exprString2;
condObject ? exprIsObject1 : exprIsObject2;
condObject ? exprString1 : exprBoolean1; // union
//Cond is an object type literal
((a: string) => a.length) ? exprAny1 : exprAny2;
@@ -30,6 +31,7 @@ condObject ? exprIsObject1 : exprIsObject2;
({}) ? exprNumber1 : exprNumber2;
({ a: 1, b: "s" }) ? exprString1 : exprString2;
({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
({ a: 1, b: "s" }) ? exprString1: exprBoolean1; // union
//Cond is an object type expression
foo() ? exprAny1 : exprAny2;
@@ -37,6 +39,7 @@ new Date() ? exprBoolean1 : exprBoolean2;
new C() ? exprNumber1 : exprNumber2;
C.doIt() ? exprString1 : exprString2;
condObject.valueOf() ? exprIsObject1 : exprIsObject2;
new Date() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condObject ? exprAny1 : exprAny2;
@@ -44,18 +47,21 @@ var resultIsBoolean1 = condObject ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condObject ? exprNumber1 : exprNumber2;
var resultIsString1 = condObject ? exprString1 : exprString2;
var resultIsObject1 = condObject ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condObject ? exprString1 : exprBoolean1; // union
var resultIsAny2 = ((a: string) => a.length) ? exprAny1 : exprAny2;
var resultIsBoolean2 = ((a: string) => a.length) ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = ({}) ? exprNumber1 : exprNumber2;
var resultIsString2 = ({ a: 1, b: "s" }) ? exprString1 : exprString2;
var resultIsObject2 = ({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = ({ a: 1, b: "s" }) ? exprString1 : exprBoolean1; // union
var resultIsAny3 = foo() ? exprAny1 : exprAny2;
var resultIsBoolean3 = new Date() ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = new C() ? exprNumber1 : exprNumber2;
var resultIsString3 = C.doIt() ? exprString1 : exprString2;
var resultIsObject3 = condObject.valueOf() ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = C.doIt() ? exprString1 : exprBoolean1; // union
//// [conditionalOperatorConditionIsObjectType.js]
@@ -86,31 +92,37 @@ condObject ? exprBoolean1 : exprBoolean2;
condObject ? exprNumber1 : exprNumber2;
condObject ? exprString1 : exprString2;
condObject ? exprIsObject1 : exprIsObject2;
condObject ? exprString1 : exprBoolean1; // union
//Cond is an object type literal
(function (a) { return a.length; }) ? exprAny1 : exprAny2;
(function (a) { return a.length; }) ? exprBoolean1 : exprBoolean2;
({}) ? exprNumber1 : exprNumber2;
({ a: 1, b: "s" }) ? exprString1 : exprString2;
({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
({ a: 1, b: "s" }) ? exprString1 : exprBoolean1; // union
//Cond is an object type expression
foo() ? exprAny1 : exprAny2;
new Date() ? exprBoolean1 : exprBoolean2;
new C() ? exprNumber1 : exprNumber2;
C.doIt() ? exprString1 : exprString2;
condObject.valueOf() ? exprIsObject1 : exprIsObject2;
new Date() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condObject ? exprAny1 : exprAny2;
var resultIsBoolean1 = condObject ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condObject ? exprNumber1 : exprNumber2;
var resultIsString1 = condObject ? exprString1 : exprString2;
var resultIsObject1 = condObject ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condObject ? exprString1 : exprBoolean1; // union
var resultIsAny2 = (function (a) { return a.length; }) ? exprAny1 : exprAny2;
var resultIsBoolean2 = (function (a) { return a.length; }) ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = ({}) ? exprNumber1 : exprNumber2;
var resultIsString2 = ({ a: 1, b: "s" }) ? exprString1 : exprString2;
var resultIsObject2 = ({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = ({ a: 1, b: "s" }) ? exprString1 : exprBoolean1; // union
var resultIsAny3 = foo() ? exprAny1 : exprAny2;
var resultIsBoolean3 = new Date() ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = new C() ? exprNumber1 : exprNumber2;
var resultIsString3 = C.doIt() ? exprString1 : exprString2;
var resultIsObject3 = condObject.valueOf() ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = C.doIt() ? exprString1 : exprBoolean1; // union
@@ -74,6 +74,12 @@ condObject ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
condObject ? exprString1 : exprBoolean1; // union
>condObject ? exprString1 : exprBoolean1 : string | boolean
>condObject : Object
>exprString1 : string
>exprBoolean1 : boolean
//Cond is an object type literal
((a: string) => a.length) ? exprAny1 : exprAny2;
>((a: string) => a.length) ? exprAny1 : exprAny2 : any
@@ -122,6 +128,15 @@ condObject ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
({ a: 1, b: "s" }) ? exprString1: exprBoolean1; // union
>({ a: 1, b: "s" }) ? exprString1: exprBoolean1 : string | boolean
>({ a: 1, b: "s" }) : { a: number; b: string; }
>{ a: 1, b: "s" } : { a: number; b: string; }
>a : number
>b : string
>exprString1 : string
>exprBoolean1 : boolean
//Cond is an object type expression
foo() ? exprAny1 : exprAny2;
>foo() ? exprAny1 : exprAny2 : any
@@ -162,6 +177,13 @@ condObject.valueOf() ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
new Date() ? exprString1 : exprBoolean1; // union
>new Date() ? exprString1 : exprBoolean1 : string | boolean
>new Date() : Date
>Date : DateConstructor
>exprString1 : string
>exprBoolean1 : boolean
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condObject ? exprAny1 : exprAny2;
>resultIsAny1 : any
@@ -198,6 +220,13 @@ var resultIsObject1 = condObject ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean1 = condObject ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean1 : string | boolean
>condObject ? exprString1 : exprBoolean1 : string | boolean
>condObject : Object
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny2 = ((a: string) => a.length) ? exprAny1 : exprAny2;
>resultIsAny2 : any
>((a: string) => a.length) ? exprAny1 : exprAny2 : any
@@ -250,6 +279,16 @@ var resultIsObject2 = ({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean2 = ({ a: 1, b: "s" }) ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean2 : string | boolean
>({ a: 1, b: "s" }) ? exprString1 : exprBoolean1 : string | boolean
>({ a: 1, b: "s" }) : { a: number; b: string; }
>{ a: 1, b: "s" } : { a: number; b: string; }
>a : number
>b : string
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny3 = foo() ? exprAny1 : exprAny2;
>resultIsAny3 : any
>foo() ? exprAny1 : exprAny2 : any
@@ -294,3 +333,13 @@ var resultIsObject3 = condObject.valueOf() ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean3 = C.doIt() ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean3 : string | boolean
>C.doIt() ? exprString1 : exprBoolean1 : string | boolean
>C.doIt() : void
>C.doIt : () => void
>C : typeof C
>doIt : () => void
>exprString1 : string
>exprBoolean1 : boolean
@@ -21,6 +21,7 @@ condAny ? exprBoolean1 : exprBoolean2;
condAny ? exprNumber1 : exprNumber2;
condAny ? exprString1 : exprString2;
condAny ? exprIsObject1 : exprIsObject2;
condAny ? exprString1 : exprBoolean1; // union
//Cond is an any type literal
null ? exprAny1 : exprAny2;
@@ -28,6 +29,7 @@ null ? exprBoolean1 : exprBoolean2;
undefined ? exprNumber1 : exprNumber2;
[null, undefined] ? exprString1 : exprString2;
[null, undefined] ? exprIsObject1 : exprIsObject2;
undefined ? exprString1 : exprBoolean1; // union
//Cond is an any type expression
x.doSomeThing() ? exprAny1 : exprAny2;
@@ -35,6 +37,7 @@ x("x") ? exprBoolean1 : exprBoolean2;
x(x) ? exprNumber1 : exprNumber2;
x("x") ? exprString1 : exprString2;
x.doSomeThing() ? exprIsObject1 : exprIsObject2;
x.doSomeThing() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condAny ? exprAny1 : exprAny2;
@@ -42,19 +45,23 @@ var resultIsBoolean1 = condAny ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condAny ? exprNumber1 : exprNumber2;
var resultIsString1 = condAny ? exprString1 : exprString2;
var resultIsObject1 = condAny ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condAny ? exprString1 : exprBoolean1; // union
var resultIsAny2 = null ? exprAny1 : exprAny2;
var resultIsBoolean2 = null ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = undefined ? exprNumber1 : exprNumber2;
var resultIsString2 = [null, undefined] ? exprString1 : exprString2;
var resultIsObject2 = [null, undefined] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = null ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean3 = undefined ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean4 = [null, undefined] ? exprString1 : exprBoolean1; // union
var resultIsAny3 = x.doSomeThing() ? exprAny1 : exprAny2;
var resultIsBoolean3 = x("x") ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = x(x) ? exprNumber1 : exprNumber2;
var resultIsString3 = x("x") ? exprString1 : exprString2;
var resultIsObject3 = x.doSomeThing() ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean5 = x.doSomeThing() ? exprString1 : exprBoolean1; // union
//// [conditionalOperatorConditoinIsAnyType.js]
//Cond ? Expr1 : Expr2, Cond is of any type, Expr1 and Expr2 have the same type
@@ -76,31 +83,39 @@ condAny ? exprBoolean1 : exprBoolean2;
condAny ? exprNumber1 : exprNumber2;
condAny ? exprString1 : exprString2;
condAny ? exprIsObject1 : exprIsObject2;
condAny ? exprString1 : exprBoolean1; // union
//Cond is an any type literal
null ? exprAny1 : exprAny2;
null ? exprBoolean1 : exprBoolean2;
undefined ? exprNumber1 : exprNumber2;
[null, undefined] ? exprString1 : exprString2;
[null, undefined] ? exprIsObject1 : exprIsObject2;
undefined ? exprString1 : exprBoolean1; // union
//Cond is an any type expression
x.doSomeThing() ? exprAny1 : exprAny2;
x("x") ? exprBoolean1 : exprBoolean2;
x(x) ? exprNumber1 : exprNumber2;
x("x") ? exprString1 : exprString2;
x.doSomeThing() ? exprIsObject1 : exprIsObject2;
x.doSomeThing() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condAny ? exprAny1 : exprAny2;
var resultIsBoolean1 = condAny ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condAny ? exprNumber1 : exprNumber2;
var resultIsString1 = condAny ? exprString1 : exprString2;
var resultIsObject1 = condAny ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condAny ? exprString1 : exprBoolean1; // union
var resultIsAny2 = null ? exprAny1 : exprAny2;
var resultIsBoolean2 = null ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = undefined ? exprNumber1 : exprNumber2;
var resultIsString2 = [null, undefined] ? exprString1 : exprString2;
var resultIsObject2 = [null, undefined] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = null ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean3 = undefined ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean4 = [null, undefined] ? exprString1 : exprBoolean1; // union
var resultIsAny3 = x.doSomeThing() ? exprAny1 : exprAny2;
var resultIsBoolean3 = x("x") ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = x(x) ? exprNumber1 : exprNumber2;
var resultIsString3 = x("x") ? exprString1 : exprString2;
var resultIsObject3 = x.doSomeThing() ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean5 = x.doSomeThing() ? exprString1 : exprBoolean1; // union
@@ -69,6 +69,12 @@ condAny ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
condAny ? exprString1 : exprBoolean1; // union
>condAny ? exprString1 : exprBoolean1 : string | boolean
>condAny : any
>exprString1 : string
>exprBoolean1 : boolean
//Cond is an any type literal
null ? exprAny1 : exprAny2;
>null ? exprAny1 : exprAny2 : any
@@ -100,6 +106,12 @@ undefined ? exprNumber1 : exprNumber2;
>exprIsObject1 : Object
>exprIsObject2 : Object
undefined ? exprString1 : exprBoolean1; // union
>undefined ? exprString1 : exprBoolean1 : string | boolean
>undefined : undefined
>exprString1 : string
>exprBoolean1 : boolean
//Cond is an any type expression
x.doSomeThing() ? exprAny1 : exprAny2;
>x.doSomeThing() ? exprAny1 : exprAny2 : any
@@ -141,6 +153,15 @@ x.doSomeThing() ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
x.doSomeThing() ? exprString1 : exprBoolean1; // union
>x.doSomeThing() ? exprString1 : exprBoolean1 : string | boolean
>x.doSomeThing() : any
>x.doSomeThing : any
>x : any
>doSomeThing : any
>exprString1 : string
>exprBoolean1 : boolean
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condAny ? exprAny1 : exprAny2;
>resultIsAny1 : any
@@ -177,6 +198,13 @@ var resultIsObject1 = condAny ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean1 = condAny ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean1 : string | boolean
>condAny ? exprString1 : exprBoolean1 : string | boolean
>condAny : any
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny2 = null ? exprAny1 : exprAny2;
>resultIsAny2 : any
>null ? exprAny1 : exprAny2 : any
@@ -212,6 +240,27 @@ var resultIsObject2 = [null, undefined] ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean2 = null ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean2 : string | boolean
>null ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsStringOrBoolean3 = undefined ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean3 : string | boolean
>undefined ? exprString1 : exprBoolean1 : string | boolean
>undefined : undefined
>exprString1 : string
>exprBoolean1 : boolean
var resultIsStringOrBoolean4 = [null, undefined] ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean4 : string | boolean
>[null, undefined] ? exprString1 : exprBoolean1 : string | boolean
>[null, undefined] : null[]
>undefined : undefined
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny3 = x.doSomeThing() ? exprAny1 : exprAny2;
>resultIsAny3 : any
>x.doSomeThing() ? exprAny1 : exprAny2 : any
@@ -257,3 +306,13 @@ var resultIsObject3 = x.doSomeThing() ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean5 = x.doSomeThing() ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean5 : string | boolean
>x.doSomeThing() ? exprString1 : exprBoolean1 : string | boolean
>x.doSomeThing() : any
>x.doSomeThing : any
>x : any
>doSomeThing : any
>exprString1 : string
>exprBoolean1 : boolean
@@ -20,6 +20,7 @@ condString ? exprBoolean1 : exprBoolean2;
condString ? exprNumber1 : exprNumber2;
condString ? exprString1 : exprString2;
condString ? exprIsObject1 : exprIsObject2;
condString ? exprString1 : exprBoolean1; // union
//Cond is a string type literal
"" ? exprAny1 : exprAny2;
@@ -27,6 +28,7 @@ condString ? exprIsObject1 : exprIsObject2;
'c' ? exprNumber1 : exprNumber2;
'string' ? exprString1 : exprString2;
" " ? exprIsObject1 : exprIsObject2;
"hello " ? exprString1 : exprBoolean1; // union
//Cond is a string type expression
function foo() { return "string" };
@@ -37,6 +39,7 @@ condString.toUpperCase ? exprBoolean1 : exprBoolean2;
condString + "string" ? exprNumber1 : exprNumber2;
foo() ? exprString1 : exprString2;
array[1] ? exprIsObject1 : exprIsObject2;
foo() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condString ? exprAny1 : exprAny2;
@@ -44,19 +47,22 @@ var resultIsBoolean1 = condString ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condString ? exprNumber1 : exprNumber2;
var resultIsString1 = condString ? exprString1 : exprString2;
var resultIsObject1 = condString ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1; // union
var resultIsAny2 = "" ? exprAny1 : exprAny2;
var resultIsBoolean2 = "string" ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = 'c' ? exprNumber1 : exprNumber2;
var resultIsString2 = 'string' ? exprString1 : exprString2;
var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union
var resultIsAny3 = typeof condString ? exprAny1 : exprAny2;
var resultIsBoolean3 = condString.toUpperCase ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = condString + "string" ? exprNumber1 : exprNumber2;
var resultIsString3 = foo() ? exprString1 : exprString2;
var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean4 = condString.toUpperCase ? exprString1 : exprBoolean1; // union
//// [conditionalOperatorConditoinIsStringType.js]
//Cond ? Expr1 : Expr2, Cond is of string type, Expr1 and Expr2 have the same type
@@ -77,12 +83,14 @@ condString ? exprBoolean1 : exprBoolean2;
condString ? exprNumber1 : exprNumber2;
condString ? exprString1 : exprString2;
condString ? exprIsObject1 : exprIsObject2;
condString ? exprString1 : exprBoolean1; // union
//Cond is a string type literal
"" ? exprAny1 : exprAny2;
"string" ? exprBoolean1 : exprBoolean2;
'c' ? exprNumber1 : exprNumber2;
'string' ? exprString1 : exprString2;
" " ? exprIsObject1 : exprIsObject2;
"hello " ? exprString1 : exprBoolean1; // union
//Cond is a string type expression
function foo() {
return "string";
@@ -94,19 +102,24 @@ condString.toUpperCase ? exprBoolean1 : exprBoolean2;
condString + "string" ? exprNumber1 : exprNumber2;
foo() ? exprString1 : exprString2;
array[1] ? exprIsObject1 : exprIsObject2;
foo() ? exprString1 : exprBoolean1; // union
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condString ? exprAny1 : exprAny2;
var resultIsBoolean1 = condString ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condString ? exprNumber1 : exprNumber2;
var resultIsString1 = condString ? exprString1 : exprString2;
var resultIsObject1 = condString ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1; // union
var resultIsAny2 = "" ? exprAny1 : exprAny2;
var resultIsBoolean2 = "string" ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = 'c' ? exprNumber1 : exprNumber2;
var resultIsString2 = 'string' ? exprString1 : exprString2;
var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union
var resultIsAny3 = typeof condString ? exprAny1 : exprAny2;
var resultIsBoolean3 = condString.toUpperCase ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = condString + "string" ? exprNumber1 : exprNumber2;
var resultIsString3 = foo() ? exprString1 : exprString2;
var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union
var resultIsStringOrBoolean4 = condString.toUpperCase ? exprString1 : exprBoolean1; // union
@@ -66,6 +66,12 @@ condString ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
condString ? exprString1 : exprBoolean1; // union
>condString ? exprString1 : exprBoolean1 : string | boolean
>condString : string
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a string type literal
"" ? exprAny1 : exprAny2;
>"" ? exprAny1 : exprAny2 : any
@@ -92,6 +98,11 @@ condString ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
"hello " ? exprString1 : exprBoolean1; // union
>"hello " ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
//Cond is a string type expression
function foo() { return "string" };
>foo : () => string
@@ -136,6 +147,13 @@ array[1] ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
foo() ? exprString1 : exprBoolean1; // union
>foo() ? exprString1 : exprBoolean1 : string | boolean
>foo() : string
>foo : () => string
>exprString1 : string
>exprBoolean1 : boolean
//Results shoud be same as Expr1 and Expr2
var resultIsAny1 = condString ? exprAny1 : exprAny2;
>resultIsAny1 : any
@@ -172,6 +190,13 @@ var resultIsObject1 = condString ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean1 : string | boolean
>condString ? exprString1 : exprBoolean1 : string | boolean
>condString : string
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny2 = "" ? exprAny1 : exprAny2;
>resultIsAny2 : any
>"" ? exprAny1 : exprAny2 : any
@@ -202,6 +227,12 @@ var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean2 : string | boolean
>"hello" ? exprString1 : exprBoolean1 : string | boolean
>exprString1 : string
>exprBoolean1 : boolean
var resultIsAny3 = typeof condString ? exprAny1 : exprAny2;
>resultIsAny3 : any
>typeof condString ? exprAny1 : exprAny2 : any
@@ -243,3 +274,20 @@ var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2;
>exprIsObject1 : Object
>exprIsObject2 : Object
var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean3 : string | boolean
>typeof condString ? exprString1 : exprBoolean1 : string | boolean
>typeof condString : string
>condString : string
>exprString1 : string
>exprBoolean1 : boolean
var resultIsStringOrBoolean4 = condString.toUpperCase ? exprString1 : exprBoolean1; // union
>resultIsStringOrBoolean4 : string | boolean
>condString.toUpperCase ? exprString1 : exprBoolean1 : string | boolean
>condString.toUpperCase : () => string
>condString : string
>toUpperCase : () => string
>exprString1 : string
>exprBoolean1 : boolean
@@ -4,13 +4,13 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'B'.
Type 'A' is not assignable to type 'B'.
Property 'propertyB' is missing in type 'A'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(18,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => number'.
Type '(n: X) => string' is not assignable to type '(t: X) => number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => string'.
Type '(m: X) => number' is not assignable to type '(t: X) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
Type 'number' is not assignable to type 'boolean'.
@@ -40,6 +40,7 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou
!!! error TS2322: Type 'A | B' is not assignable to type 'B'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: Property 'propertyB' is missing in type 'A'.
var result31: A | B = true ? a : b;
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
@@ -55,4 +56,6 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou
~~~~~~~
!!! error TS2322: Type '((m: X) => number) | ((n: X) => string)' is not assignable to type '(t: X) => boolean'.
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => boolean'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
@@ -15,10 +15,13 @@ var result1 = true ? a : b;
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
var result2: A = true ? a : b;
var result3: B = true ? a : b;
var result31: A | B = true ? a : b;
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
//// [conditionalOperatorWithoutIdenticalBCT.js]
var __extends = this.__extends || function (d, b) {
@@ -59,6 +62,8 @@ var result1 = true ? a : b;
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
var result2 = true ? a : b;
var result3 = true ? a : b;
var result31 = true ? a : b;
var result4 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; };
var result5 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; };
var result6 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; };
var result61 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; };
@@ -25,3 +25,13 @@
//// [conformanceFunctionOverloads.js]
// Function overloads do not emit code
// Function overload signature with optional parameter
// Function overload signature with optional parameter
// Function overloads with generic and non-generic overloads
// Function overloads whose only difference is returning different unconstrained generic parameters
// Function overloads whose only difference is returning different constrained generic parameters
// Function overloads that differ only by type parameter constraints
// Function overloads with matching accessibility
// Function overloads with matching export
// Function overloads with more params than implementation signature
// Function overloads where return types are same infinitely recursive type reference
@@ -4,21 +4,27 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232
Type 'string | number | boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(8,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(11,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
Types of property '0' are incompatible.
Type '{}' is not assignable to type '{ a: string; }'.
Property 'a' is missing in type '{}'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(12,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'.
Property '2' is missing in type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'.
Types of property 'pop' are incompatible.
Type '() => string | number' is not assignable to type '() => string'.
Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(24,1): error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'.
Property '2' is missing in type '[C, string | number]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'.
Types of property '1' are incompatible.
Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (5 errors) ====
==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (7 errors) ====
// no error
var numStrTuple: [number, string] = [5, "hello"];
var numStrTuple2: [number, string] = [5, "foo", true];
@@ -32,6 +38,13 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS23
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
class C { }
class D { }
var unionTuple: [C, string | number] = [new C(), "foo"];
var unionTuple1: [C, string | number] = [new C(), "foo"];
var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
var unionTuple3: [number, string| number] = [10, "foo"];
numStrTuple = numStrTuple2;
numStrTuple = numStrBoolTuple;
~~~~~~~~~~~
@@ -55,4 +68,16 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS23
!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
unionTuple = unionTuple1;
unionTuple = unionTuple2;
unionTuple2 = unionTuple;
~~~~~~~~~~~
!!! error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'.
!!! error TS2322: Property '2' is missing in type '[C, string | number]'.
numStrTuple = unionTuple3;
~~~~~~~~~~~
!!! error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'.
!!! error TS2322: Types of property '1' are incompatible.
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -5,6 +5,13 @@ var numStrTuple2: [number, string] = [5, "foo", true];
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
class C { }
class D { }
var unionTuple: [C, string | number] = [new C(), "foo"];
var unionTuple1: [C, string | number] = [new C(), "foo"];
var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
var unionTuple3: [number, string| number] = [10, "foo"];
numStrTuple = numStrTuple2;
numStrTuple = numStrBoolTuple;
@@ -12,7 +19,11 @@ numStrTuple = numStrBoolTuple;
objNumTuple = [ {}, 5];
numStrBoolTuple = numStrTuple;
var strStrTuple: [string, string] = ["foo", "bar", 5];
unionTuple = unionTuple1;
unionTuple = unionTuple2;
unionTuple2 = unionTuple;
numStrTuple = unionTuple3;
//// [contextualTypeWithTuple.js]
// no error
@@ -21,9 +32,27 @@ var numStrTuple2 = [5, "foo", true];
var numStrBoolTuple = [5, "foo", true];
var objNumTuple = [{ a: "world" }, 5];
var strTupleTuple = ["bar", [5, { x: 1, y: 1 }]];
var C = (function () {
function C() {
}
return C;
})();
var D = (function () {
function D() {
}
return D;
})();
var unionTuple = [new C(), "foo"];
var unionTuple1 = [new C(), "foo"];
var unionTuple2 = [new C(), "foo", new D()];
var unionTuple3 = [10, "foo"];
numStrTuple = numStrTuple2;
numStrTuple = numStrBoolTuple;
// error
objNumTuple = [{}, 5];
numStrBoolTuple = numStrTuple;
var strStrTuple = ["foo", "bar", 5];
unionTuple = unionTuple1;
unionTuple = unionTuple2;
unionTuple2 = unionTuple;
numStrTuple = unionTuple3;
@@ -45,42 +45,6 @@ var x = function (a) { return a.toString(); };
var x2 = function (a) { return a.toString(); }; // Like iWithCallSignatures
var x2 = function (a) { return a; }; // Like iWithCallSignatures2
// With call signatures of mismatching parameter type
var x3 = function (a /*here a should be any*/) { return a.toString(); };
var x3 = function (a) { return a.toString(); };
// With call signature count mismatch
var x4 = function (a //When used as a contextual type, a union type U has those members that are present in any of
// its constituent types, with types that are unions of the respective members in the constituent types.
// Let S be the set of types in U that have call signatures.
// If S is not empty and the sets of call signatures of the types in S are identical ignoring return types,
// U has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in S.
interface IWithNoCallSignatures {
foo: string;
}
interface IWithCallSignatures {
(a: number): string;
}
interface IWithCallSignatures2 {
(a: number): number;
}
interface IWithCallSignatures3 {
(b: string): number;
}
interface IWithCallSignatures4 {
(a: number): string;
(a: string, b: number): number;
}
// With no call signature | callSignatures
var x: IWithNoCallSignatures | IWithCallSignatures = a => a.toString();
// With call signatures with different return type
var x2: IWithCallSignatures | IWithCallSignatures2 = a => a.toString(); // Like iWithCallSignatures
var x2: IWithCallSignatures | IWithCallSignatures2 = a => a; // Like iWithCallSignatures2
// With call signatures of mismatching parameter type
var x3: IWithCallSignatures | IWithCallSignatures3 = a => /*here a should be any*/ a.toString();
// With call signature count mismatch
var x4: IWithCallSignatures | IWithCallSignatures4 = a =>
) { return a.toString(); };
var x4 = function (a) { return a.toString(); };
@@ -29,3 +29,29 @@
//// [emitCommentsOnlyFile.js]
/**
* @name Foo
* @class
*/
/**#@+
* @memberOf Foo#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
/**
* @name Foo2
* @class
*/
/**#@+
* @memberOf Foo2#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
@@ -31,3 +31,29 @@ var y = 10;
//// [emitPostComments.js]
var y = 10;
/**
* @name Foo
* @class
*/
/**#@+
* @memberOf Foo#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
/**
* @name Foo2
* @class
*/
/**#@+
* @memberOf Foo2#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
@@ -33,3 +33,29 @@ var y = 10;
//// [emitPreComments.js]
// This is pre comment
var y = 10;
/**
* @name Foo
* @class
*/
/**#@+
* @memberOf Foo#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
/**
* @name Foo2
* @class
*/
/**#@+
* @memberOf Foo2#
* @field
*/
/**
* @name bar
* @type Object[]
*/
/**#@-*/
@@ -20,3 +20,4 @@ var Foo = (function () {
var baz = Foo.b;
// Foo.b won't bind.
baz.concat("y");
// So we don't want an error on 'concat'.
@@ -113,3 +113,8 @@ function foo(x, y, z) {
a = y;
a = z;
}
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// a = x;
// a = y;
// a = z;
//}
@@ -0,0 +1,19 @@
//// [externalModuleReferenceDoubleUnderscore1.ts]
declare module 'timezonecomplete' {
import basics = require("__timezonecomplete/basics");
export import TimeUnit = basics.TimeUnit;
}
declare module '__timezonecomplete/basics' {
export enum TimeUnit {
Second = 0,
Minute = 1,
Hour = 2,
Day = 3,
Week = 4,
Month = 5,
Year = 6,
}
}
//// [externalModuleReferenceDoubleUnderscore1.js]
@@ -0,0 +1,37 @@
=== tests/cases/compiler/externalModuleReferenceDoubleUnderscore1.ts ===
declare module 'timezonecomplete' {
import basics = require("__timezonecomplete/basics");
>basics : typeof basics
export import TimeUnit = basics.TimeUnit;
>TimeUnit : typeof basics.TimeUnit
>basics : typeof basics
>TimeUnit : basics.TimeUnit
}
declare module '__timezonecomplete/basics' {
export enum TimeUnit {
>TimeUnit : TimeUnit
Second = 0,
>Second : TimeUnit
Minute = 1,
>Minute : TimeUnit
Hour = 2,
>Hour : TimeUnit
Day = 3,
>Day : TimeUnit
Week = 4,
>Week : TimeUnit
Month = 5,
>Month : TimeUnit
Year = 6,
>Year : TimeUnit
}
}
@@ -1,5 +1,5 @@
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(1,9): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(2,5): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(2,8): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(4,5): error TS1048: A rest parameter cannot have an initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016: A required parameter cannot follow an optional parameter.
@@ -9,7 +9,7 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016
~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
(...arg?) => 102;
~~~
~
!!! error TS1047: A rest parameter cannot be optional.
(...arg) => 103;
(...arg:number [] = []) => 104;
@@ -113,3 +113,7 @@ function foo2(x, y) {
foo(x);
foo(y);
}
//function foo2<T extends { (): void }, U extends T>(x: T, y: U) {
// foo(x);
// foo(y);
//}
@@ -6,9 +6,15 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error
tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it.
tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it.
tests/cases/conformance/functions/functionImplementationErrors.ts(40,28): 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/functions/functionImplementationErrors.ts(49,1): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/functions/functionImplementationErrors.ts(53,10): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/functions/functionImplementationErrors.ts(57,11): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/functions/functionImplementationErrors.ts(61,1): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/functions/functionImplementationErrors.ts(65,11): error TS2354: No best common type exists among return expressions.
tests/cases/conformance/functions/functionImplementationErrors.ts(69,11): error TS2354: No best common type exists among return expressions.
==== tests/cases/conformance/functions/functionImplementationErrors.ts (8 errors) ====
==== tests/cases/conformance/functions/functionImplementationErrors.ts (14 errors) ====
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
var f1 = function () {
~~~~~~~~~~~~~
@@ -83,4 +89,63 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(40,28): error
throw undefined;
var x = 4;
};
class Base { private x; }
class AnotherClass { private y; }
class Derived1 extends Base { private m; }
class Derived2 extends Base { private n; }
function f8() {
~~~~~~~~~~~~~~~
return new Derived1();
~~~~~~~~~~~~~~~~~~~~~~~~~~
return new Derived2();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
~
!!! error TS2354: No best common type exists among return expressions.
var f9 = function () {
~~~~~~~~~~~~~
return new Derived1();
~~~~~~~~~~~~~~~~~~~~~~~~~~
return new Derived2();
~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
var f10 = () => {
~~~~~~~
return new Derived1();
~~~~~~~~~~~~~~~~~~~~~~~~~~
return new Derived2();
~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
function f11() {
~~~~~~~~~~~~~~~~
return new Base();
~~~~~~~~~~~~~~~~~~~~~~
return new AnotherClass();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
~
!!! error TS2354: No best common type exists among return expressions.
var f12 = function () {
~~~~~~~~~~~~~
return new Base();
~~~~~~~~~~~~~~~~~~~~~~
return new AnotherClass();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
var f13 = () => {
~~~~~~~
return new Base();
~~~~~~~~~~~~~~~~~~~~~~
return new AnotherClass();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
@@ -42,9 +42,44 @@ undefined === function (): number {
throw undefined;
var x = 4;
};
class Base { private x; }
class AnotherClass { private y; }
class Derived1 extends Base { private m; }
class Derived2 extends Base { private n; }
function f8() {
return new Derived1();
return new Derived2();
}
var f9 = function () {
return new Derived1();
return new Derived2();
};
var f10 = () => {
return new Derived1();
return new Derived2();
};
function f11() {
return new Base();
return new AnotherClass();
}
var f12 = function () {
return new Base();
return new AnotherClass();
};
var f13 = () => {
return new Base();
return new AnotherClass();
};
//// [functionImplementationErrors.js]
var __extends = 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;
d.prototype = new __();
};
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
var f1 = function () {
return '';
@@ -86,3 +121,51 @@ undefined === function () {
throw undefined;
var x = 4;
};
var Base = (function () {
function Base() {
}
return Base;
})();
var AnotherClass = (function () {
function AnotherClass() {
}
return AnotherClass;
})();
var Derived1 = (function (_super) {
__extends(Derived1, _super);
function Derived1() {
_super.apply(this, arguments);
}
return Derived1;
})(Base);
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
_super.apply(this, arguments);
}
return Derived2;
})(Base);
function f8() {
return new Derived1();
return new Derived2();
}
var f9 = function () {
return new Derived1();
return new Derived2();
};
var f10 = function () {
return new Derived1();
return new Derived2();
};
function f11() {
return new Base();
return new AnotherClass();
}
var f12 = function () {
return new Base();
return new AnotherClass();
};
var f13 = function () {
return new Base();
return new AnotherClass();
};
@@ -70,6 +70,10 @@ var n = function () {
return 5;
}();
// Otherwise, the inferred return type is the first of the types of the return statement expressions
// in the function body that is a supertype of each of the others,
// ignoring return statements with no expressions.
// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others.
// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns
class Base { private m; }
class Derived extends Base { private q; }
@@ -120,9 +124,37 @@ function f6(): number {
return;
}
class Derived2 extends Base { private r: string; }
class AnotherClass { private x }
// if f is a contextually typed function expression, the inferred return type is the union type
// of the types of the return statement expressions in the function body,
// ignoring return statements with no expressions.
var f7: (x: number) => string | number = x => { // should be (x: number) => number | string
if (x < 0) { return x; }
return x.toString();
}
var f8: (x: number) => any = x => { // should be (x: number) => Base
return new Base();
return new Derived2();
}
var f9: (x: number) => any = x => { // should be (x: number) => Base
return new Base();
return new Derived();
return new Derived2();
}
var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1
return new Derived();
return new Derived2();
}
var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
return new Base();
return new AnotherClass();
}
var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
return new Base();
return; // should be ignored
return new AnotherClass();
}
//// [functionImplementations.js]
var __extends = this.__extends || function (d, b) {
@@ -192,6 +224,10 @@ var n = function () {
return 3;
return 5;
}();
// Otherwise, the inferred return type is the first of the types of the return statement expressions
// in the function body that is a supertype of each of the others,
// ignoring return statements with no expressions.
// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others.
// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns
var Base = (function () {
function Base() {
@@ -249,3 +285,46 @@ function opt3(n, m) {
function f6() {
return;
}
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
_super.apply(this, arguments);
}
return Derived2;
})(Base);
var AnotherClass = (function () {
function AnotherClass() {
}
return AnotherClass;
})();
// if f is a contextually typed function expression, the inferred return type is the union type
// of the types of the return statement expressions in the function body,
// ignoring return statements with no expressions.
var f7 = function (x) {
if (x < 0) {
return x;
}
return x.toString();
};
var f8 = function (x) {
return new Base();
return new Derived2();
};
var f9 = function (x) {
return new Base();
return new Derived();
return new Derived2();
};
var f10 = function (x) {
return new Derived();
return new Derived2();
};
var f11 = function (x) {
return new Base();
return new AnotherClass();
};
var f12 = function (x) {
return new Base();
return; // should be ignored
return new AnotherClass();
};
@@ -168,6 +168,10 @@ var n = function () {
return 5;
}();
// Otherwise, the inferred return type is the first of the types of the return statement expressions
// in the function body that is a supertype of each of the others,
// ignoring return statements with no expressions.
// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others.
// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns
class Base { private m; }
>Base : Base
@@ -292,6 +296,107 @@ function f6(): number {
return;
}
class Derived2 extends Base { private r: string; }
>Derived2 : Derived2
>Base : Base
>r : string
class AnotherClass { private x }
>AnotherClass : AnotherClass
>x : any
// if f is a contextually typed function expression, the inferred return type is the union type
// of the types of the return statement expressions in the function body,
// ignoring return statements with no expressions.
var f7: (x: number) => string | number = x => { // should be (x: number) => number | string
>f7 : (x: number) => string | number
>x : number
>x => { // should be (x: number) => number | string if (x < 0) { return x; } return x.toString();} : (x: number) => string | number
>x : number
if (x < 0) { return x; }
>x < 0 : boolean
>x : number
>x : number
return x.toString();
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>toString : (radix?: number) => string
}
var f8: (x: number) => any = x => { // should be (x: number) => Base
>f8 : (x: number) => any
>x : number
>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base
>x : number
return new Base();
>new Base() : Base
>Base : typeof Base
return new Derived2();
>new Derived2() : Derived2
>Derived2 : typeof Derived2
}
var f9: (x: number) => any = x => { // should be (x: number) => Base
>f9 : (x: number) => any
>x : number
>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base
>x : number
return new Base();
>new Base() : Base
>Base : typeof Base
return new Derived();
>new Derived() : Derived
>Derived : typeof Derived
return new Derived2();
>new Derived2() : Derived2
>Derived2 : typeof Derived2
}
var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1
>f10 : (x: number) => any
>x : number
>x => { // should be (x: number) => Derived | Derived1 return new Derived(); return new Derived2();} : (x: number) => Derived | Derived2
>x : number
return new Derived();
>new Derived() : Derived
>Derived : typeof Derived
return new Derived2();
>new Derived2() : Derived2
>Derived2 : typeof Derived2
}
var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
>f11 : (x: number) => any
>x : number
>x => { // should be (x: number) => Base | AnotherClass return new Base(); return new AnotherClass();} : (x: number) => Base | AnotherClass
>x : number
return new Base();
>new Base() : Base
>Base : typeof Base
return new AnotherClass();
>new AnotherClass() : AnotherClass
>AnotherClass : typeof AnotherClass
}
var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
>f12 : (x: number) => any
>x : number
>x => { // should be (x: number) => Base | AnotherClass return new Base(); return; // should be ignored return new AnotherClass();} : (x: number) => Base | AnotherClass
>x : number
return new Base();
>new Base() : Base
>Base : typeof Base
return; // should be ignored
return new AnotherClass();
>new AnotherClass() : AnotherClass
>AnotherClass : typeof AnotherClass
}
@@ -1,6 +1,6 @@
tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts(2,27): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts(5,38): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts(9,28): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts(9,25): error TS1014: A rest parameter must be last in a parameter list.
==== tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts (3 errors) ====
@@ -17,7 +17,7 @@ tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts(9,28): error T
//Function overload signature with rest param followed by non-optional parameter
function fn5(x: string, ...y: any[], z: string);
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
function fn5() { }
@@ -57,3 +57,10 @@ function other3(arg) {
// BUG 821629
//var u: U = r2[1]; // ok
}
//function other3<T extends U, U extends Date>(arg: T) {
// var b: { [x: number]: T };
// var r2 = foo(b);
// var d = r2[1];
// // BUG 821629
// //var u: U = r2[1]; // ok
//}
@@ -58,3 +58,10 @@ function other3(arg) {
// BUG 821629
//var u: U = r2['hm']; // ok
}
//function other3<T extends U, U extends Date>(arg: T) {
// var b: { [x: string]: T };
// var r2 = foo(b);
// var d: Date = r2['hm']; // ok
// // BUG 821629
// //var u: U = r2['hm']; // ok
//}
@@ -0,0 +1,2 @@
EmitOutputStatus : AllOutputGenerationSkipped
@@ -0,0 +1,8 @@
EmitOutputStatus : Succeeded
Filename : tests/cases/fourslash/inputFile1.js
// File to emit, does not contain semantic errors
// expected to be emitted correctelly regardless of the semantic errors in the other file
var noErrors = true;
Filename : tests/cases/fourslash/inputFile1.d.ts
declare var noErrors: boolean;
@@ -0,0 +1,8 @@
EmitOutputStatus : DeclarationGenerationSkipped
Filename : out.js
// File to emit, does not contain semantic errors, but --out is passed
// expected to not generate declarations because of the semantic errors in the other file
var noErrors = true;
// File not emitted, and contains semantic errors
var semanticError = "string";
@@ -0,0 +1,6 @@
EmitOutputStatus : Succeeded
Filename : tests/cases/fourslash/inputFile1.js
// File to emit, does not contain syntactic errors
// expected to be emitted correctelly regardless of the syntactic errors in the other file
var noErrors = true;
@@ -0,0 +1,2 @@
EmitOutputStatus : AllOutputGenerationSkipped
@@ -241,3 +241,28 @@ function foo4(t, u) {
var j = [u, derived]; // Derived[]
var k = [t, u];
}
//function foo3<T extends U, U extends Derived>(t: T, u: U) {
// var a = [t, t]; // T[]
// var b = [t, null]; // T[]
// var c = [t, u]; // {}[]
// var d = [t, 1]; // {}[]
// var e = [() => t, () => u]; // {}[]
// var f = [() => t, () => u, () => null]; // { (): any }[]
// var g = [t, base]; // Base[]
// var h = [t, derived]; // Derived[]
// var i = [u, base]; // Base[]
// var j = [u, derived]; // Derived[]
//}
//function foo4<T extends U, U extends Base>(t: T, u: U) {
// var a = [t, t]; // T[]
// var b = [t, null]; // T[]
// var c = [t, u]; // BUG 821629
// var d = [t, 1]; // {}[]
// var e = [() => t, () => u]; // {}[]
// var f = [() => t, () => u, () => null]; // { (): any }[]
// var g = [t, base]; // Base[]
// var h = [t, derived]; // Derived[]
// var i = [u, base]; // Base[]
// var j = [u, derived]; // Derived[]
// var k: Base[] = [t, u];
//}
@@ -1,5 +1,5 @@
tests/cases/compiler/indexSignatureTypeCheck.ts(14,6): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexSignatureTypeCheck.ts(15,9): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexSignatureTypeCheck.ts(14,8): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexSignatureTypeCheck.ts(15,6): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexSignatureTypeCheck.ts(16,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexSignatureTypeCheck.ts(17,6): error TS1096: An index signature must have exactly one parameter.
@@ -19,10 +19,10 @@ tests/cases/compiler/indexSignatureTypeCheck.ts(17,6): error TS1096: An index si
interface indexErrors {
[p2?: string];
~~
~
!!! error TS1019: An index signature parameter cannot have a question mark.
[...p3: any[]];
~~
~~~
!!! error TS1017: An index signature cannot have a rest parameter.
[p4: string, p5?: string];
~~
@@ -1,5 +1,5 @@
tests/cases/compiler/indexSignatureTypeCheck2.ts(10,6): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexSignatureTypeCheck2.ts(11,9): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexSignatureTypeCheck2.ts(10,8): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexSignatureTypeCheck2.ts(11,6): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexSignatureTypeCheck2.ts(12,6): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexSignatureTypeCheck2.ts(13,6): error TS1096: An index signature must have exactly one parameter.
@@ -15,10 +15,10 @@ tests/cases/compiler/indexSignatureTypeCheck2.ts(13,6): error TS1096: An index s
interface indexErrors {
[p2?: string];
~~
~
!!! error TS1019: An index signature parameter cannot have a question mark.
[...p3: any[]];
~~
~~~
!!! error TS1017: An index signature cannot have a rest parameter.
[p4: string, p5?: string];
~~
@@ -1,18 +1,18 @@
tests/cases/compiler/indexerAsOptional.ts(3,6): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexerAsOptional.ts(8,6): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexerAsOptional.ts(3,9): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/compiler/indexerAsOptional.ts(8,9): error TS1019: An index signature parameter cannot have a question mark.
==== tests/cases/compiler/indexerAsOptional.ts (2 errors) ====
interface indexSig {
//Index signatures can't be optional
[idx?: number]: any; //err
~~~
~
!!! error TS1019: An index signature parameter cannot have a question mark.
}
class indexSig2 {
//Index signatures can't be optional
[idx?: number]: any //err
~~~
~
!!! error TS1019: An index signature parameter cannot have a question mark.
}
@@ -1,16 +1,16 @@
tests/cases/compiler/indexerSignatureWithRestParam.ts(2,9): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexerSignatureWithRestParam.ts(6,9): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexerSignatureWithRestParam.ts(2,6): error TS1017: An index signature cannot have a rest parameter.
tests/cases/compiler/indexerSignatureWithRestParam.ts(6,6): error TS1017: An index signature cannot have a rest parameter.
==== tests/cases/compiler/indexerSignatureWithRestParam.ts (2 errors) ====
interface I {
[...x]: string;
~
~~~
!!! error TS1017: An index signature cannot have a rest parameter.
}
class C {
[...x]: string
~
~~~
!!! error TS1017: An index signature cannot have a rest parameter.
}
+41 -8
View File
@@ -1,32 +1,65 @@
//// [indexerWithTuple.ts]
var strNumTuple: [string, number] = ["foo", 10];
var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]];
var unionTuple1: [number, string| number] = [10, "foo"];
var unionTuple2: [boolean, string| number] = [true, "foo"];
// no error
var idx0 = 0;
var idx1 = 1;
var ele10 = strNumTuple[0]; // string
var ele11 = strNumTuple[1]; // number
var ele12 = strNumTuple[2]; // {}
var ele13 = strNumTuple[idx0]; // {}
var ele14 = strNumTuple[idx1]; // {}
var ele12 = strNumTuple[2]; // string | number
var ele13 = strNumTuple[idx0]; // string | number
var ele14 = strNumTuple[idx1]; // string | number
var ele15 = strNumTuple["0"]; // string
var ele16 = strNumTuple["1"]; // number
var strNumTuple1 = numTupleTuple[1]; //[string, number];
var ele17 = numTupleTuple[2]; // {}
var ele17 = numTupleTuple[2]; // number | [string, number]
var eleUnion10 = unionTuple1[0]; // number
var eleUnion11 = unionTuple1[1]; // string | number
var eleUnion12 = unionTuple1[2]; // string | number
var eleUnion13 = unionTuple1[idx0]; // string | number
var eleUnion14 = unionTuple1[idx1]; // string | number
var eleUnion15 = unionTuple1["0"]; // number
var eleUnion16 = unionTuple1["1"]; // string | number
var eleUnion20 = unionTuple2[0]; // boolean
var eleUnion21 = unionTuple2[1]; // string | number
var eleUnion22 = unionTuple2[2]; // string | number | boolean
var eleUnion23 = unionTuple2[idx0]; // string | number | boolean
var eleUnion24 = unionTuple2[idx1]; // string | number | boolean
var eleUnion25 = unionTuple2["0"]; // boolean
var eleUnion26 = unionTuple2["1"]; // string | number
//// [indexerWithTuple.js]
var strNumTuple = ["foo", 10];
var numTupleTuple = [10, ["bar", 20]];
var unionTuple1 = [10, "foo"];
var unionTuple2 = [true, "foo"];
// no error
var idx0 = 0;
var idx1 = 1;
var ele10 = strNumTuple[0]; // string
var ele11 = strNumTuple[1]; // number
var ele12 = strNumTuple[2]; // {}
var ele13 = strNumTuple[idx0]; // {}
var ele14 = strNumTuple[idx1]; // {}
var ele12 = strNumTuple[2]; // string | number
var ele13 = strNumTuple[idx0]; // string | number
var ele14 = strNumTuple[idx1]; // string | number
var ele15 = strNumTuple["0"]; // string
var ele16 = strNumTuple["1"]; // number
var strNumTuple1 = numTupleTuple[1]; //[string, number];
var ele17 = numTupleTuple[2]; // {}
var ele17 = numTupleTuple[2]; // number | [string, number]
var eleUnion10 = unionTuple1[0]; // number
var eleUnion11 = unionTuple1[1]; // string | number
var eleUnion12 = unionTuple1[2]; // string | number
var eleUnion13 = unionTuple1[idx0]; // string | number
var eleUnion14 = unionTuple1[idx1]; // string | number
var eleUnion15 = unionTuple1["0"]; // number
var eleUnion16 = unionTuple1["1"]; // string | number
var eleUnion20 = unionTuple2[0]; // boolean
var eleUnion21 = unionTuple2[1]; // string | number
var eleUnion22 = unionTuple2[2]; // string | number | boolean
var eleUnion23 = unionTuple2[idx0]; // string | number | boolean
var eleUnion24 = unionTuple2[idx1]; // string | number | boolean
var eleUnion25 = unionTuple2["0"]; // boolean
var eleUnion26 = unionTuple2["1"]; // string | number
@@ -8,6 +8,14 @@ var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]];
>[10, ["bar", 20]] : [number, [string, number]]
>["bar", 20] : [string, number]
var unionTuple1: [number, string| number] = [10, "foo"];
>unionTuple1 : [number, string | number]
>[10, "foo"] : [number, string]
var unionTuple2: [boolean, string| number] = [true, "foo"];
>unionTuple2 : [boolean, string | number]
>[true, "foo"] : [boolean, string]
// no error
var idx0 = 0;
>idx0 : number
@@ -25,18 +33,18 @@ var ele11 = strNumTuple[1]; // number
>strNumTuple[1] : number
>strNumTuple : [string, number]
var ele12 = strNumTuple[2]; // {}
var ele12 = strNumTuple[2]; // string | number
>ele12 : string | number
>strNumTuple[2] : string | number
>strNumTuple : [string, number]
var ele13 = strNumTuple[idx0]; // {}
var ele13 = strNumTuple[idx0]; // string | number
>ele13 : string | number
>strNumTuple[idx0] : string | number
>strNumTuple : [string, number]
>idx0 : number
var ele14 = strNumTuple[idx1]; // {}
var ele14 = strNumTuple[idx1]; // string | number
>ele14 : string | number
>strNumTuple[idx1] : string | number
>strNumTuple : [string, number]
@@ -57,8 +65,82 @@ var strNumTuple1 = numTupleTuple[1]; //[string, number];
>numTupleTuple[1] : [string, number]
>numTupleTuple : [number, [string, number]]
var ele17 = numTupleTuple[2]; // {}
var ele17 = numTupleTuple[2]; // number | [string, number]
>ele17 : number | [string, number]
>numTupleTuple[2] : number | [string, number]
>numTupleTuple : [number, [string, number]]
var eleUnion10 = unionTuple1[0]; // number
>eleUnion10 : number
>unionTuple1[0] : number
>unionTuple1 : [number, string | number]
var eleUnion11 = unionTuple1[1]; // string | number
>eleUnion11 : string | number
>unionTuple1[1] : string | number
>unionTuple1 : [number, string | number]
var eleUnion12 = unionTuple1[2]; // string | number
>eleUnion12 : string | number
>unionTuple1[2] : string | number
>unionTuple1 : [number, string | number]
var eleUnion13 = unionTuple1[idx0]; // string | number
>eleUnion13 : string | number
>unionTuple1[idx0] : string | number
>unionTuple1 : [number, string | number]
>idx0 : number
var eleUnion14 = unionTuple1[idx1]; // string | number
>eleUnion14 : string | number
>unionTuple1[idx1] : string | number
>unionTuple1 : [number, string | number]
>idx1 : number
var eleUnion15 = unionTuple1["0"]; // number
>eleUnion15 : number
>unionTuple1["0"] : number
>unionTuple1 : [number, string | number]
var eleUnion16 = unionTuple1["1"]; // string | number
>eleUnion16 : string | number
>unionTuple1["1"] : string | number
>unionTuple1 : [number, string | number]
var eleUnion20 = unionTuple2[0]; // boolean
>eleUnion20 : boolean
>unionTuple2[0] : boolean
>unionTuple2 : [boolean, string | number]
var eleUnion21 = unionTuple2[1]; // string | number
>eleUnion21 : string | number
>unionTuple2[1] : string | number
>unionTuple2 : [boolean, string | number]
var eleUnion22 = unionTuple2[2]; // string | number | boolean
>eleUnion22 : string | number | boolean
>unionTuple2[2] : string | number | boolean
>unionTuple2 : [boolean, string | number]
var eleUnion23 = unionTuple2[idx0]; // string | number | boolean
>eleUnion23 : string | number | boolean
>unionTuple2[idx0] : string | number | boolean
>unionTuple2 : [boolean, string | number]
>idx0 : number
var eleUnion24 = unionTuple2[idx1]; // string | number | boolean
>eleUnion24 : string | number | boolean
>unionTuple2[idx1] : string | number | boolean
>unionTuple2 : [boolean, string | number]
>idx1 : number
var eleUnion25 = unionTuple2["0"]; // boolean
>eleUnion25 : boolean
>unionTuple2["0"] : boolean
>unionTuple2 : [boolean, string | number]
var eleUnion26 = unionTuple2["1"]; // string | number
>eleUnion26 : string | number
>unionTuple2["1"] : string | number
>unionTuple2 : [boolean, string | number]
@@ -47,3 +47,11 @@ function f2() {
var x;
x.getDate();
}
//function f2<T extends Date, U extends T>() {
// function g<T extends Number, U extends T>() {
// var x: U;
// x.toFixed();
// }
// var x: U;
// x.getDate();
//}
@@ -66,3 +66,13 @@ var C2 = (function () {
};
return C2;
})();
//class C2<T extends Date, U extends T> {
// g<T extends Number, U extends T>() {
// var x: U;
// x.toFixed();
// }
// h() {
// var x: U;
// x.getDate();
// }
//}
@@ -28,77 +28,77 @@ var ra10 = undefined || a1; // undefined || any is any
var rb1 = a1 || a2; // any || boolean is any
var rb2 = a2 || a2; // boolean || boolean is boolean
var rb3 = a3 || a2; // number || boolean is {}
var rb4 = a4 || a2; // string || boolean is {}
var rb5 = a5 || a2; // void || boolean is {}
var rb6 = a6 || a2; // enum || boolean is {}
var rb7 = a7 || a2; // object || boolean is {}
var rb8 = a8 || a2; // array || boolean is {}
var rb3 = a3 || a2; // number || boolean is number | boolean
var rb4 = a4 || a2; // string || boolean is string | boolean
var rb5 = a5 || a2; // void || boolean is void | boolean
var rb6 = a6 || a2; // enum || boolean is E | boolean
var rb7 = a7 || a2; // object || boolean is object | boolean
var rb8 = a8 || a2; // array || boolean is array | boolean
var rb9 = null || a2; // null || boolean is boolean
var rb10= undefined || a2; // undefined || boolean is boolean
var rc1 = a1 || a3; // any || number is any
var rc2 = a2 || a3; // boolean || number is {}
var rc2 = a2 || a3; // boolean || number is boolean | number
var rc3 = a3 || a3; // number || number is number
var rc4 = a4 || a3; // string || number is {}
var rc5 = a5 || a3; // void || number is {}
var rc4 = a4 || a3; // string || number is string | number
var rc5 = a5 || a3; // void || number is void | number
var rc6 = a6 || a3; // enum || number is number
var rc7 = a7 || a3; // object || number is {}
var rc8 = a8 || a3; // array || number is {}
var rc7 = a7 || a3; // object || number is object | number
var rc8 = a8 || a3; // array || number is array | number
var rc9 = null || a3; // null || number is number
var rc10 = undefined || a3; // undefined || number is number
var rd1 = a1 || a4; // any || string is any
var rd2 = a2 || a4; // boolean || string is {}
var rd3 = a3 || a4; // number || string is {}
var rd2 = a2 || a4; // boolean || string is boolean | string
var rd3 = a3 || a4; // number || string is number | string
var rd4 = a4 || a4; // string || string is string
var rd5 = a5 || a4; // void || string is {}
var rd6 = a6 || a4; // enum || string is {}
var rd7 = a7 || a4; // object || string is {}
var rd8 = a8 || a4; // array || string is {}
var rd5 = a5 || a4; // void || string is void | string
var rd6 = a6 || a4; // enum || string is enum | string
var rd7 = a7 || a4; // object || string is object | string
var rd8 = a8 || a4; // array || string is array | string
var rd9 = null || a4; // null || string is string
var rd10 = undefined || a4; // undefined || string is string
var re1 = a1 || a5; // any || void is any
var re2 = a2 || a5; // boolean || void is {}
var re3 = a3 || a5; // number || void is {}
var re4 = a4 || a5; // string || void is {}
var re2 = a2 || a5; // boolean || void is boolean | void
var re3 = a3 || a5; // number || void is number | void
var re4 = a4 || a5; // string || void is string | void
var re5 = a5 || a5; // void || void is void
var re6 = a6 || a5; // enum || void is {}
var re7 = a7 || a5; // object || void is {}
var re8 = a8 || a5; // array || void is {}
var re6 = a6 || a5; // enum || void is enum | void
var re7 = a7 || a5; // object || void is object | void
var re8 = a8 || a5; // array || void is array | void
var re9 = null || a5; // null || void is void
var re10 = undefined || a5; // undefined || void is void
var rg1 = a1 || a6; // any || enum is any
var rg2 = a2 || a6; // boolean || enum is {}
var rg2 = a2 || a6; // boolean || enum is boolean | enum
var rg3 = a3 || a6; // number || enum is number
var rg4 = a4 || a6; // string || enum is {}
var rg5 = a5 || a6; // void || enum is {}
var rg4 = a4 || a6; // string || enum is string | enum
var rg5 = a5 || a6; // void || enum is void | enum
var rg6 = a6 || a6; // enum || enum is E
var rg7 = a7 || a6; // object || enum is {}
var rg8 = a8 || a6; // array || enum is {}
var rg7 = a7 || a6; // object || enum is object | enum
var rg8 = a8 || a6; // array || enum is array | enum
var rg9 = null || a6; // null || enum is E
var rg10 = undefined || a6; // undefined || enum is E
var rh1 = a1 || a7; // any || object is any
var rh2 = a2 || a7; // boolean || object is {}
var rh3 = a3 || a7; // number || object is {}
var rh4 = a4 || a7; // string || object is {}
var rh5 = a5 || a7; // void || object is {}
var rh6 = a6 || a7; // enum || object is {}
var rh2 = a2 || a7; // boolean || object is boolean | object
var rh3 = a3 || a7; // number || object is number | object
var rh4 = a4 || a7; // string || object is string | object
var rh5 = a5 || a7; // void || object is void | object
var rh6 = a6 || a7; // enum || object is enum | object
var rh7 = a7 || a7; // object || object is object
var rh8 = a8 || a7; // array || object is {}
var rh8 = a8 || a7; // array || object is array | object
var rh9 = null || a7; // null || object is object
var rh10 = undefined || a7; // undefined || object is object
var ri1 = a1 || a8; // any || array is any
var ri2 = a2 || a8; // boolean || array is {}
var ri3 = a3 || a8; // number || array is {}
var ri4 = a4 || a8; // string || array is {}
var ri5 = a5 || a8; // void || array is {}
var ri6 = a6 || a8; // enum || array is {}
var ri7 = a7 || a8; // object || array is {}
var ri2 = a2 || a8; // boolean || array is boolean | array
var ri3 = a3 || a8; // number || array is number | array
var ri4 = a4 || a8; // string || array is string | array
var ri5 = a5 || a8; // void || array is void | array
var ri6 = a6 || a8; // enum || array is enum | array
var ri7 = a7 || a8; // object || array is object | array
var ri8 = a8 || a8; // array || array is array
var ri9 = null || a8; // null || array is array
var ri10 = undefined || a8; // undefined || array is array
@@ -156,71 +156,71 @@ var ra9 = null || a1; // null || any is any
var ra10 = undefined || a1; // undefined || any is any
var rb1 = a1 || a2; // any || boolean is any
var rb2 = a2 || a2; // boolean || boolean is boolean
var rb3 = a3 || a2; // number || boolean is {}
var rb4 = a4 || a2; // string || boolean is {}
var rb5 = a5 || a2; // void || boolean is {}
var rb6 = a6 || a2; // enum || boolean is {}
var rb7 = a7 || a2; // object || boolean is {}
var rb8 = a8 || a2; // array || boolean is {}
var rb3 = a3 || a2; // number || boolean is number | boolean
var rb4 = a4 || a2; // string || boolean is string | boolean
var rb5 = a5 || a2; // void || boolean is void | boolean
var rb6 = a6 || a2; // enum || boolean is E | boolean
var rb7 = a7 || a2; // object || boolean is object | boolean
var rb8 = a8 || a2; // array || boolean is array | boolean
var rb9 = null || a2; // null || boolean is boolean
var rb10 = undefined || a2; // undefined || boolean is boolean
var rc1 = a1 || a3; // any || number is any
var rc2 = a2 || a3; // boolean || number is {}
var rc2 = a2 || a3; // boolean || number is boolean | number
var rc3 = a3 || a3; // number || number is number
var rc4 = a4 || a3; // string || number is {}
var rc5 = a5 || a3; // void || number is {}
var rc4 = a4 || a3; // string || number is string | number
var rc5 = a5 || a3; // void || number is void | number
var rc6 = a6 || a3; // enum || number is number
var rc7 = a7 || a3; // object || number is {}
var rc8 = a8 || a3; // array || number is {}
var rc7 = a7 || a3; // object || number is object | number
var rc8 = a8 || a3; // array || number is array | number
var rc9 = null || a3; // null || number is number
var rc10 = undefined || a3; // undefined || number is number
var rd1 = a1 || a4; // any || string is any
var rd2 = a2 || a4; // boolean || string is {}
var rd3 = a3 || a4; // number || string is {}
var rd2 = a2 || a4; // boolean || string is boolean | string
var rd3 = a3 || a4; // number || string is number | string
var rd4 = a4 || a4; // string || string is string
var rd5 = a5 || a4; // void || string is {}
var rd6 = a6 || a4; // enum || string is {}
var rd7 = a7 || a4; // object || string is {}
var rd8 = a8 || a4; // array || string is {}
var rd5 = a5 || a4; // void || string is void | string
var rd6 = a6 || a4; // enum || string is enum | string
var rd7 = a7 || a4; // object || string is object | string
var rd8 = a8 || a4; // array || string is array | string
var rd9 = null || a4; // null || string is string
var rd10 = undefined || a4; // undefined || string is string
var re1 = a1 || a5; // any || void is any
var re2 = a2 || a5; // boolean || void is {}
var re3 = a3 || a5; // number || void is {}
var re4 = a4 || a5; // string || void is {}
var re2 = a2 || a5; // boolean || void is boolean | void
var re3 = a3 || a5; // number || void is number | void
var re4 = a4 || a5; // string || void is string | void
var re5 = a5 || a5; // void || void is void
var re6 = a6 || a5; // enum || void is {}
var re7 = a7 || a5; // object || void is {}
var re8 = a8 || a5; // array || void is {}
var re6 = a6 || a5; // enum || void is enum | void
var re7 = a7 || a5; // object || void is object | void
var re8 = a8 || a5; // array || void is array | void
var re9 = null || a5; // null || void is void
var re10 = undefined || a5; // undefined || void is void
var rg1 = a1 || a6; // any || enum is any
var rg2 = a2 || a6; // boolean || enum is {}
var rg2 = a2 || a6; // boolean || enum is boolean | enum
var rg3 = a3 || a6; // number || enum is number
var rg4 = a4 || a6; // string || enum is {}
var rg5 = a5 || a6; // void || enum is {}
var rg4 = a4 || a6; // string || enum is string | enum
var rg5 = a5 || a6; // void || enum is void | enum
var rg6 = a6 || a6; // enum || enum is E
var rg7 = a7 || a6; // object || enum is {}
var rg8 = a8 || a6; // array || enum is {}
var rg7 = a7 || a6; // object || enum is object | enum
var rg8 = a8 || a6; // array || enum is array | enum
var rg9 = null || a6; // null || enum is E
var rg10 = undefined || a6; // undefined || enum is E
var rh1 = a1 || a7; // any || object is any
var rh2 = a2 || a7; // boolean || object is {}
var rh3 = a3 || a7; // number || object is {}
var rh4 = a4 || a7; // string || object is {}
var rh5 = a5 || a7; // void || object is {}
var rh6 = a6 || a7; // enum || object is {}
var rh2 = a2 || a7; // boolean || object is boolean | object
var rh3 = a3 || a7; // number || object is number | object
var rh4 = a4 || a7; // string || object is string | object
var rh5 = a5 || a7; // void || object is void | object
var rh6 = a6 || a7; // enum || object is enum | object
var rh7 = a7 || a7; // object || object is object
var rh8 = a8 || a7; // array || object is {}
var rh8 = a8 || a7; // array || object is array | object
var rh9 = null || a7; // null || object is object
var rh10 = undefined || a7; // undefined || object is object
var ri1 = a1 || a8; // any || array is any
var ri2 = a2 || a8; // boolean || array is {}
var ri3 = a3 || a8; // number || array is {}
var ri4 = a4 || a8; // string || array is {}
var ri5 = a5 || a8; // void || array is {}
var ri6 = a6 || a8; // enum || array is {}
var ri7 = a7 || a8; // object || array is {}
var ri2 = a2 || a8; // boolean || array is boolean | array
var ri3 = a3 || a8; // number || array is number | array
var ri4 = a4 || a8; // string || array is string | array
var ri5 = a5 || a8; // void || array is void | array
var ri6 = a6 || a8; // enum || array is enum | array
var ri7 = a7 || a8; // object || array is object | array
var ri8 = a8 || a8; // array || array is array
var ri9 = null || a8; // null || array is array
var ri10 = undefined || a8; // undefined || array is array
@@ -107,37 +107,37 @@ var rb2 = a2 || a2; // boolean || boolean is boolean
>a2 : boolean
>a2 : boolean
var rb3 = a3 || a2; // number || boolean is {}
var rb3 = a3 || a2; // number || boolean is number | boolean
>rb3 : number | boolean
>a3 || a2 : number | boolean
>a3 : number
>a2 : boolean
var rb4 = a4 || a2; // string || boolean is {}
var rb4 = a4 || a2; // string || boolean is string | boolean
>rb4 : string | boolean
>a4 || a2 : string | boolean
>a4 : string
>a2 : boolean
var rb5 = a5 || a2; // void || boolean is {}
var rb5 = a5 || a2; // void || boolean is void | boolean
>rb5 : boolean | void
>a5 || a2 : boolean | void
>a5 : void
>a2 : boolean
var rb6 = a6 || a2; // enum || boolean is {}
var rb6 = a6 || a2; // enum || boolean is E | boolean
>rb6 : boolean | E
>a6 || a2 : boolean | E
>a6 : E
>a2 : boolean
var rb7 = a7 || a2; // object || boolean is {}
var rb7 = a7 || a2; // object || boolean is object | boolean
>rb7 : boolean | { a: string; }
>a7 || a2 : boolean | { a: string; }
>a7 : { a: string; }
>a2 : boolean
var rb8 = a8 || a2; // array || boolean is {}
var rb8 = a8 || a2; // array || boolean is array | boolean
>rb8 : boolean | string[]
>a8 || a2 : boolean | string[]
>a8 : string[]
@@ -160,7 +160,7 @@ var rc1 = a1 || a3; // any || number is any
>a1 : any
>a3 : number
var rc2 = a2 || a3; // boolean || number is {}
var rc2 = a2 || a3; // boolean || number is boolean | number
>rc2 : number | boolean
>a2 || a3 : number | boolean
>a2 : boolean
@@ -172,13 +172,13 @@ var rc3 = a3 || a3; // number || number is number
>a3 : number
>a3 : number
var rc4 = a4 || a3; // string || number is {}
var rc4 = a4 || a3; // string || number is string | number
>rc4 : string | number
>a4 || a3 : string | number
>a4 : string
>a3 : number
var rc5 = a5 || a3; // void || number is {}
var rc5 = a5 || a3; // void || number is void | number
>rc5 : number | void
>a5 || a3 : number | void
>a5 : void
@@ -190,13 +190,13 @@ var rc6 = a6 || a3; // enum || number is number
>a6 : E
>a3 : number
var rc7 = a7 || a3; // object || number is {}
var rc7 = a7 || a3; // object || number is object | number
>rc7 : number | { a: string; }
>a7 || a3 : number | { a: string; }
>a7 : { a: string; }
>a3 : number
var rc8 = a8 || a3; // array || number is {}
var rc8 = a8 || a3; // array || number is array | number
>rc8 : number | string[]
>a8 || a3 : number | string[]
>a8 : string[]
@@ -219,13 +219,13 @@ var rd1 = a1 || a4; // any || string is any
>a1 : any
>a4 : string
var rd2 = a2 || a4; // boolean || string is {}
var rd2 = a2 || a4; // boolean || string is boolean | string
>rd2 : string | boolean
>a2 || a4 : string | boolean
>a2 : boolean
>a4 : string
var rd3 = a3 || a4; // number || string is {}
var rd3 = a3 || a4; // number || string is number | string
>rd3 : string | number
>a3 || a4 : string | number
>a3 : number
@@ -237,25 +237,25 @@ var rd4 = a4 || a4; // string || string is string
>a4 : string
>a4 : string
var rd5 = a5 || a4; // void || string is {}
var rd5 = a5 || a4; // void || string is void | string
>rd5 : string | void
>a5 || a4 : string | void
>a5 : void
>a4 : string
var rd6 = a6 || a4; // enum || string is {}
var rd6 = a6 || a4; // enum || string is enum | string
>rd6 : string | E
>a6 || a4 : string | E
>a6 : E
>a4 : string
var rd7 = a7 || a4; // object || string is {}
var rd7 = a7 || a4; // object || string is object | string
>rd7 : string | { a: string; }
>a7 || a4 : string | { a: string; }
>a7 : { a: string; }
>a4 : string
var rd8 = a8 || a4; // array || string is {}
var rd8 = a8 || a4; // array || string is array | string
>rd8 : string | string[]
>a8 || a4 : string | string[]
>a8 : string[]
@@ -278,19 +278,19 @@ var re1 = a1 || a5; // any || void is any
>a1 : any
>a5 : void
var re2 = a2 || a5; // boolean || void is {}
var re2 = a2 || a5; // boolean || void is boolean | void
>re2 : boolean | void
>a2 || a5 : boolean | void
>a2 : boolean
>a5 : void
var re3 = a3 || a5; // number || void is {}
var re3 = a3 || a5; // number || void is number | void
>re3 : number | void
>a3 || a5 : number | void
>a3 : number
>a5 : void
var re4 = a4 || a5; // string || void is {}
var re4 = a4 || a5; // string || void is string | void
>re4 : string | void
>a4 || a5 : string | void
>a4 : string
@@ -302,19 +302,19 @@ var re5 = a5 || a5; // void || void is void
>a5 : void
>a5 : void
var re6 = a6 || a5; // enum || void is {}
var re6 = a6 || a5; // enum || void is enum | void
>re6 : void | E
>a6 || a5 : void | E
>a6 : E
>a5 : void
var re7 = a7 || a5; // object || void is {}
var re7 = a7 || a5; // object || void is object | void
>re7 : void | { a: string; }
>a7 || a5 : void | { a: string; }
>a7 : { a: string; }
>a5 : void
var re8 = a8 || a5; // array || void is {}
var re8 = a8 || a5; // array || void is array | void
>re8 : void | string[]
>a8 || a5 : void | string[]
>a8 : string[]
@@ -337,7 +337,7 @@ var rg1 = a1 || a6; // any || enum is any
>a1 : any
>a6 : E
var rg2 = a2 || a6; // boolean || enum is {}
var rg2 = a2 || a6; // boolean || enum is boolean | enum
>rg2 : boolean | E
>a2 || a6 : boolean | E
>a2 : boolean
@@ -349,13 +349,13 @@ var rg3 = a3 || a6; // number || enum is number
>a3 : number
>a6 : E
var rg4 = a4 || a6; // string || enum is {}
var rg4 = a4 || a6; // string || enum is string | enum
>rg4 : string | E
>a4 || a6 : string | E
>a4 : string
>a6 : E
var rg5 = a5 || a6; // void || enum is {}
var rg5 = a5 || a6; // void || enum is void | enum
>rg5 : void | E
>a5 || a6 : void | E
>a5 : void
@@ -367,13 +367,13 @@ var rg6 = a6 || a6; // enum || enum is E
>a6 : E
>a6 : E
var rg7 = a7 || a6; // object || enum is {}
var rg7 = a7 || a6; // object || enum is object | enum
>rg7 : E | { a: string; }
>a7 || a6 : E | { a: string; }
>a7 : { a: string; }
>a6 : E
var rg8 = a8 || a6; // array || enum is {}
var rg8 = a8 || a6; // array || enum is array | enum
>rg8 : string[] | E
>a8 || a6 : string[] | E
>a8 : string[]
@@ -396,31 +396,31 @@ var rh1 = a1 || a7; // any || object is any
>a1 : any
>a7 : { a: string; }
var rh2 = a2 || a7; // boolean || object is {}
var rh2 = a2 || a7; // boolean || object is boolean | object
>rh2 : boolean | { a: string; }
>a2 || a7 : boolean | { a: string; }
>a2 : boolean
>a7 : { a: string; }
var rh3 = a3 || a7; // number || object is {}
var rh3 = a3 || a7; // number || object is number | object
>rh3 : number | { a: string; }
>a3 || a7 : number | { a: string; }
>a3 : number
>a7 : { a: string; }
var rh4 = a4 || a7; // string || object is {}
var rh4 = a4 || a7; // string || object is string | object
>rh4 : string | { a: string; }
>a4 || a7 : string | { a: string; }
>a4 : string
>a7 : { a: string; }
var rh5 = a5 || a7; // void || object is {}
var rh5 = a5 || a7; // void || object is void | object
>rh5 : void | { a: string; }
>a5 || a7 : void | { a: string; }
>a5 : void
>a7 : { a: string; }
var rh6 = a6 || a7; // enum || object is {}
var rh6 = a6 || a7; // enum || object is enum | object
>rh6 : E | { a: string; }
>a6 || a7 : E | { a: string; }
>a6 : E
@@ -432,7 +432,7 @@ var rh7 = a7 || a7; // object || object is object
>a7 : { a: string; }
>a7 : { a: string; }
var rh8 = a8 || a7; // array || object is {}
var rh8 = a8 || a7; // array || object is array | object
>rh8 : string[] | { a: string; }
>a8 || a7 : string[] | { a: string; }
>a8 : string[]
@@ -455,37 +455,37 @@ var ri1 = a1 || a8; // any || array is any
>a1 : any
>a8 : string[]
var ri2 = a2 || a8; // boolean || array is {}
var ri2 = a2 || a8; // boolean || array is boolean | array
>ri2 : boolean | string[]
>a2 || a8 : boolean | string[]
>a2 : boolean
>a8 : string[]
var ri3 = a3 || a8; // number || array is {}
var ri3 = a3 || a8; // number || array is number | array
>ri3 : number | string[]
>a3 || a8 : number | string[]
>a3 : number
>a8 : string[]
var ri4 = a4 || a8; // string || array is {}
var ri4 = a4 || a8; // string || array is string | array
>ri4 : string | string[]
>a4 || a8 : string | string[]
>a4 : string
>a8 : string[]
var ri5 = a5 || a8; // void || array is {}
var ri5 = a5 || a8; // void || array is void | array
>ri5 : void | string[]
>a5 || a8 : void | string[]
>a5 : void
>a8 : string[]
var ri6 = a6 || a8; // enum || array is {}
var ri6 = a6 || a8; // enum || array is enum | array
>ri6 : string[] | E
>a6 || a8 : string[] | E
>a6 : E
>a8 : string[]
var ri7 = a7 || a8; // object || array is {}
var ri7 = a7 || a8; // object || array is object | array
>ri7 : string[] | { a: string; }
>a7 || a8 : string[] | { a: string; }
>a7 : { a: string; }
@@ -18,3 +18,5 @@ var M;
//var p: M.P;
//var m: M = M;
var x1 = M.a;
//var x2 = m.a;
//var q: m.P;
@@ -80,3 +80,8 @@ function foo(x, y, z) {
y = null;
z = null;
}
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = null;
// y = null;
// z = null;
//}
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1.ts(2,7): error TS1017: An index signature cannot have a rest parameter.
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1.ts(2,4): error TS1017: An index signature cannot have a rest parameter.
==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1.ts (1 errors) ====
interface I {
[...a]
~
~~~
!!! error TS1017: An index signature cannot have a rest parameter.
}
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature3.ts(2,4): error TS1019: An index signature parameter cannot have a question mark.
tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature3.ts(2,5): error TS1019: An index signature parameter cannot have a question mark.
==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature3.ts (1 errors) ====
interface I {
[a?]
~
~
!!! error TS1019: An index signature parameter cannot have a question mark.
}
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration17.ts(2,8): error TS1051: A 'set' accessor cannot have an optional parameter.
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration17.ts(2,13): error TS1051: A 'set' accessor cannot have an optional parameter.
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration17.ts (1 errors) ====
class C {
set Foo(a?: number) { }
~~~
~
!!! error TS1051: A 'set' accessor cannot have an optional parameter.
}
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration18.ts(2,8): error TS1053: A 'set' accessor cannot have rest parameter.
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration18.ts(2,12): error TS1053: A 'set' accessor cannot have rest parameter.
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration18.ts (1 errors) ====
class C {
set Foo(...a) { }
~~~
~~~
!!! error TS1053: A 'set' accessor cannot have rest parameter.
}
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList1.ts(2,9): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList1.ts(2,6): error TS1014: A rest parameter must be last in a parameter list.
==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList1.ts (1 errors) ====
class C {
F(...A, B) { }
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
}
@@ -1,7 +1,7 @@
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList11.ts(1,5): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList11.ts(1,8): error TS1047: A rest parameter cannot be optional.
==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList11.ts (1 errors) ====
(...arg?) => 102;
~~~
~
!!! error TS1047: A rest parameter cannot be optional.
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList9.ts(2,11): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList9.ts(2,14): error TS1047: A rest parameter cannot be optional.
==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList9.ts (1 errors) ====
class C {
foo(...bar?) { }
~~~
~
!!! error TS1047: A rest parameter cannot be optional.
}
@@ -17,3 +17,11 @@
//// [parserS7.6.1.1_A1.10.js]
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* The "for" token can not be used as identifier
*
* @path ch07/7.6/7.6.1/7.6.1.1/S7.6.1.1_A1.10.js
* @description Checking if execution of "for=1" fails
* @negative
*/
//for = 1;
@@ -289,3 +289,220 @@
// [index: number]: string;
// }
//}
//import fs = module("fs");
//module TypeScriptAllInOne {
// export class Program {
// static Main(...args: string[]) {
// try {
// var bfs = new BasicFeatures();
// var retValue: number = 0;
// retValue = bfs.VARIABLES();
// if (retValue != 0) {
// return 1;
// }
// retValue = bfs.STATEMENTS(4);
// if (retValue != 0) {
// return 1;
// }
// retValue = bfs.TYPES();
// if (retValue != 0) {
// return 1;
// }
// retValue = bfs.OPERATOR();
// if (retValue != 0) {
// return 1;
// }
// }
// catch (e) {
// console.log(e);
// }
// finally {
// }
// console.log('Done');
// return 0;
// }
// }
// class BasicFeatures {
// /// <summary>
// /// Test various of variables. Including nullable,key world as variable,special format
// /// </summary>
// /// <returns></returns>
// public VARIABLES(): number {
// var local = Number.MAX_VALUE;
// var min = Number.MIN_VALUE;
// var inf = Number.NEGATIVE_INFINITY;
// var nan = Number.NaN;
// var undef = undefined;
// var п = local;
// var м = local;
// var local5 = <fs.File>null;
// var local6 = local5 instanceof fs.File;
// var hex = 0xBADC0DE, Hex = 0XDEADBEEF;
// var float = 6.02e23, float2 = 6.02E-23
// var char = 'c', \u0066 = '\u0066', hexchar = '\x42';
// var quoted = '"', quoted2 = "'";
// var reg = /\w*/;
// var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, toString: () => 'objLit{42}' };
// var weekday = Weekdays.Monday;
// var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
// //
// var any = 0;
// var boolean = 0;
// var declare = 0;
// var constructor = 0;
// var get = 0;
// var implements = 0;
// var interface = 0;
// var let = 0;
// var module = 0;
// var number = 0;
// var package = 0;
// var private = 0;
// var protected = 0;
// var public = 0;
// var set = 0;
// var static = 0;
// var string = 0;
// var yield = 0;
// var sum3 = any + boolean + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
// return 0;
// }
// /// <summary>
// /// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
// /// </summary>
// /// <param name="i"></param>
// /// <returns></returns>
// STATEMENTS(i: number): number {
// var retVal = 0;
// if (i == 1)
// retVal = 1;
// else
// retVal = 0;
// switch (i) {
// case 2:
// retVal = 1;
// break;
// case 3:
// retVal = 1;
// break;
// default:
// break;
// }
// for (var x in { x: 0, y: 1 }) {
// }
// try {
// throw null;
// }
// catch (Exception) {
// }
// finally {
// try { }
// catch (Exception) { }
// }
// return retVal;
// }
// /// <summary>
// /// Test types in ts language. Including class,struct,interface,delegate,anonymous type
// /// </summary>
// /// <returns></returns>
// public TYPES(): number {
// var retVal = 0;
// var c = new CLASS();
// var xx: IF = c;
// retVal += c.Property;
// retVal += c.Member();
// retVal += xx ^= Foo() ? 0 : 1;
// //anonymous type
// var anony = { a: new CLASS() };
// retVal += anony.a.d();
// return retVal;
// }
// ///// <summary>
// ///// Test different operators
// ///// </summary>
// ///// <returns></returns>
// public OPERATOR(): number {
// var a: number[] = [1, 2, 3, 4, implements , ];/*[] bug*/ // YES []
// var i = a[1];/*[]*/
// i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
// var b = true && false || true ^ false;/*& | ^*/
// b = !b;/*!*/
// i = ~i;/*~i*/
// b = i < (i - continue ) && (i + 1) > i;/*< && >*/
// var f = true ? 1 : 0;/*? :*/ // YES :
// i++;/*++*/
// i--;/*--*/
// b = true && false || true;/*&& ||*/
// i = i << 5;/*<<*/
// i = i >> 5;/*>>*/
// var j = i;
// b = i == j && i != j && i <= j && i >= j;/*= == && != <= >=*/
// i += <number>5.0;/*+=*/
// i -= i;/*-=*/
// i *= i;/**=*/
// if (i == 0)
// i++;
// i /= i;/*/=*/
// i %= i;/*%=*/
// i &= i;/*&=*/
// i |= i;/*|=*/
// i ^= i;/*^=*/
// i <<= i;/*<<=*/
// i >>= i;/*>>=*/
// if (i == 0 && !b && f == 1)
// return 0;
// else return 1;
// }
// }
// interface IF {
// Foo <!-- ): boolean;
// }
// class CLASS implements IF {
// public d = () => ' return 0; };
// public get Property() { return 0; }
// public Member() {
// return 0;
// }
// public Foo(): boolean {
// var myEvent = () => { return 1; };
// if (myEvent() == 1)
// return true;
// else
// return false;
// }
// }
// // todo: use these
// class A {
// public method1(val:number) {
// return val;
// }
// public method2() {
// return 2 * this.method1(2);
// }
// }
// class B extends A {
// public method2() {
// return this.method1(2);
// }
// }
// class Overloading {
// private otherValue = 42;
// constructor(private value: number, public name: string) { }
// public Overloads(value: string);
// public Overloads(value: string, ...rest: string[]) { }
// public DefaultValue(value?: string = "Hello") { }
// }
//}
//enum Weekdays {
// Monday,
// Tuesday,
// Weekend,
//}
//enum Fruit {
// Apple,
// Pear
//}
//interface IDisposable {
// Dispose(): void;
//}
//TypeScriptAllInOne.Program.Main();
@@ -62,3 +62,44 @@ var MsPortal;
})(Base = Controls.Base || (Controls.Base = {}));
})(Controls = MsPortal.Controls || (MsPortal.Controls = {}));
})(MsPortal || (MsPortal = {}));
// Generates:
/*
declare module MsPortal.Controls.Base.ItemList {
interface Interface<TValue> {
options: ViewModel<TValue>;
}
class ItemValue<T> {
constructor(value: T);
}
class ViewModel<TValue> extends ItemValue<TValue> {
}
}
module MsPortal.Controls.Base.ItemList {
export interface Interface<TValue> {
// Removing this line fixes the constructor of ItemValue
options: ViewModel<TValue>;
}
export class ItemValue<T> {
constructor(value: T) {
}
}
export class ViewModel<TValue> extends ItemValue<TValue> {
}
}
// Generates:
/*
declare module MsPortal.Controls.Base.ItemList {
interface Interface<TValue> {
options: ViewModel<TValue>;
}
class ItemValue<T> {
constructor(value: T);
}
class ViewModel<TValue> extends ItemValue<TValue> {
}
}
@@ -1,10 +1,10 @@
tests/cases/compiler/restParamAsOptional.ts(1,15): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/restParamAsOptional.ts(1,16): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/restParamAsOptional.ts(2,16): error TS1048: A rest parameter cannot have an initializer.
==== tests/cases/compiler/restParamAsOptional.ts (2 errors) ====
function f(...x?) { }
~
~
!!! error TS1047: A rest parameter cannot be optional.
function f2(...x = []) { }
~
@@ -1,7 +1,7 @@
tests/cases/compiler/restParameterNotLast.ts(1,15): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/compiler/restParameterNotLast.ts(1,12): error TS1014: A rest parameter must be last in a parameter list.
==== tests/cases/compiler/restParameterNotLast.ts (1 errors) ====
function f(...x, y) { }
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
@@ -1,6 +1,6 @@
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,14): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,12): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,24): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list.
tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list.
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts (3 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWith
function foo(...x) { }
var f = function foo(...x) { }
var f2 = (...x, ...y) => { }
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
class C {
@@ -19,7 +19,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWith
interface I {
(...x);
foo(...x, ...y);
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
}
@@ -31,7 +31,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWith
var b = {
foo(...x) { },
a: function foo(...x, ...y) { },
~
~~~
!!! error TS1014: A rest parameter must be last in a parameter list.
b: (...x) => { }
}

Some files were not shown because too many files have changed in this diff Show More