diff --git a/.gitignore b/.gitignore index 3147b8e8724..58a45545939 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ tests/baselines/reference/projectOutput/* tests/baselines/local/projectOutput/* tests/services/baselines/prototyping/local/* tests/services/browser/typescriptServices.js +scripts/configureNightly.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js scripts/importDefinitelyTypedTests.js diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000000..0ade4c31221 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,70 @@ +TypeScript is authored by: + +* Adam Freidin +* Ahmad Farid +* Anders Hejlsberg +* Arnav Singh +* Arthur Ozga +* Basarat Ali Syed +* Ben Duffield +* Bill Ticehurst +* Bryan Forbes +* Caitlin Potter +* Chris Bubernak +* Colby Russell +* Colin Snover +* Cyrus Najmabadi +* Dan Quirk +* Daniel Rosenwasser +* David Li +* Dick van den Brink +* Dirk Bäumer +* Frank Wallis +* Gabriel Isenberg +* Gilad Peleg +* Guillaume Salles +* Harald Niesche +* Ingvar Stepanyan +* Ivo Gabe de Wolff +* James Whitney +* Jason Freeman +* Jason Ramsay +* Jed Mao +* Johannes Rieken +* Jonathan Bond-Caron +* Jonathan Park +* Jonathan Turner +* Josh Kalderimis +* Kagami Sascha Rosylight +* Keith Mashinter +* Kenji Imamula +* Lorant Pinter +* Masahiro Wakame +* Max Deepfield +* Micah Zoltu +* Mohamed Hegazy +* Oleg Mihailik +* Oleksandr Chekhovskyi +* Paul van Brenk +* Pedro Maltez +* Philip Bulley +* piloopin +* Ron Buckton +* Ryan Cavanaugh +* Sheetal Nandi +* Shengping Zhong +* Shyyko Serhiy +* Simon Hürlimann +* Solal Pirelli +* Stan Thomas +* Steve Lucco +* Tien Hoanhtien +* Tingan Ho +* togru +* Tomas Grubliauskas +* TruongSinh Tran-Nguyen +* Vladimir Matveev +* Wesley Wigham +* Yui Tanglertsampan +* Zev Spitz +* Zhengbo Li \ No newline at end of file diff --git a/Jakefile.js b/Jakefile.js index bd5074b43d6..8fbefe1b2cc 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -138,6 +138,7 @@ var harnessSources = harnessCoreSources.concat([ "services/documentRegistry.ts", "services/preProcessFile.ts", "services/patternMatcher.ts", + "session.ts", "versionCache.ts", "convertToBase64.ts", "transpile.ts" @@ -313,7 +314,7 @@ var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnostic var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json"); var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts"); -file(processDiagnosticMessagesTs) +file(processDiagnosticMessagesTs); // processDiagnosticMessages script compileFile(processDiagnosticMessagesJs, @@ -338,12 +339,50 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], complete(); }); ex.run(); -}, {async: true}) +}, {async: true}); desc("Generates a diagnostic file in TypeScript based on an input JSON file"); -task("generate-diagnostics", [diagnosticInfoMapTs]) +task("generate-diagnostics", [diagnosticInfoMapTs]); +// Publish nightly +var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js"); +var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts"); +var packageJson = "package.json"; +var programTs = path.join(compilerDirectory, "program.ts"); + +file(configureNightlyTs); + +compileFile(/*outfile*/configureNightlyJs, + /*sources*/ [configureNightlyTs], + /*prereqs*/ [configureNightlyTs], + /*prefixes*/ [], + /*useBuiltCompiler*/ false, + /*noOutFile*/ false, + /*generateDeclarations*/ false, + /*outDir*/ undefined, + /*preserveConstEnums*/ undefined, + /*keepComments*/ false, + /*noResolve*/ false, + /*stripInternal*/ false); + +task("setDebugMode", function() { + useDebugMode = true; +}); + +task("configure-nightly", [configureNightlyJs], function() { + var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; + console.log(cmd); + exec(cmd); +}, { async: true }); + +desc("Configure, build, test, and publish the nightly release."); +task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () { + var cmd = "npm publish --tag next"; + console.log(cmd); + exec(cmd); +}); + // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); @@ -440,11 +479,11 @@ file(specMd, [word2mdJs, specWord], function () { child_process.exec(cmd, function () { complete(); }); -}, {async: true}) +}, {async: true}); desc("Generates a Markdown version of the Language Specification"); -task("generate-spec", [specMd]) +task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory @@ -576,7 +615,7 @@ task("runtests", ["tests", builtLocalDirectory], function() { exec(cmd, deleteTemporaryProjectOutput); }, {async: true}); -desc("Generates code coverage data via instanbul") +desc("Generates code coverage data via instanbul"); task("generate-code-coverage", ["tests", builtLocalDirectory], function () { var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run; console.log(cmd); @@ -619,7 +658,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function( function getDiffTool() { var program = process.env['DIFF'] if (!program) { - fail("Add the 'DIFF' environment variable to the path of the program you want to use.") + fail("Add the 'DIFF' environment variable to the path of the program you want to use."); } return program; } @@ -628,14 +667,14 @@ function getDiffTool() { desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff', function () { var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; - console.log(cmd) + console.log(cmd); exec(cmd); }, {async: true}); desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff-rwc', function () { var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; - console.log(cmd) + console.log(cmd); exec(cmd); }, {async: true}); @@ -736,9 +775,9 @@ task("lint", [], function() { function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }}; var lintTargets = compilerSources.concat(harnessCoreSources); - for(var i in lintTargets) { + for (var i in lintTargets) { var f = lintTargets[i]; - var cmd = 'tslint -f ' + f; + var cmd = 'tslint -c tslint.json ' + f; exec(cmd, success(f), failure(f)); } }, { async: true }); diff --git a/README.md b/README.md index 57dfe06c67c..c8bc5936c24 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,19 @@ [TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang). +## Installing + +For the latest stable version: + +``` +npm install -g typescript +``` + +For our nightly builds: + +``` +npm install -g typescript@next +``` ## Contribute @@ -63,7 +76,8 @@ jake runtests # Run tests using the built compiler and test infrastructu # Use host= or tests=. jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'. -jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. +jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. +jake lint # Runs tslint on the TypeScript source. jake -T # List the above commands. ``` diff --git a/package.json b/package.json index 70ada6fef15..c8b30f9de1c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.5.3", + "version": "1.6.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/scripts/configureNightly.ts b/scripts/configureNightly.ts new file mode 100644 index 00000000000..640f330b376 --- /dev/null +++ b/scripts/configureNightly.ts @@ -0,0 +1,73 @@ +/// + +/** + * A minimal description for a parsed package.json object. + */ +interface PackageJson { + name: string; + version: string; + keywords: string[]; +} + +function main(): void { + const sys = ts.sys; + if (sys.args.length < 2) { + sys.write("Usage:" + sys.newLine) + sys.write("\tnode configureNightly.js " + sys.newLine); + return; + } + + // Acquire the version from the package.json file and modify it appropriately. + const packageJsonFilePath = ts.normalizePath(sys.args[0]); + const packageJsonContents = sys.readFile(packageJsonFilePath); + const packageJsonValue: PackageJson = JSON.parse(packageJsonContents); + + const nightlyVersion = getNightlyVersionString(packageJsonValue.version); + + // Modify the package.json structure + packageJsonValue.version = nightlyVersion; + + // Acquire and modify the source file that exposes the version string. + const tsFilePath = ts.normalizePath(sys.args[1]); + const tsFileContents = sys.readFile(tsFilePath); + const versionAssignmentRegExp = /export\s+const\s+version\s+=\s+".*";/; + const modifiedTsFileContents = tsFileContents.replace(versionAssignmentRegExp, `export const version = "${nightlyVersion}";`); + + // Ensure we are actually changing something - the user probably wants to know that the update failed. + if (tsFileContents === modifiedTsFileContents) { + let err = `\n '${tsFilePath}' was not updated while configuring for a nightly publish.\n `; + + if (tsFileContents.match(versionAssignmentRegExp)) { + err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`; + } + else { + err += `The file seems to no longer have a string matching '${versionAssignmentRegExp}'.`; + } + + throw err + "\n"; + } + + // Finally write the changes to disk. + sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4)) + sys.writeFile(tsFilePath, modifiedTsFileContents); +} + +function getNightlyVersionString(versionString: string): string { + // If the version string already contains "-nightly", + // then get the base string and update based on that. + const dashNightlyPos = versionString.indexOf("-dev"); + if (dashNightlyPos >= 0) { + versionString = versionString.slice(0, dashNightlyPos); + } + + // We're going to append a representation of the current time at the end of the current version. + // String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ', + // but we'd prefer to just remove separators and limit ourselves to YYYYMMDD. + // UTC time will always be implicit here. + const now = new Date(); + const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8); + + return `${versionString}-dev.${timeStr}`; +} + +main(); \ No newline at end of file diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e839d6d6c9a..e842f9a4040 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -518,15 +518,21 @@ namespace ts { } else { declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); - - let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -1056,4 +1062,4 @@ namespace ts { : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } -} +} diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3fa77211e4b..e95a117d218 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -59,17 +59,21 @@ namespace ts { isArgumentsSymbol: symbol => symbol === argumentsSymbol, getDiagnostics, getGlobalDiagnostics, - getTypeOfSymbolAtLocation, + + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol, getPropertiesOfType, getPropertyOfType, getSignaturesOfType, getIndexTypeOfType, + getBaseTypes, getReturnTypeOfSignature, getSymbolsInScope, getSymbolAtLocation, getShorthandAssignmentValueSymbol, - getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString, getSymbolDisplayBuilder, symbolToString, @@ -159,8 +163,9 @@ namespace ts { let emitAwaiter = false; let emitGenerator = false; - let resolutionTargets: Object[] = []; + let resolutionTargets: TypeSystemEntity[] = []; let resolutionResults: boolean[] = []; + let resolutionPropertyNames: TypeSystemPropertyName[] = []; let mergedSymbols: Symbol[] = []; let symbolLinks: SymbolLinks[] = []; @@ -201,6 +206,15 @@ namespace ts { let assignableRelation: Map = {}; let identityRelation: Map = {}; + type TypeSystemEntity = Symbol | Type | Signature; + + const enum TypeSystemPropertyName { + Type, + ResolvedBaseConstructorType, + DeclaredType, + ResolvedReturnType + } + initializeTypeChecker(); return checker; @@ -1992,15 +2006,12 @@ namespace ts { } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -2189,35 +2200,69 @@ namespace ts { } } - // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, - // a new entry with that target and an associated result value of true is pushed on the stack, and the value - // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and - // all entries pushed after it are changed to false, and the value false is returned. The target object provides - // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of - // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and - // Signature instances are used to track resolution of Signature.resolvedReturnType. - function pushTypeResolution(target: Object): boolean { - let i = 0; - let count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target: TypeSystemEntity, propertyName: TypeSystemPropertyName): boolean { + let resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + let { length } = resolutionTargets; + for (let i = resolutionCycleStartIndex; i < length; i++) { + resolutionResults[i] = false; } - while (i < count); return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target: TypeSystemEntity, propertyName: TypeSystemPropertyName): number { + for (let i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + + return -1; + } + + function hasType(target: TypeSystemEntity, propertyName: TypeSystemPropertyName): Type { + if (propertyName === TypeSystemPropertyName.Type) { + return getSymbolLinks(target).type; + } + if (propertyName === TypeSystemPropertyName.DeclaredType) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) { + Debug.assert(!!((target).flags & TypeFlags.Class)); + return (target).resolvedBaseConstructorType; + } + if (propertyName === TypeSystemPropertyName.ResolvedReturnType) { + return (target).resolvedReturnType; + } + + Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } + // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. function popTypeResolution(): boolean { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } @@ -2480,7 +2525,7 @@ namespace ts { return links.type = checkExpression((declaration).expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { return unknownType; } let type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -2521,7 +2566,7 @@ namespace ts { function getTypeOfAccessors(symbol: Symbol): Type { let links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { return unknownType; } let getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); @@ -2737,7 +2782,7 @@ namespace ts { if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, TypeSystemPropertyName.ResolvedBaseConstructorType)) { return unknownType; } let baseConstructorType = checkExpression(baseTypeNode.expression); @@ -2864,7 +2909,7 @@ namespace ts { if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.DeclaredType)) { return unknownType; } let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); @@ -3080,44 +3125,57 @@ namespace ts { setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s: Signature[], t: Signature[]): boolean { - if (s.length !== t.length) { - return false; - } - for (let i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], /*compareReturnTypes*/ false, compareTypes)) { - return false; + function findMatchingSignature(signature: Signature, signatureList: Signature[]): Signature { + for (let s of signatureList) { + // Only signatures with no type parameters may differ in return types + if (compareSignatures(signature, s, /*compareReturnTypes*/ !!signature.typeParameters, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] { - let signatureLists = map(types, t => getSignaturesOfType(t, kind)); - let signatures = signatureLists[0]; - for (let signature of signatures) { - if (signature.typeParameters) { - return emptyArray; - } - } + function findMatchingSignatures(signature: Signature, signatureLists: Signature[][]): Signature[] { + let result: Signature[] = undefined; for (let i = 1; i < signatureLists.length; i++) { - if (!signatureListsIdentical(signatures, signatureLists[i])) { - return emptyArray; + let match = findMatchingSignature(signature, signatureLists[i]); + if (!match) { + return undefined; + } + if (!result) { + result = [signature]; + } + if (match !== signature) { + result.push(match); } - } - let result = map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - let s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = map(signatureLists, signatures => signatures[i]); } return result; } + // The signatures of a union type are those signatures that are present and identical in each of the + // constituent types, except that non-generic signatures may differ in return types. When signatures + // differ in return types, the resulting return type is the union of the constituent return types. + function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] { + let signatureLists = map(types, t => getSignaturesOfType(t, kind)); + let result: Signature[] = undefined; + for (let source of signatureLists[0]) { + let unionSignatures = findMatchingSignatures(source, signatureLists); + if (unionSignatures) { + let signature: Signature = undefined; + if (unionSignatures.length === 1 || source.typeParameters) { + signature = source; + } + else { + signature = cloneSignature(source); + // Clear resolved return type we possibly got from cloneSignature + signature.resolvedReturnType = undefined; + signature.unionSignatures = unionSignatures; + } + (result || (result = [])).push(signature); + } + } + return result || emptyArray; + } + function getUnionIndexType(types: Type[], kind: IndexKind): Type { let indexTypes: Type[] = []; for (let type of types) { @@ -3275,9 +3333,6 @@ namespace ts { * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type: Type): Type { - if (type.flags & TypeFlags.Union) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & TypeFlags.TypeParameter) { do { type = getConstraintOfTypeParameter(type); @@ -3382,6 +3437,29 @@ namespace ts { return undefined; } + // Check if a property with the given name is known anywhere in the given type. In an object + // type, a property is considered known if the object type is empty, if it has any index + // signatures, or if the property is actually declared in the type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type: Type, name: string): boolean { + if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { + var resolved = resolveStructuredTypeMembers(type); + return !!(resolved.properties.length === 0 || + resolved.stringIndexType || + resolved.numberIndexType || + getPropertyOfType(type, name)); + } + if (type.flags & TypeFlags.UnionOrIntersection) { + for (let t of (type).types) { + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { let resolved = resolveStructuredTypeMembers(type); @@ -3551,7 +3629,7 @@ namespace ts { function getReturnTypeOfSignature(signature: Signature): Type { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) { return unknownType; } let type: Type; @@ -3991,26 +4069,79 @@ namespace ts { } } - function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean { + let sourceProperties = getPropertiesOfObjectType(source); + let targetProperties = getPropertiesOfObjectType(target); + if (sourceProperties.length !== targetProperties.length) { + return false; + } + for (let sourceProp of sourceProperties) { + let targetProp = getPropertyOfObjectType(target, sourceProp.name); + if (!targetProp || + getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) || + !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { + return false; + } + } + return true; + } + + function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean { + let sourceTypes = source.elementTypes; + let targetTypes = target.elementTypes; + if (sourceTypes.length !== targetTypes.length) { + return false; + } + for (var i = 0; i < sourceTypes.length; i++) { + if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { + return false; + } + } + return true; + } + + // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of + // a target type if the the two are identical, with the exception that the source type may have null or + // undefined in places where the target type doesn't. This is by design an asymmetric relationship. + function isTypeDuplicateOf(source: Type, target: Type): boolean { + if (source === target) { + return true; + } + if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) { + return true; + } + if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) { + return isObjectLiteralTypeDuplicateOf(source, target); + } + if (isArrayType(source) && isArrayType(target)) { + return isTypeDuplicateOf((source).typeArguments[0], (target).typeArguments[0]); + } + if (isTupleType(source) && isTupleType(target)) { + return isTupleTypeDuplicateOf(source, target); + } + return isTypeIdenticalTo(source, target); + } + + function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean { for (let type of types) { - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeDuplicateOf(candidate, type)) { return true; } } return false; } - function removeSubtypes(types: Type[]) { + function removeDuplicateTypes(types: Type[]) { let i = types.length; while (i > 0) { i--; - if (isSubtypeOfAny(types[i], types)) { + if (isTypeDuplicateOfSomeType(types[i], types)) { types.splice(i, 1); } } } - function containsTypeAny(types: Type[]) { + function containsTypeAny(types: Type[]): boolean { for (let type of types) { if (isTypeAny(type)) { return true; @@ -4029,30 +4160,26 @@ namespace ts { } } - function compareTypeIds(type1: Type, type2: Type): number { - return type1.id - type2.id; - } - - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. - function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { + // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate + // based on the structure of the types unless the noDeduplication flag is true, which is the case when + // creating a union type from a type node and when instantiating a union type. In both of those cases, + // structural deduplication has to be deferred to properly support recursive union types. For example, + // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. + function getUnionType(types: Type[], noDeduplication?: boolean): Type { if (types.length === 0) { return emptyObjectType; } let typeSet: Type[] = []; addTypesToSet(typeSet, types, TypeFlags.Union); - typeSet.sort(compareTypeIds); - if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } + if (containsTypeAny(typeSet)) { + return anyType; + } + if (noDeduplication) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeSubtypes(typeSet); + removeDuplicateTypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -4062,38 +4189,19 @@ namespace ts { if (!type) { type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type: UnionType): Type { - if (!type.reducedType) { - type.reducedType = circularType; - let reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } - function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { let links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -4196,7 +4304,7 @@ namespace ts { // Callers should first ensure this by calling isTypeNode case SyntaxKind.Identifier: case SyntaxKind.QualifiedName: - let symbol = getSymbolInfo(node); + let symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -4374,7 +4482,7 @@ namespace ts { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } if (type.flags & TypeFlags.Union) { - return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noDeduplication*/ true); } if (type.flags & TypeFlags.Intersection) { return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); @@ -4519,6 +4627,16 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message: DiagnosticMessage, source: Type, target: Type) { + let sourceType = typeToString(source); + let targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); + } + reportError(message || Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } + // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -4538,7 +4656,23 @@ namespace ts { if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True; } } + + if (relation !== identityRelation && source.flags & TypeFlags.FreshObjectLiteral) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return Ternary.False; + } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + source = getRegularTypeOfObjectLiteral(source); + } + let saveErrorInfo = errorInfo; + if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { @@ -4615,18 +4749,22 @@ namespace ts { } if (reportErrors) { - headMessage = headMessage || Diagnostics.Type_0_is_not_assignable_to_type_1; - let sourceType = typeToString(source); - let targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); - targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return Ternary.False; } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { + for (let prop of getPropertiesOfObjectType(source)) { + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; let sourceTypes = source.types; @@ -5323,6 +5461,24 @@ namespace ts { return !!(type.flags & TypeFlags.Tuple); } + function getRegularTypeOfObjectLiteral(type: Type): Type { + if (type.flags & TypeFlags.FreshObjectLiteral) { + let regularType = (type).regularType; + if (!regularType) { + regularType = createType((type).flags & ~TypeFlags.FreshObjectLiteral); + regularType.symbol = (type).symbol; + regularType.members = (type).members; + regularType.properties = (type).properties; + regularType.callSignatures = (type).callSignatures; + regularType.constructSignatures = (type).constructSignatures; + regularType.stringIndexType = (type).stringIndexType; + regularType.numberIndexType = (type).numberIndexType; + } + return regularType; + } + return type; + } + function getWidenedTypeOfObjectLiteral(type: Type): Type { let properties = getPropertiesOfObjectType(type); let members: SymbolTable = {}; @@ -5853,47 +6009,6 @@ namespace ts { } } - function resolveLocation(node: Node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - let containerNodes: Node[] = []; - for (let parent = node.parent; parent; parent = parent.parent) { - if ((isExpression(parent) || isObjectLiteralMethod(node)) && - isContextSensitive(parent)) { - containerNodes.unshift(parent); - } - } - - ts.forEach(containerNodes, node => { getTypeOfNode(node); }); - } - - function getSymbolAtLocation(node: Node): Symbol { - resolveLocation(node); - return getSymbolInfo(node); - } - - function getTypeAtLocation(node: Node): Type { - resolveLocation(node); - return getTypeOfNode(node); - } - - function getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } - // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { let type = getTypeOfSymbol(symbol); @@ -6990,7 +7105,7 @@ namespace ts { let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull); + result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull); return result; function getIndexType(kind: IndexKind) { @@ -7221,10 +7336,9 @@ namespace ts { * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node: JsxOpeningLikeElement) { - if (!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), 'Should not call getJsxElementInstanceType on non-class Element'); let classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { @@ -7247,16 +7361,11 @@ namespace ts { if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - let returnType = getUnionType(signatures.map(s => getReturnTypeOfSignature(s))); - if (!isTypeAny(returnType) && !(returnType.flags & TypeFlags.ObjectType)) { - error(node.tagName, Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + let returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass let elemClassType = getJsxGlobalElementClassType(); @@ -7317,7 +7426,7 @@ namespace ts { let elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } let propsName = getJsxElementPropertiesName(); @@ -8522,6 +8631,9 @@ namespace ts { if (!produceDiagnostics) { for (let candidate of candidates) { if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -8870,7 +8982,7 @@ namespace ts { } function checkAssertion(node: AssertionExpression) { - let exprType = checkExpression(node.expression); + let exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); let targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { let widenedType = getWidenedType(exprType); @@ -9695,7 +9807,7 @@ namespace ts { return getUnionType([leftType, rightType]); case SyntaxKind.EqualsToken: checkAssignmentOperator(rightType); - return rightType; + return getRegularTypeOfObjectLiteral(rightType); case SyntaxKind.CommaToken: return rightType; } @@ -10120,7 +10232,7 @@ namespace ts { } else { checkTypeAssignableTo(typePredicate.type, - getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), + getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } @@ -10331,10 +10443,19 @@ namespace ts { // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (getClassExtendsHeritageClauseElement(node.parent)) { + let containingClassDecl = node.parent; + if (getClassExtendsHeritageClauseElement(containingClassDecl)) { + let containingClassSymbol = getSymbolOfNode(containingClassDecl); + let containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + let baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. @@ -10342,18 +10463,30 @@ namespace ts { forEach((node.parent).members, isInstancePropertyWithInitializer) || forEach(node.parameters, p => p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { let statements = (node.body).statements; - if (!statements.length || statements[0].kind !== SyntaxKind.ExpressionStatement || !isSuperCallExpression((statements[0]).expression)) { - error(node, Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + let superCallStatement: ExpressionStatement; + for (let statement of statements) { + if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((statement).expression)) { + superCallStatement = statement; + break; + } + if (!isPrologueDirective(statement)) { + break; + } } + if (!superCallStatement) { + error(node, Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); + } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors((statements[0]).expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -10744,9 +10877,6 @@ namespace ts { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. - // if localSymbol is defined on node then node itself is exported - check is required let symbol = node.localSymbol; if (!symbol) { @@ -10766,27 +10896,45 @@ namespace ts { // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - let exportedDeclarationSpaces: SymbolFlags = 0; - let nonExportedDeclarationSpaces: SymbolFlags = 0; - forEach(symbol.declarations, d => { + let exportedDeclarationSpaces = SymbolFlags.None; + let nonExportedDeclarationSpaces = SymbolFlags.None; + let defaultExportedDeclarationSpaces = SymbolFlags.None; + for (let d of symbol.declarations) { let declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, NodeFlags.Export)) { - exportedDeclarationSpaces |= declarationSpaces; + let effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, NodeFlags.Export | NodeFlags.Default); + + if (effectiveDeclarationFlags & NodeFlags.Export) { + if (effectiveDeclarationFlags & NodeFlags.Default) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); + } - let commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + // Spaces for anyting not declared a 'default export'. + let nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + + let commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + let commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; - if (commonDeclarationSpace) { + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - forEach(symbol.declarations, d => { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (let d of symbol.declarations) { + let declarationSpaces = getDeclarationSpaces(d); + + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d: Declaration): SymbolFlags { @@ -12631,28 +12779,7 @@ namespace ts { } let initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -12666,8 +12793,36 @@ namespace ts { nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed; } - function getConstantValueForEnumMemberInitializer(initializer: Expression): number { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer: Expression, enumType: Type, enumIsConst: boolean, ambient: boolean): number { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + let reportError = true; + let value = evalConstant(initializer); + + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + + return value; function evalConstant(e: Node): number { switch (e.kind) { @@ -12776,6 +12931,8 @@ namespace ts { // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); return undefined; } @@ -13742,7 +13899,7 @@ namespace ts { return undefined; } - function getSymbolInfo(node: Node) { + function getSymbolAtLocation(node: Node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -13762,7 +13919,7 @@ namespace ts { else if (node.parent.kind === SyntaxKind.BindingElement && node.parent.parent.kind === SyntaxKind.ObjectBindingPattern && node === (node.parent).propertyName) { - let typeOfPattern = getTypeAtLocation(node.parent.parent); + let typeOfPattern = getTypeOfNode(node.parent.parent); let propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, (node).text); if (propertyDeclaration) { @@ -13845,24 +14002,24 @@ namespace ts { } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration let symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - let symbol = getSymbolInfo(node); + let symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration let symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (isDeclarationName(node)) { - let symbol = getSymbolInfo(node); + let symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } @@ -13871,7 +14028,7 @@ namespace ts { } if (isInRightSideOfImportOrExportAssignment(node)) { - let symbol = getSymbolInfo(node); + let symbol = getSymbolAtLocation(node); let declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -14040,7 +14197,11 @@ namespace ts { return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & SymbolFlags.Value && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s: Symbol): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a0a95d47c8c..5ccc0a0db9b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -254,6 +254,7 @@ namespace ts { Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -293,7 +294,7 @@ namespace ts { Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -424,6 +425,8 @@ namespace ts { JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -508,7 +511,6 @@ namespace ts { Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, @@ -613,5 +615,6 @@ namespace ts { Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index acf4e74ae9f..e138e2ddac4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1,4 +1,4 @@ -{ + { "Unterminated string literal.": { "category": "Error", "code": 1002 @@ -1005,6 +1005,10 @@ "category": "Error", "code": 2352 }, + "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'.": { + "category": "Error", + "code": 2353 + }, "No best common type exists among return expressions.": { "category": "Error", "code": 2354 @@ -1161,7 +1165,7 @@ "category": "Error", "code": 2394 }, - "Individual declarations in merged declaration {0} must be all exported or all local.": { + "Individual declarations in merged declaration '{0}' must be all exported or all local.": { "category": "Error", "code": 2395 }, @@ -1685,6 +1689,14 @@ "category": "Error", "code": 2650 }, + "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": { + "category": "Error", + "code": 2651 + }, + "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": { + "category": "Error", + "code": 2652 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2021,10 +2033,6 @@ "category": "Error", "code": 5042 }, - "Option 'sourceMap' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5043 - }, "Option 'declaration' cannot be specified with option 'isolatedModules'.": { "category": "Error", "code": 5044 @@ -2445,5 +2453,9 @@ "Cannot use JSX unless the '--jsx' flag is provided.": { "category": "Error", "code": 17004 + }, + "A constructor cannot contain a 'super' call when its class extends 'null'": { + "category": "Error", + "code": 17005 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2c235f9fdca..7b3b51c3f27 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case SyntaxKind.IfStatement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxExpression: case SyntaxKind.NewExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PostfixUnaryExpression: @@ -3012,6 +3013,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return result; } + function emitEs6ExportDefaultCompat(node: Node) { + if (node.parent.kind === SyntaxKind.SourceFile) { + Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment); + // only allow export default at a source file level + if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === ScriptTarget.ES5) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === ScriptTarget.ES3) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } + function emitExportMemberAssignment(node: FunctionLikeDeclaration | ClassDeclaration) { if (node.flags & NodeFlags.Export) { writeLine(); @@ -3034,9 +3055,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else { if (node.flags & NodeFlags.Default) { + emitEs6ExportDefaultCompat(node); if (languageVersion === ScriptTarget.ES3) { write("exports[\"default\"]"); - } else { + } + else { write("exports.default"); } } @@ -5407,17 +5430,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + + if (!variableDeclarationIsHoisted) { + Debug.assert(!isExported); + + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & NodeFlags.Export)) { + write("var "); + } } - else if (!(node.flags & NodeFlags.Export)) { - write("var "); + + + if (isExported) { + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(node.name); + write(`", `); } + emitModuleMemberName(node); write(" = "); emit(node.moduleReference); - write(";"); + + if (isExported) { + write(")"); + } + + write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); @@ -5538,6 +5587,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === ScriptTarget.ES3) { write("[\"default\"] = "); @@ -5756,6 +5806,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(`function ${exportStarFunction}(m) {`); increaseIndent(); writeLine(); + write(`var exports = {};`); + writeLine(); write(`for(var n in m) {`); increaseIndent(); writeLine(); @@ -5763,10 +5815,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (localNames) { write(`&& !${localNames}.hasOwnProperty(n)`); } - write(`) ${exportFunctionForFile}(n, m[n]);`); + write(`) exports[n] = m[n];`); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(`${exportFunctionForFile}(exports);`) decreaseIndent(); writeLine(); write("}"); @@ -5938,6 +5992,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return; } + + if (isInternalModuleImportEqualsDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node.name); + return; + } if (isBindingPattern(node)) { forEach((node).elements, visit); @@ -6099,16 +6162,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if ((importNode).exportClause) { // export {a, b as c} from 'foo' // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) + // var reexports = {} + // reexports['a'] = _foo["a"]; + // reexports['c'] = _foo["b"]; + // exports_(reexports); + let reexportsVariableName = makeUniqueName("reexports"); + writeLine(); + write(`var ${reexportsVariableName} = {};`) + writeLine(); for (let e of (importNode).exportClause.elements) { - writeLine(); - write(`${exportFunctionForFile}("`); + write(`${reexportsVariableName}["`); emitNodeWithoutSourceMap(e.name); - write(`", ${parameterName}["`); + write(`"] = ${parameterName}["`); emitNodeWithoutSourceMap(e.propertyName || e.name); - write(`"]);`); + write(`"];`); + writeLine(); } + write(`${exportFunctionForFile}(${reexportsVariableName});`); } else { writeLine(); @@ -6135,14 +6205,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); for (let i = startIndex; i < node.statements.length; ++i) { let statement = node.statements[i]; - // - imports/exports are not emitted for system modules + // - external module related imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { case SyntaxKind.ExportDeclaration: case SyntaxKind.ImportDeclaration: - case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.FunctionDeclaration: continue; + case SyntaxKind.ImportEqualsDeclaration: + if (!isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } } writeLine(); emit(statement); @@ -6768,6 +6841,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } + /** + * Removes all but the pinned or triple slash comments. + * @param ranges The array to be filtered + * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. + */ function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] { // If we're removing comments, then we want to strip out all but the pinned or // triple slash comments. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5ce4846b43b..4b1f10eb649 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -8,7 +8,7 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - export const version = "1.5.3"; + export const version = "1.6.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; @@ -341,7 +341,7 @@ namespace ts { }); } - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { if (!isDeclarationFile(sourceFile)) { let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); @@ -350,7 +350,7 @@ namespace ts { return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } }); - } + } function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; @@ -602,10 +602,6 @@ namespace ts { function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } - if (options.declaration) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a657cc8c314..6872c4c876e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -3,7 +3,7 @@ namespace ts { export interface SourceFile { - fileWatcher: FileWatcher; + fileWatcher?: FileWatcher; } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f1b476d11b4..ba7aceb856d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1404,6 +1404,7 @@ namespace ts { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1762,10 +1763,12 @@ namespace ts { FromSignature = 0x00040000, // Created for signature assignment check ObjectLiteral = 0x00080000, // Originates in an object literal /* @internal */ - ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type + FreshObjectLiteral = 0x00100000, // Fresh object literal type /* @internal */ - ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type - ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6 + ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type + /* @internal */ + ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type + ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6 /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1774,10 +1777,10 @@ namespace ts { StringLike = String | StringLiteral, NumberLike = Number | Enum, ObjectType = Class | Interface | Reference | Tuple | Anonymous, - UnionOrIntersection = Union | Intersection, + UnionOrIntersection = Union | Intersection, StructuredType = ObjectType | Union | Intersection, /* @internal */ - RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral + RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral } // Properties common to all types @@ -1806,7 +1809,9 @@ namespace ts { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none) localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none) + /* @internal */ resolvedBaseConstructorType?: Type; // Resolved base constructor type of class + /* @internal */ resolvedBaseTypes: ObjectType[]; // Resolved base types } @@ -1858,6 +1863,14 @@ namespace ts { numberIndexType?: Type; // Numeric index type } + /* @internal */ + // Object literals are initially marked fresh. Freshness disappears following an assignment, + // before a type assertion, or when when an object literal's type is widened. The regular + // version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag. + export interface FreshObjectLiteralType extends ResolvedType { + regularType: ResolvedType; // Regular version of fresh type + } + // Just a place to cache element types of iterables and iterators /* @internal */ export interface IterableOrIteratorType extends ObjectType, UnionType { @@ -2211,6 +2224,7 @@ namespace ts { export interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9d7877ca6e3..56eb2415cf9 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -965,7 +965,7 @@ namespace ts { return ((node).moduleReference).expression; } - export function isInternalModuleImportEqualsDeclaration(node: Node) { + export function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { return node.kind === SyntaxKind.ImportEqualsDeclaration && (node).moduleReference.kind !== SyntaxKind.ExternalModuleReference; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5c8e6bc8981..272f4c1c1dd 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -26,9 +26,8 @@ module FourSlash { export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) content: string; - fileName: string; - + version: number; // File-specific options (name/value pairs) fileOptions: { [index: string]: string; }; } @@ -1876,7 +1875,7 @@ module FourSlash { } } - private verifyProjectInfo(expected: string[]) { + public verifyProjectInfo(expected: string[]) { if (this.testType === FourSlashTestType.Server) { let actual = (this.languageService).getProjectInfo( this.activeFile.fileName, @@ -2058,11 +2057,8 @@ module FourSlash { return result; } - public verifGetScriptLexicalStructureListContains( - name: string, - kind: string, - markerPosition?: number) { - this.taoInvalidReason = 'verifGetScriptLexicalStructureListContains impossible'; + public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { + this.taoInvalidReason = 'verifyGetScriptLexicalStructureListContains impossible'; let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); @@ -2264,7 +2260,7 @@ module FourSlash { return 'line ' + (pos.line + 1) + ', col ' + pos.character; } - private getMarkerByName(markerName: string) { + public getMarkerByName(markerName: string) { let markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { let markerNames: string[] = []; @@ -2739,4 +2735,4 @@ module FourSlash { fileName: fileName }; } -} +} \ No newline at end of file diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 17aa0dd325c..b6c10071cb1 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -29,6 +29,7 @@ var Buffer: BufferConstructor = require('buffer').Buffer; // this will work in the browser via browserify var _chai: typeof chai = require('chai'); var assert: typeof _chai.assert = _chai.assert; +var expect: typeof _chai.expect = _chai.expect; declare var __dirname: string; // Node-specific var global = Function("return this").call(null); diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 0ce567e9563..c7b57a7d51f 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -12,6 +12,7 @@ interface FindFileResult { } interface IOLog { + timestamp: string; arguments: string[]; executingPath: string; currentDirectory: string; diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 66438d938dd..406ca7caeae 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -1,6 +1,6 @@ /// -class RunnerBase { +abstract class RunnerBase { constructor() { } // contains the tests to run @@ -18,9 +18,7 @@ class RunnerBase { /** Setup the runner's tests so that they are ready to be executed by the harness * The first test should be a describe/it block that sets up the harness's compiler instance appropriately */ - public initializeTests(): void { - throw new Error('method not implemented'); - } + public abstract initializeTests(): void; /** Replaces instances of full paths with fileNames only */ static removeFullPaths(path: string) { diff --git a/src/server/client.ts b/src/server/client.ts index e4a524dd210..3ad7230cf33 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -202,9 +202,7 @@ namespace ts.server { return { isMemberCompletion: false, isNewIdentifierLocation: false, - entries: response.body, - fileName: fileName, - position: position + entries: response.body }; } diff --git a/src/server/session.ts b/src/server/session.ts index d2ac429aa3c..9a5cee32264 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -109,13 +109,13 @@ namespace ts.server { } export class Session { - projectService: ProjectService; - pendingOperation = false; - fileHash: ts.Map = {}; - nextFileId = 1; - errorTimer: any; /*NodeJS.Timer | number*/ - immediateId: any; - changeSeq = 0; + protected projectService: ProjectService; + private pendingOperation = false; + private fileHash: ts.Map = {}; + private nextFileId = 1; + private errorTimer: any; /*NodeJS.Timer | number*/ + private immediateId: any; + private changeSeq = 0; constructor( private host: ServerHost, @@ -129,7 +129,7 @@ namespace ts.server { }); } - handleEvent(eventName: string, project: Project, fileName: string) { + private handleEvent(eventName: string, project: Project, fileName: string) { if (eventName == "context") { this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); this.updateErrorCheck([{ fileName, project }], this.changeSeq, @@ -137,7 +137,7 @@ namespace ts.server { } } - logError(err: Error, cmd: string) { + public logError(err: Error, cmd: string) { var typedErr = err; var msg = "Exception on executing command " + cmd; if (typedErr.message) { @@ -149,11 +149,11 @@ namespace ts.server { this.projectService.log(msg); } - sendLineToClient(line: string) { + private sendLineToClient(line: string) { this.host.write(line + this.host.newLine); } - send(msg: protocol.Message) { + public send(msg: protocol.Message) { var json = JSON.stringify(msg); if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); @@ -162,7 +162,7 @@ namespace ts.server { '\r\n\r\n' + json); } - event(info: any, eventName: string) { + public event(info: any, eventName: string) { var ev: protocol.Event = { seq: 0, type: "event", @@ -172,7 +172,7 @@ namespace ts.server { this.send(ev); } - response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) { + private response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) { var res: protocol.Response = { seq: 0, type: "response", @@ -189,11 +189,11 @@ namespace ts.server { this.send(res); } - output(body: any, commandName: string, requestSequence = 0, errorMessage?: string) { + public output(body: any, commandName: string, requestSequence = 0, errorMessage?: string) { this.response(body, commandName, requestSequence, errorMessage); } - semanticCheck(file: string, project: Project) { + private semanticCheck(file: string, project: Project) { try { var diags = project.compilerService.languageService.getSemanticDiagnostics(file); @@ -207,7 +207,7 @@ namespace ts.server { } } - syntacticCheck(file: string, project: Project) { + private syntacticCheck(file: string, project: Project) { try { var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); if (diags) { @@ -220,12 +220,12 @@ namespace ts.server { } } - errorCheck(file: string, project: Project) { + private errorCheck(file: string, project: Project) { this.syntacticCheck(file, project); this.semanticCheck(file, project); } - updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { + private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { setTimeout(() => { if (matchSeq(seq)) { this.projectService.updateProjectStructure(); @@ -233,7 +233,7 @@ namespace ts.server { }, ms); } - updateErrorCheck(checkList: PendingErrorCheck[], seq: number, + private updateErrorCheck(checkList: PendingErrorCheck[], seq: number, matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200) { if (followMs > ms) { followMs = ms; @@ -269,7 +269,7 @@ namespace ts.server { } } - getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { + private getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -291,7 +291,7 @@ namespace ts.server { })); } - getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { + private getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -313,7 +313,7 @@ namespace ts.server { })); } - getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[]{ + private getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[]{ fileName = ts.normalizePath(fileName); let project = this.projectService.getProjectForFile(fileName); @@ -343,7 +343,7 @@ namespace ts.server { }); } - getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo { + private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo { fileName = ts.normalizePath(fileName) let project = this.projectService.getProjectForFile(fileName) @@ -358,7 +358,7 @@ namespace ts.server { return projectInfo; } - getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { + private getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -426,7 +426,7 @@ namespace ts.server { return { info: renameInfo, locs: bakedRenameLocs }; } - getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody { + private getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody { // TODO: get all projects for this file; report refs for all projects deleting duplicates // can avoid duplicates by eliminating same ref file from subsequent projects var file = ts.normalizePath(fileName); @@ -473,12 +473,12 @@ namespace ts.server { }; } - openClientFile(fileName: string) { + private openClientFile(fileName: string) { var file = ts.normalizePath(fileName); this.projectService.openClientFile(file); } - getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody { + private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -504,7 +504,7 @@ namespace ts.server { }; } - getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] { + private getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -531,7 +531,7 @@ namespace ts.server { }); } - getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] { + private getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -607,7 +607,7 @@ namespace ts.server { }); } - getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] { + private getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] { if (!prefix) { prefix = ""; } @@ -633,7 +633,7 @@ namespace ts.server { }, []).sort((a, b) => a.name.localeCompare(b.name)); } - getCompletionEntryDetails(line: number, offset: number, + private getCompletionEntryDetails(line: number, offset: number, entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -653,7 +653,7 @@ namespace ts.server { }, []); } - getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems { + private getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -682,7 +682,7 @@ namespace ts.server { return result; } - getDiagnostics(delay: number, fileNames: string[]) { + private getDiagnostics(delay: number, fileNames: string[]) { var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -697,7 +697,7 @@ namespace ts.server { } } - change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) { + private change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (project) { @@ -712,7 +712,7 @@ namespace ts.server { } } - reload(fileName: string, tempFileName: string, reqSeq = 0) { + private reload(fileName: string, tempFileName: string, reqSeq = 0) { var file = ts.normalizePath(fileName); var tmpfile = ts.normalizePath(tempFileName); var project = this.projectService.getProjectForFile(file); @@ -725,7 +725,7 @@ namespace ts.server { } } - saveToTmp(fileName: string, tempFileName: string) { + private saveToTmp(fileName: string, tempFileName: string) { var file = ts.normalizePath(fileName); var tmpfile = ts.normalizePath(tempFileName); @@ -735,12 +735,12 @@ namespace ts.server { } } - closeClientFile(fileName: string) { + private closeClientFile(fileName: string) { var file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); } - decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] { + private decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] { if (!items) { return undefined; } @@ -759,7 +759,7 @@ namespace ts.server { })); } - getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] { + private getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -775,7 +775,7 @@ namespace ts.server { return this.decorateNavigationBarItem(project, fileName, items); } - getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] { + private getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -814,7 +814,7 @@ namespace ts.server { }); } - getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] { + private getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); @@ -836,7 +836,7 @@ namespace ts.server { })); } - exit() { + public exit() { } private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { @@ -942,14 +942,14 @@ namespace ts.server { return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, }; - addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { + public addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { if (this.handlers[command]) { throw new Error(`Protocol handler already exists for command "${command}"`); } this.handlers[command] = handler; } - executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} { + public executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} { var handler = this.handlers[request.command]; if (handler) { return handler(request); @@ -960,7 +960,7 @@ namespace ts.server { } } - onMessage(message: string) { + public onMessage(message: string) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); var start = this.hrtime(); diff --git a/src/services/services.ts b/src/services/services.ts index c2432816f24..8e670268498 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -48,6 +48,7 @@ namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[] } export interface Signature { @@ -260,26 +261,25 @@ namespace ts { } public getFirstToken(sourceFile?: SourceFile): Node { - let children = this.getChildren(); - for (let child of children) { - if (child.kind < SyntaxKind.FirstNode) { - return child; - } - - return child.getFirstToken(sourceFile); + let children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + + let child = children[0]; + + return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile); } public getLastToken(sourceFile?: SourceFile): Node { let children = this.getChildren(sourceFile); - for (let i = children.length - 1; i >= 0; i--) { - let child = children[i]; - if (child.kind < SyntaxKind.FirstNode) { - return child; - } - return child.getLastToken(sourceFile); + let child = lastOrUndefined(children); + if (!child) { + return undefined; } + + return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); } } @@ -682,6 +682,11 @@ namespace ts { getNumberIndexType(): Type { return this.checker.getIndexTypeOfType(this, IndexKind.Number); } + getBaseTypes(): ObjectType[] { + return this.flags & (TypeFlags.Class | TypeFlags.Interface) + ? this.checker.getBaseTypes(this) + : undefined; + } } class SignatureObject implements Signature { @@ -1105,6 +1110,7 @@ namespace ts { } export interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1411,7 +1417,9 @@ namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void + releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + + reportStats(): string; } // TODO: move these to enums @@ -1751,18 +1759,31 @@ namespace ts { sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - + + export interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + } + + export interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true - */ - export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string { - let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions(); + */ + export function transpileModule(input: string, transpileOptions?: TranspileOptions): TranspileOutput { + let options = transpileOptions.compilerOptions ? clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; @@ -1778,23 +1799,30 @@ namespace ts { options.noResolve = true; // Parse - let inputFileName = fileName || "module.ts"; + let inputFileName = transpileOptions.fileName || "module.ts"; let sourceFile = createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } let newLine = getNewLineCharacter(options); // Output let outputText: string; + let sourceMapText: string; // Create a compilerHost object to allow the compiler to read and write files let compilerHost: CompilerHost = { getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { - Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (fileExtensionIs(name, ".map")) { + Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); + sourceMapText = text; + } + else { + Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: () => "lib.d.ts", useCaseSensitiveFileNames: () => false, @@ -1804,16 +1832,29 @@ namespace ts { }; let program = createProgram([inputFileName], options, compilerHost); - - addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); - addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); - + + let diagnostics: Diagnostic[]; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText, diagnostics, sourceMapText }; + } + + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string { + let output = transpileModule(input, { compilerOptions, fileName, reportDiagnostics: !!diagnostics, moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + addRange(diagnostics, output.diagnostics); + return output.outputText; } export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile { diff --git a/src/services/shims.ts b/src/services/shims.ts index e2055b3de77..ae853e1c72a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -454,11 +454,11 @@ namespace ts { } } - export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; } []{ + export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; code: number; } []{ return diagnostics.map(d => realizeDiagnostic(d, newLine)); } - function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; } { + function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; code: number; } { return { message: flattenDiagnosticMessageText(diagnostic.messageText, newLine), start: diagnostic.start, diff --git a/tests/baselines/reference/ES5For-of30.errors.txt b/tests/baselines/reference/ES5For-of30.errors.txt index e99b8284bf3..ee2d14a4f58 100644 --- a/tests/baselines/reference/ES5For-of30.errors.txt +++ b/tests/baselines/reference/ES5For-of30.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type. +tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'number | string' is not an array type. tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'. @@ -8,7 +8,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error var tuple: [number, string] = [2, "3"]; for ([a = 1, b = ""] of tuple) { ~~~~~~~~~~~~~~~ -!!! error TS2461: Type 'string | number' is not an array type. +!!! error TS2461: Type 'number | string' is not an array type. ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. ~ diff --git a/tests/baselines/reference/ES5For-ofTypeCheck11.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck11.errors.txt index 635bb09616a..57a28b6612c 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck11.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'number | string' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. @@ -7,5 +7,5 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6) var v: string; for (v of union) { } ~ -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number | string' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck5.types b/tests/baselines/reference/ES5For-ofTypeCheck5.types index ed3d13f3918..f24aa54c7f3 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck5.types +++ b/tests/baselines/reference/ES5For-ofTypeCheck5.types @@ -3,6 +3,6 @@ var union: string | number[]; >union : string | number[] for (var v of union) { } ->v : string | number +>v : number | string >union : string | number[] diff --git a/tests/baselines/reference/ES5For-ofTypeCheck9.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck9.errors.txt index 156eb188803..3f382d72a08 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck9.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck9.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'number | symbol | string[]' is not an array type. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'string[] | number | symbol' is not an array type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts (1 errors) ==== var union: string | string[] | number | symbol; for (let v of union) { } ~~~~~ -!!! error TS2461: Type 'number | symbol | string[]' is not an array type. \ No newline at end of file +!!! error TS2461: Type 'string[] | number | symbol' is not an array type. \ No newline at end of file diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.types b/tests/baselines/reference/TypeGuardWithEnumUnion.types index 61cce562ba5..453ec220f02 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.types +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.types @@ -6,14 +6,14 @@ enum Color { R, G, B } >B : Color function f1(x: Color | string) { ->f1 : (x: string | Color) => void ->x : string | Color +>f1 : (x: Color | string) => void +>x : Color | string >Color : Color if (typeof x === "number") { >typeof x === "number" : boolean >typeof x : string ->x : string | Color +>x : Color | string >"number" : string var y = x; @@ -35,14 +35,14 @@ function f1(x: Color | string) { } function f2(x: Color | string | string[]) { ->f2 : (x: string | Color | string[]) => void ->x : string | Color | string[] +>f2 : (x: Color | string | string[]) => void +>x : Color | string | string[] >Color : Color if (typeof x === "object") { >typeof x === "object" : boolean >typeof x : string ->x : string | Color | string[] +>x : Color | string | string[] >"object" : string var y = x; @@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) { if (typeof x === "number") { >typeof x === "number" : boolean >typeof x : string ->x : string | Color | string[] +>x : Color | string | string[] >"number" : string var z = x; @@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) { if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | Color | string[] +>x : Color | string | string[] >"string" : string var a = x; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index e7ca8639762..f009e7084eb 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -34,7 +34,7 @@ var d2: IHasVisualizationModel = i || moduleA; var d2: IHasVisualizationModel = moduleA || i; >d2 : IHasVisualizationModel >IHasVisualizationModel : IHasVisualizationModel ->moduleA || i : IHasVisualizationModel +>moduleA || i : typeof moduleA >moduleA : typeof moduleA >i : IHasVisualizationModel diff --git a/tests/baselines/reference/aliasesInSystemModule1.errors.txt b/tests/baselines/reference/aliasesInSystemModule1.errors.txt new file mode 100644 index 00000000000..9b89332e458 --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule1.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/aliasesInSystemModule1.ts(2,24): error TS2307: Cannot find module 'foo'. + + +==== tests/cases/compiler/aliasesInSystemModule1.ts (1 errors) ==== + + import alias = require('foo'); + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + import cls = alias.Class; + export import cls2 = alias.Class; + + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); + + module M { + export import cls = alias.Class; + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/aliasesInSystemModule1.js b/tests/baselines/reference/aliasesInSystemModule1.js new file mode 100644 index 00000000000..28ac1e9b4ad --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule1.js @@ -0,0 +1,42 @@ +//// [aliasesInSystemModule1.ts] + +import alias = require('foo'); +import cls = alias.Class; +export import cls2 = alias.Class; + +let x = new alias.Class(); +let y = new cls(); +let z = new cls2(); + +module M { + export import cls = alias.Class; + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); +} + + +//// [aliasesInSystemModule1.js] +System.register(['foo'], function(exports_1) { + var alias; + var cls, cls2, x, y, z, M; + return { + setters:[ + function (_alias) { + alias = _alias; + }], + execute: function() { + cls = alias.Class; + exports_1("cls2", cls2 = alias.Class); + x = new alias.Class(); + y = new cls(); + z = new cls2(); + (function (M) { + M.cls = alias.Class; + var x = new alias.Class(); + var y = new M.cls(); + var z = new cls2(); + })(M || (M = {})); + } + } +}); diff --git a/tests/baselines/reference/aliasesInSystemModule2.errors.txt b/tests/baselines/reference/aliasesInSystemModule2.errors.txt new file mode 100644 index 00000000000..618e61c7f3c --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/aliasesInSystemModule2.ts(2,21): error TS2307: Cannot find module 'foo'. + + +==== tests/cases/compiler/aliasesInSystemModule2.ts (1 errors) ==== + + import {alias} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + import cls = alias.Class; + export import cls2 = alias.Class; + + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); + + module M { + export import cls = alias.Class; + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); + } \ No newline at end of file diff --git a/tests/baselines/reference/aliasesInSystemModule2.js b/tests/baselines/reference/aliasesInSystemModule2.js new file mode 100644 index 00000000000..0256d03a179 --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule2.js @@ -0,0 +1,41 @@ +//// [aliasesInSystemModule2.ts] + +import {alias} from "foo"; +import cls = alias.Class; +export import cls2 = alias.Class; + +let x = new alias.Class(); +let y = new cls(); +let z = new cls2(); + +module M { + export import cls = alias.Class; + let x = new alias.Class(); + let y = new cls(); + let z = new cls2(); +} + +//// [aliasesInSystemModule2.js] +System.register(["foo"], function(exports_1) { + var foo_1; + var cls, cls2, x, y, z, M; + return { + setters:[ + function (_foo_1) { + foo_1 = _foo_1; + }], + execute: function() { + cls = foo_1.alias.Class; + exports_1("cls2", cls2 = foo_1.alias.Class); + x = new foo_1.alias.Class(); + y = new cls(); + z = new cls2(); + (function (M) { + M.cls = foo_1.alias.Class; + var x = new foo_1.alias.Class(); + var y = new M.cls(); + var z = new cls2(); + })(M || (M = {})); + } + } +}); diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 5650efc9ae7..9b05aff5ac6 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -294,8 +294,8 @@ module EmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : { x: any; y: string; }[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] +>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -313,8 +313,8 @@ module EmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : { x: any; y: string; }[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -332,8 +332,8 @@ module EmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : { x: any; y: string; }[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -366,22 +366,22 @@ module EmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : iface[] ->[baseObj, base2Obj, ifaceObj] : iface[] +>b1 : base[] +>[baseObj, base2Obj, ifaceObj] : base[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : iface[] ->[base2Obj, baseObj, ifaceObj] : iface[] +>b2 : base2[] +>[base2Obj, baseObj, ifaceObj] : base2[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : iface[] ->[baseObj, ifaceObj, base2Obj] : iface[] +>b3 : base[] +>[baseObj, ifaceObj, base2Obj] : base[] >baseObj : base >ifaceObj : iface >base2Obj : base2 @@ -639,7 +639,7 @@ module NonEmptyTypes { >x : number >y : base >base : base ->[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >7 : number @@ -658,7 +658,7 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >true : boolean @@ -697,8 +697,8 @@ module NonEmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : { x: any; y: string; }[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] +>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -716,8 +716,8 @@ module NonEmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : { x: any; y: string; }[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -735,8 +735,8 @@ module NonEmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : { x: any; y: string; }[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] +>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -769,29 +769,29 @@ module NonEmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : iface[] ->[baseObj, base2Obj, ifaceObj] : iface[] +>b1 : (base | base2 | iface)[] +>[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : iface[] ->[base2Obj, baseObj, ifaceObj] : iface[] +>b2 : (base2 | base | iface)[] +>[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : iface[] ->[baseObj, ifaceObj, base2Obj] : iface[] +>b3 : (base | iface | base2)[] +>[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[] >baseObj : base >ifaceObj : iface >base2Obj : base2 var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : iface[] ->[ifaceObj, baseObj, base2Obj] : iface[] +>b4 : (iface | base | base2)[] +>[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[] >ifaceObj : iface >baseObj : base >base2Obj : base2 diff --git a/tests/baselines/reference/arrayCast.errors.txt b/tests/baselines/reference/arrayCast.errors.txt index 10562cc57e4..82b4b856a97 100644 --- a/tests/baselines/reference/arrayCast.errors.txt +++ b/tests/baselines/reference/arrayCast.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. Type '{ foo: string; }' is not assignable to type '{ id: number; }'. - Property 'id' is missing in type '{ foo: string; }'. + Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/arrayCast.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. !!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'. -!!! error TS2352: Property 'id' is missing in type '{ foo: string; }'. +!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. // Should succeed, as the {} element causes the type of the array to be {}[] <{ id: number; }[]>[{ foo: "s" }, {}]; \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt index 3e9777aea7c..72ba1411320 100644 --- a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'. Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => number'. - Type 'string | number' is not assignable to type 'number'. + Type '() => number | string' is not assignable to type '() => number'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. Property '0' is missing in type 'number[]'. @@ -19,8 +19,8 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionConte ~~~~ !!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | string' is not assignable to type '() => number'. +!!! error TS2322: Type 'number | string' is not assignable to type 'number'. !!! error TS2322: Type 'string' is not assignable to type 'number'. // In a contextually typed array literal expression containing one or more spread elements, diff --git a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt new file mode 100644 index 00000000000..105375f2e74 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt @@ -0,0 +1,72 @@ +tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. + Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. + Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. + Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. +tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. + Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. + Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/arrayLiteralTypeInference.ts (2 errors) ==== + class Action { + id: number; + } + + class ActionA extends Action { + value: string; + } + + class ActionB extends Action { + trueNess: boolean; + } + + var x1: Action[] = [ + ~~ +!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. +!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. +!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. +!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. + { id: 2, trueness: false }, + { id: 3, name: "three" } + ] + + var x2: Action[] = [ + new ActionA(), + new ActionB() + ] + + var x3: Action[] = [ + new Action(), + new ActionA(), + new ActionB() + ] + + var z1: { id: number }[] = + ~~ +!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. + [ + { id: 2, trueness: false }, + { id: 3, name: "three" } + ] + + var z2: { id: number }[] = + [ + new ActionA(), + new ActionB() + ] + + var z3: { id: number }[] = + [ + new Action(), + new ActionA(), + new ActionB() + ] + + + + + \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralTypeInference.symbols b/tests/baselines/reference/arrayLiteralTypeInference.symbols deleted file mode 100644 index 005cb57f6c4..00000000000 --- a/tests/baselines/reference/arrayLiteralTypeInference.symbols +++ /dev/null @@ -1,113 +0,0 @@ -=== tests/cases/compiler/arrayLiteralTypeInference.ts === -class Action { ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - id: number; ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 0, 14)) -} - -class ActionA extends Action { ->ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - value: string; ->value : Symbol(value, Decl(arrayLiteralTypeInference.ts, 4, 30)) -} - -class ActionB extends Action { ->ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - trueNess: boolean; ->trueNess : Symbol(trueNess, Decl(arrayLiteralTypeInference.ts, 8, 30)) -} - -var x1: Action[] = [ ->x1 : Symbol(x1, Decl(arrayLiteralTypeInference.ts, 12, 3)) ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - { id: 2, trueness: false }, ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 13, 5)) ->trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 13, 12)) - - { id: 3, name: "three" } ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 14, 5)) ->name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 14, 12)) - -] - -var x2: Action[] = [ ->x2 : Symbol(x2, Decl(arrayLiteralTypeInference.ts, 17, 3)) ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - new ActionA(), ->ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) - - new ActionB() ->ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) - -] - -var x3: Action[] = [ ->x3 : Symbol(x3, Decl(arrayLiteralTypeInference.ts, 22, 3)) ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - new Action(), ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - new ActionA(), ->ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) - - new ActionB() ->ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) - -] - -var z1: { id: number }[] = ->z1 : Symbol(z1, Decl(arrayLiteralTypeInference.ts, 28, 3)) ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 28, 9)) - - [ - { id: 2, trueness: false }, ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 30, 9)) ->trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 30, 16)) - - { id: 3, name: "three" } ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 31, 9)) ->name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 31, 16)) - - ] - -var z2: { id: number }[] = ->z2 : Symbol(z2, Decl(arrayLiteralTypeInference.ts, 34, 3)) ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 34, 9)) - - [ - new ActionA(), ->ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) - - new ActionB() ->ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) - - ] - -var z3: { id: number }[] = ->z3 : Symbol(z3, Decl(arrayLiteralTypeInference.ts, 40, 3)) ->id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 40, 9)) - - [ - new Action(), ->Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) - - new ActionA(), ->ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) - - new ActionB() ->ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) - - ] - - - - - diff --git a/tests/baselines/reference/arrayLiteralTypeInference.types b/tests/baselines/reference/arrayLiteralTypeInference.types deleted file mode 100644 index 660592fceb8..00000000000 --- a/tests/baselines/reference/arrayLiteralTypeInference.types +++ /dev/null @@ -1,144 +0,0 @@ -=== tests/cases/compiler/arrayLiteralTypeInference.ts === -class Action { ->Action : Action - - id: number; ->id : number -} - -class ActionA extends Action { ->ActionA : ActionA ->Action : Action - - value: string; ->value : string -} - -class ActionB extends Action { ->ActionB : ActionB ->Action : Action - - trueNess: boolean; ->trueNess : boolean -} - -var x1: Action[] = [ ->x1 : Action[] ->Action : Action ->[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] - - { id: 2, trueness: false }, ->{ id: 2, trueness: false } : { id: number; trueness: boolean; } ->id : number ->2 : number ->trueness : boolean ->false : boolean - - { id: 3, name: "three" } ->{ id: 3, name: "three" } : { id: number; name: string; } ->id : number ->3 : number ->name : string ->"three" : string - -] - -var x2: Action[] = [ ->x2 : Action[] ->Action : Action ->[ new ActionA(), new ActionB()] : (ActionA | ActionB)[] - - new ActionA(), ->new ActionA() : ActionA ->ActionA : typeof ActionA - - new ActionB() ->new ActionB() : ActionB ->ActionB : typeof ActionB - -] - -var x3: Action[] = [ ->x3 : Action[] ->Action : Action ->[ new Action(), new ActionA(), new ActionB()] : Action[] - - new Action(), ->new Action() : Action ->Action : typeof Action - - new ActionA(), ->new ActionA() : ActionA ->ActionA : typeof ActionA - - new ActionB() ->new ActionB() : ActionB ->ActionB : typeof ActionB - -] - -var z1: { id: number }[] = ->z1 : { id: number; }[] ->id : number - - [ ->[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] - - { id: 2, trueness: false }, ->{ id: 2, trueness: false } : { id: number; trueness: boolean; } ->id : number ->2 : number ->trueness : boolean ->false : boolean - - { id: 3, name: "three" } ->{ id: 3, name: "three" } : { id: number; name: string; } ->id : number ->3 : number ->name : string ->"three" : string - - ] - -var z2: { id: number }[] = ->z2 : { id: number; }[] ->id : number - - [ ->[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[] - - new ActionA(), ->new ActionA() : ActionA ->ActionA : typeof ActionA - - new ActionB() ->new ActionB() : ActionB ->ActionB : typeof ActionB - - ] - -var z3: { id: number }[] = ->z3 : { id: number; }[] ->id : number - - [ ->[ new Action(), new ActionA(), new ActionB() ] : Action[] - - new Action(), ->new Action() : Action ->Action : typeof Action - - new ActionA(), ->new ActionA() : ActionA ->ActionA : typeof ActionA - - new ActionB() ->new ActionB() : ActionB ->ActionB : typeof ActionB - - ] - - - - - diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index aad515b62ee..5b5a1be6b8a 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -23,8 +23,8 @@ var as = [a, b]; // { x: number; y?: number };[] >b : { x: number; z?: number; } var bs = [b, a]; // { x: number; z?: number };[] ->bs : ({ x: number; y?: number; } | { x: number; z?: number; })[] ->[b, a] : ({ x: number; y?: number; } | { x: number; z?: number; })[] +>bs : ({ x: number; z?: number; } | { x: number; y?: number; })[] +>[b, a] : ({ x: number; z?: number; } | { x: number; y?: number; })[] >b : { x: number; z?: number; } >a : { x: number; y?: number; } @@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[] >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : ((x: Object) => number)[] ->[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] +>ds : (((x: Object) => number) | ((x: string) => number))[] +>[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >2 : number var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : ((x: string) => number)[] ->[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] +>es : (((x: string) => number) | ((x: Object) => number))[] +>[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[] >(x: string) => 2 : (x: string) => number >x : string >2 : number diff --git a/tests/baselines/reference/arrayLiterals.errors.txt b/tests/baselines/reference/arrayLiterals.errors.txt new file mode 100644 index 00000000000..fd882804b8a --- /dev/null +++ b/tests/baselines/reference/arrayLiterals.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. + Index signatures are incompatible. + Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. + Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'. + Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'. + + +==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts (1 errors) ==== + // Empty array literal with no contextual type has type Undefined[] + + var arr1= [[], [1], ['']]; + + var arr2 = [[null], [1], ['']]; + + + // Array literal with elements of only EveryType E has type E[] + var stringArrArr = [[''], [""]]; + + var stringArr = ['', ""]; + + var numberArr = [0, 0.0, 0x00, 1e1]; + + var boolArr = [false, true, false, true]; + + class C { private p; } + var classArr = [new C(), new C()]; + + var classTypeArray = [C, C, C]; + var classTypeArray: Array; // Should OK, not be a parse error + + // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] + var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; + ~~~~~~~~ +!!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. +!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. +!!! error TS2322: Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'. + var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; + + // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] + class Base { private p; } + class Derived1 extends Base { private m }; + class Derived2 extends Base { private n }; + var context3: Base[] = [new Derived1(), new Derived2()]; + + // Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] + var context4: Base[] = [new Derived1(), new Derived1()]; + + \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals.symbols b/tests/baselines/reference/arrayLiterals.symbols deleted file mode 100644 index b338e7ff6e6..00000000000 --- a/tests/baselines/reference/arrayLiterals.symbols +++ /dev/null @@ -1,94 +0,0 @@ -=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts === -// Empty array literal with no contextual type has type Undefined[] - -var arr1= [[], [1], ['']]; ->arr1 : Symbol(arr1, Decl(arrayLiterals.ts, 2, 3)) - -var arr2 = [[null], [1], ['']]; ->arr2 : Symbol(arr2, Decl(arrayLiterals.ts, 4, 3)) - - -// Array literal with elements of only EveryType E has type E[] -var stringArrArr = [[''], [""]]; ->stringArrArr : Symbol(stringArrArr, Decl(arrayLiterals.ts, 8, 3)) - -var stringArr = ['', ""]; ->stringArr : Symbol(stringArr, Decl(arrayLiterals.ts, 10, 3)) - -var numberArr = [0, 0.0, 0x00, 1e1]; ->numberArr : Symbol(numberArr, Decl(arrayLiterals.ts, 12, 3)) - -var boolArr = [false, true, false, true]; ->boolArr : Symbol(boolArr, Decl(arrayLiterals.ts, 14, 3)) - -class C { private p; } ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) ->p : Symbol(p, Decl(arrayLiterals.ts, 16, 9)) - -var classArr = [new C(), new C()]; ->classArr : Symbol(classArr, Decl(arrayLiterals.ts, 17, 3)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) - -var classTypeArray = [C, C, C]; ->classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) - -var classTypeArray: Array; // Should OK, not be a parse error ->classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) - -// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] -var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; ->context1 : Symbol(context1, Decl(arrayLiterals.ts, 23, 3)) ->n : Symbol(n, Decl(arrayLiterals.ts, 23, 17)) ->a : Symbol(a, Decl(arrayLiterals.ts, 23, 30)) ->b : Symbol(b, Decl(arrayLiterals.ts, 23, 41)) ->a : Symbol(a, Decl(arrayLiterals.ts, 23, 62)) ->b : Symbol(b, Decl(arrayLiterals.ts, 23, 69)) ->c : Symbol(c, Decl(arrayLiterals.ts, 23, 75)) ->a : Symbol(a, Decl(arrayLiterals.ts, 23, 86)) ->b : Symbol(b, Decl(arrayLiterals.ts, 23, 93)) ->c : Symbol(c, Decl(arrayLiterals.ts, 23, 99)) - -var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; ->context2 : Symbol(context2, Decl(arrayLiterals.ts, 24, 3)) ->a : Symbol(a, Decl(arrayLiterals.ts, 24, 17)) ->b : Symbol(b, Decl(arrayLiterals.ts, 24, 24)) ->c : Symbol(c, Decl(arrayLiterals.ts, 24, 30)) ->a : Symbol(a, Decl(arrayLiterals.ts, 24, 41)) ->b : Symbol(b, Decl(arrayLiterals.ts, 24, 48)) ->c : Symbol(c, Decl(arrayLiterals.ts, 24, 54)) - -// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] -class Base { private p; } ->Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) ->p : Symbol(p, Decl(arrayLiterals.ts, 27, 12)) - -class Derived1 extends Base { private m }; ->Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) ->Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) ->m : Symbol(m, Decl(arrayLiterals.ts, 28, 29)) - -class Derived2 extends Base { private n }; ->Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42)) ->Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) ->n : Symbol(n, Decl(arrayLiterals.ts, 29, 29)) - -var context3: Base[] = [new Derived1(), new Derived2()]; ->context3 : Symbol(context3, Decl(arrayLiterals.ts, 30, 3)) ->Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) ->Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) ->Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42)) - -// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] -var context4: Base[] = [new Derived1(), new Derived1()]; ->context4 : Symbol(context4, Decl(arrayLiterals.ts, 33, 3)) ->Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) ->Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) ->Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) - - diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types deleted file mode 100644 index e103241dd0b..00000000000 --- a/tests/baselines/reference/arrayLiterals.types +++ /dev/null @@ -1,153 +0,0 @@ -=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts === -// Empty array literal with no contextual type has type Undefined[] - -var arr1= [[], [1], ['']]; ->arr1 : (number[] | string[])[] ->[[], [1], ['']] : (number[] | string[])[] ->[] : undefined[] ->[1] : number[] ->1 : number ->[''] : string[] ->'' : string - -var arr2 = [[null], [1], ['']]; ->arr2 : (number[] | string[])[] ->[[null], [1], ['']] : (number[] | string[])[] ->[null] : null[] ->null : null ->[1] : number[] ->1 : number ->[''] : string[] ->'' : string - - -// Array literal with elements of only EveryType E has type E[] -var stringArrArr = [[''], [""]]; ->stringArrArr : string[][] ->[[''], [""]] : string[][] ->[''] : string[] ->'' : string ->[""] : string[] ->"" : string - -var stringArr = ['', ""]; ->stringArr : string[] ->['', ""] : string[] ->'' : string ->"" : string - -var numberArr = [0, 0.0, 0x00, 1e1]; ->numberArr : number[] ->[0, 0.0, 0x00, 1e1] : number[] ->0 : number ->0.0 : number ->0x00 : number ->1e1 : number - -var boolArr = [false, true, false, true]; ->boolArr : boolean[] ->[false, true, false, true] : boolean[] ->false : boolean ->true : boolean ->false : boolean ->true : boolean - -class C { private p; } ->C : C ->p : any - -var classArr = [new C(), new C()]; ->classArr : C[] ->[new C(), new C()] : C[] ->new C() : C ->C : typeof C ->new C() : C ->C : typeof C - -var classTypeArray = [C, C, C]; ->classTypeArray : typeof C[] ->[C, C, C] : typeof C[] ->C : typeof C ->C : typeof C ->C : typeof C - -var classTypeArray: Array; // Should OK, not be a parse error ->classTypeArray : typeof C[] ->Array : T[] ->C : typeof C - -// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] -var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; ->context1 : { [n: number]: { a: string; b: number; }; } ->n : number ->a : string ->b : number ->[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] ->{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } ->a : string ->'' : string ->b : number ->0 : number ->c : string ->'' : string ->{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; } ->a : string ->"" : string ->b : number ->3 : number ->c : number ->0 : number - -var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; ->context2 : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] ->[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] ->{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } ->a : string ->'' : string ->b : number ->0 : number ->c : string ->'' : string ->{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; } ->a : string ->"" : string ->b : number ->3 : number ->c : number ->0 : number - -// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] -class Base { private p; } ->Base : Base ->p : any - -class Derived1 extends Base { private m }; ->Derived1 : Derived1 ->Base : Base ->m : any - -class Derived2 extends Base { private n }; ->Derived2 : Derived2 ->Base : Base ->n : any - -var context3: Base[] = [new Derived1(), new Derived2()]; ->context3 : Base[] ->Base : Base ->[new Derived1(), new Derived2()] : (Derived1 | Derived2)[] ->new Derived1() : Derived1 ->Derived1 : typeof Derived1 ->new Derived2() : Derived2 ->Derived2 : typeof Derived2 - -// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] -var context4: Base[] = [new Derived1(), new Derived1()]; ->context4 : Base[] ->Base : Base ->[new Derived1(), new Derived1()] : Derived1[] ->new Derived1() : Derived1 ->Derived1 : typeof Derived1 ->new Derived1() : Derived1 ->Derived1 : typeof Derived1 - - diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types index 6eae997f465..a9cf31611c2 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.types +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -24,8 +24,8 @@ var a1 = ["hello", "world"] >"world" : string var a2 = [, , , ...a0, "hello"]; ->a2 : (string | number)[] ->[, , , ...a0, "hello"] : (string | number)[] +>a2 : (number | string)[] +>[, , , ...a0, "hello"] : (number | string)[] > : undefined > : undefined > : undefined @@ -151,8 +151,8 @@ interface myArray2 extends Array { } >String : String var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] ->d0 : (string | number | boolean)[] ->[1, true, ...temp,] : (string | number | boolean)[] +>d0 : (number | boolean | string)[] +>[1, true, ...temp,] : (number | boolean | string)[] >1 : number >true : boolean >...temp : string @@ -214,8 +214,8 @@ var d8: number[][] = [[...temp1]] >temp1 : number[] var d9 = [[...temp1], ...["hello"]]; ->d9 : (string | number[])[] ->[[...temp1], ...["hello"]] : (string | number[])[] +>d9 : (number[] | string)[] +>[[...temp1], ...["hello"]] : (number[] | string)[] >[...temp1] : number[] >...temp1 : number >temp1 : number[] diff --git a/tests/baselines/reference/arrayLiterals2ES6.types b/tests/baselines/reference/arrayLiterals2ES6.types index f05b0ca9282..b6bf4f1de1b 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.types +++ b/tests/baselines/reference/arrayLiterals2ES6.types @@ -24,8 +24,8 @@ var a1 = ["hello", "world"] >"world" : string var a2 = [, , , ...a0, "hello"]; ->a2 : (string | number)[] ->[, , , ...a0, "hello"] : (string | number)[] +>a2 : (number | string)[] +>[, , , ...a0, "hello"] : (number | string)[] > : undefined > : undefined > : undefined @@ -140,8 +140,8 @@ interface myArray2 extends Array { } >String : String var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] ->d0 : (string | number | boolean)[] ->[1, true, ...temp, ] : (string | number | boolean)[] +>d0 : (number | boolean | string)[] +>[1, true, ...temp, ] : (number | boolean | string)[] >1 : number >true : boolean >...temp : string @@ -176,10 +176,10 @@ var d4: myArray2 = [...temp, ...temp1]; >temp1 : number[] var d5 = [...a2]; ->d5 : (string | number)[] ->[...a2] : (string | number)[] ->...a2 : string | number ->a2 : (string | number)[] +>d5 : (number | string)[] +>[...a2] : (number | string)[] +>...a2 : number | string +>a2 : (number | string)[] var d6 = [...a3]; >d6 : number[] @@ -201,8 +201,8 @@ var d8: number[][] = [[...temp1]] >temp1 : number[] var d9 = [[...temp1], ...["hello"]]; ->d9 : (string | number[])[] ->[[...temp1], ...["hello"]] : (string | number[])[] +>d9 : (number[] | string)[] +>[[...temp1], ...["hello"]] : (number[] | string)[] >[...temp1] : number[] >...temp1 : number >temp1 : number[] diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 36714162de0..637fb3e3bc4 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -5,18 +5,18 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. Types of property 'pop' are incompatible. - Type '() => string | number | boolean' is not assignable to type '() => number'. - Type 'string | number | boolean' is not assignable to type 'number'. + Type '() => number | string | boolean' is not assignable to type '() => number'. + Type 'number | string | boolean' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'. Property '0' is missing in type '(number[] | string[])[]'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. Property '0' is missing in type 'number[]'. -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'. Types of property 'push' are incompatible. - Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. + Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'. Types of parameters 'items' and 'items' are incompatible. - Type 'string | number' is not assignable to type 'Number'. + Type 'number | string' is not assignable to type 'Number'. Type 'string' is not assignable to type 'Number'. Property 'toFixed' is missing in type 'String'. @@ -49,8 +49,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error ~~~~~~~~ !!! error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number'. +!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number'. !!! error TS2322: Type 'string' is not assignable to type 'number'. // The resulting type an array literal expression is determined as follows: @@ -76,11 +76,11 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Property '0' is missing in type 'number[]'. var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] ~~ -!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. +!!! error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'. !!! error TS2322: Types of property 'push' are incompatible. -!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. +!!! error TS2322: Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'. !!! error TS2322: Types of parameters 'items' and 'items' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'Number'. +!!! error TS2322: Type 'number | string' is not assignable to type 'Number'. !!! error TS2322: Type 'string' is not assignable to type 'Number'. !!! error TS2322: Property 'toFixed' is missing in type 'String'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index 9cdbe0a0a61..b7224fe91c4 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -77,8 +77,8 @@ var myDerivedList: DerivedList; >DerivedList : DerivedList var as = [list, myDerivedList]; // List[] ->as : List[] ->[list, myDerivedList] : List[] +>as : (List | DerivedList)[] +>[list, myDerivedList] : (List | DerivedList)[] >list : List >myDerivedList : DerivedList diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt new file mode 100644 index 00000000000..499d6bca387 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ==== + // valid uses of arrays of function types + + var x = [() => 1, () => { }]; + var r2 = x[0](); + + class C { + foo: string; + } + var y = [C, C]; + var r3 = new y[0](); + + var a: { (x: number): number; (x: string): string; }; + var b: { (x: number): number; (x: string): string; }; + var c: { (x: number): number; (x: any): any; }; + var z = [a, b, c]; + var r4 = z[0]; + var r5 = r4(''); // any not string + ~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + var r5b = r4(1); + + var a2: { (x: T): number; (x: string): string;}; + var b2: { (x: T): number; (x: string): string; }; + var c2: { (x: number): number; (x: T): any; }; + + var z2 = [a2, b2, c2]; + var r6 = z2[0]; + var r7 = r6(''); // any not string + ~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.symbols b/tests/baselines/reference/arrayOfFunctionTypes3.symbols deleted file mode 100644 index d26effeb5b7..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.symbols +++ /dev/null @@ -1,93 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === -// valid uses of arrays of function types - -var x = [() => 1, () => { }]; ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) - -var r2 = x[0](); ->r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) - -class C { ->C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) - - foo: string; ->foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9)) -} -var y = [C, C]; ->y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) ->C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) ->C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) - -var r3 = new y[0](); ->r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3)) ->y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) - -var a: { (x: number): number; (x: string): string; }; ->a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31)) - -var b: { (x: number): number; (x: string): string; }; ->b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31)) - -var c: { (x: number): number; (x: any): any; }; ->c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31)) - -var z = [a, b, c]; ->z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) ->a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) ->b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) ->c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) - -var r4 = z[0]; ->r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) ->z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) - -var r5 = r4(''); // any not string ->r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3)) ->r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) - -var r5b = r4(1); ->r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3)) ->r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) - -var a2: { (x: T): number; (x: string): string;}; ->a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30)) - -var b2: { (x: T): number; (x: string): string; }; ->b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30)) - -var c2: { (x: number): number; (x: T): any; }; ->c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) ->x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35)) ->T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) - -var z2 = [a2, b2, c2]; ->z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) ->a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) ->b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) ->c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) - -var r6 = z2[0]; ->r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) ->z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) - -var r7 = r6(''); // any not string ->r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3)) ->r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) - diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types deleted file mode 100644 index 0ed92991ed0..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.types +++ /dev/null @@ -1,116 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === -// valid uses of arrays of function types - -var x = [() => 1, () => { }]; ->x : (() => void)[] ->[() => 1, () => { }] : (() => void)[] ->() => 1 : () => number ->1 : number ->() => { } : () => void - -var r2 = x[0](); ->r2 : void ->x[0]() : void ->x[0] : () => void ->x : (() => void)[] ->0 : number - -class C { ->C : C - - foo: string; ->foo : string -} -var y = [C, C]; ->y : typeof C[] ->[C, C] : typeof C[] ->C : typeof C ->C : typeof C - -var r3 = new y[0](); ->r3 : C ->new y[0]() : C ->y[0] : typeof C ->y : typeof C[] ->0 : number - -var a: { (x: number): number; (x: string): string; }; ->a : { (x: number): number; (x: string): string; } ->x : number ->x : string - -var b: { (x: number): number; (x: string): string; }; ->b : { (x: number): number; (x: string): string; } ->x : number ->x : string - -var c: { (x: number): number; (x: any): any; }; ->c : { (x: number): number; (x: any): any; } ->x : number ->x : any - -var z = [a, b, c]; ->z : { (x: number): number; (x: any): any; }[] ->[a, b, c] : { (x: number): number; (x: any): any; }[] ->a : { (x: number): number; (x: string): string; } ->b : { (x: number): number; (x: string): string; } ->c : { (x: number): number; (x: any): any; } - -var r4 = z[0]; ->r4 : { (x: number): number; (x: any): any; } ->z[0] : { (x: number): number; (x: any): any; } ->z : { (x: number): number; (x: any): any; }[] ->0 : number - -var r5 = r4(''); // any not string ->r5 : any ->r4('') : any ->r4 : { (x: number): number; (x: any): any; } ->'' : string - -var r5b = r4(1); ->r5b : number ->r4(1) : number ->r4 : { (x: number): number; (x: any): any; } ->1 : number - -var a2: { (x: T): number; (x: string): string;}; ->a2 : { (x: T): number; (x: string): string; } ->T : T ->x : T ->T : T ->x : string - -var b2: { (x: T): number; (x: string): string; }; ->b2 : { (x: T): number; (x: string): string; } ->T : T ->x : T ->T : T ->x : string - -var c2: { (x: number): number; (x: T): any; }; ->c2 : { (x: number): number; (x: T): any; } ->x : number ->T : T ->x : T ->T : T - -var z2 = [a2, b2, c2]; ->z2 : { (x: number): number; (x: T): any; }[] ->[a2, b2, c2] : { (x: number): number; (x: T): any; }[] ->a2 : { (x: T): number; (x: string): string; } ->b2 : { (x: T): number; (x: string): string; } ->c2 : { (x: number): number; (x: T): any; } - -var r6 = z2[0]; ->r6 : { (x: number): number; (x: T): any; } ->z2[0] : { (x: number): number; (x: T): any; } ->z2 : { (x: number): number; (x: T): any; }[] ->0 : number - -var r7 = r6(''); // any not string ->r7 : any ->r6('') : any ->r6 : { (x: number): number; (x: T): any; } ->'' : string - diff --git a/tests/baselines/reference/asOperator1.types b/tests/baselines/reference/asOperator1.types index 3f69871ea09..cc8a49ddc55 100644 --- a/tests/baselines/reference/asOperator1.types +++ b/tests/baselines/reference/asOperator1.types @@ -24,12 +24,12 @@ var z = Date as any as string; // Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' var j = 32 as number|string; ->j : string | number ->32 as number|string : string | number +>j : number | string +>32 as number|string : number | string >32 : number j = ''; >j = '' : string ->j : string | number +>j : number | string >'' : string diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt index 03dcee9baf3..c7552c3fdb2 100644 --- a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => number'. - Type 'string | number' is not assignable to type 'number'. + Type '() => number | string' is not assignable to type '() => number'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]'. Property '0' is missing in type '{}[]'. @@ -28,8 +28,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | string' is not assignable to type '() => number'. +!!! error TS2322: Type 'number | string' is not assignable to type 'number'. !!! error TS2322: Type 'string' is not assignable to type 'number'. emptyObjTuple = emptyObjArray; ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 15bf1111391..53e12635888 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -1,7 +1,9 @@ tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. - Property 'b' is missing in type '{ a: number; }'. + Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. - Property 'b' is missing in type '{ a: number; }'. + Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. + Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. @@ -10,18 +12,21 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'. -==== tests/cases/compiler/assignmentCompatBug2.ts (5 errors) ==== +==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== var b2: { b: number;} = { a: 0 }; // error ~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. -!!! error TS2322: Property 'b' is missing in type '{ a: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = { a: 0 }; // error ~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. -!!! error TS2322: Property 'b' is missing in type '{ a: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = {b: 0, a: 0 }; + ~~ +!!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }; diff --git a/tests/baselines/reference/assignmentCompatBug5.errors.txt b/tests/baselines/reference/assignmentCompatBug5.errors.txt index fd13a07a948..790848babf4 100644 --- a/tests/baselines/reference/assignmentCompatBug5.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug5.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. - Property 'a' is missing in type '{ b: number; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'. @@ -14,7 +14,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ foo1({ b: 5 }); ~~~~~~~~ !!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. -!!! error TS2345: Property 'a' is missing in type '{ b: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. function foo2(x: number[]) { } foo2(["s", "t"]); diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types index fc7bef8a28c..d0b5b6ccfd0 100644 --- a/tests/baselines/reference/awaitUnion_es6.types +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es6/awaitUnion_es6.ts === declare let a: number | string; ->a : string | number +>a : number | string declare let b: PromiseLike | PromiseLike; >b : PromiseLike | PromiseLike @@ -8,7 +8,7 @@ declare let b: PromiseLike | PromiseLike; >PromiseLike : PromiseLike declare let c: PromiseLike; ->c : PromiseLike +>c : PromiseLike >PromiseLike : PromiseLike declare let d: number | PromiseLike; @@ -16,29 +16,29 @@ declare let d: number | PromiseLike; >PromiseLike : PromiseLike declare let e: number | PromiseLike; ->e : number | PromiseLike +>e : number | PromiseLike >PromiseLike : PromiseLike async function f() { >f : () => Promise let await_a = await a; ->await_a : string | number +>await_a : number | string >a : any let await_b = await b; ->await_b : string | number +>await_b : number | string >b : any let await_c = await c; ->await_c : string | number +>await_c : number | string >c : any let await_d = await d; ->await_d : string | number +>await_d : number | string >d : any let await_e = await e; ->await_e : string | number +>await_e : number | string >e : any } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 2a5ee6a2fe2..933d46cc802 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -46,8 +46,8 @@ var r = true ? 1 : 2; >2 : number var r3 = true ? 1 : {}; ->r3 : {} ->true ? 1 : {} : {} +>r3 : number | {} +>true ? 1 : {} : number | {} >true : boolean >1 : number >{} : {} @@ -60,15 +60,15 @@ var r4 = true ? a : b; // typeof a >b : { x: number; z?: number; } var r5 = true ? b : a; // typeof b ->r5 : { x: number; y?: number; } | { x: number; z?: number; } ->true ? b : a : { x: number; y?: number; } | { x: number; z?: number; } +>r5 : { x: number; z?: number; } | { x: number; y?: number; } +>true ? b : a : { x: number; z?: number; } | { x: number; y?: number; } >true : boolean >b : { x: number; z?: number; } >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void ->r6 : (x: number) => void ->true ? (x: number) => { } : (x: Object) => { } : (x: number) => void +>r6 : ((x: number) => void) | ((x: Object) => void) +>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : (x: number) => void +>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >Object : Object var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void ->r8 : (x: Object) => void ->true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void +>r8 : ((x: Object) => void) | ((x: number) => void) +>true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void) >true : boolean >(x: Object) => { } : (x: Object) => void >x : Object @@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >derived2 : Derived2 var r11 = true ? base : derived2; ->r11 : Base ->true ? base : derived2 : Base +>r11 : Base | Derived2 +>true ? base : derived2 : Base | Derived2 >true : boolean >base : Base >derived2 : Derived2 diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index 7b7302a9cc2..7d3330f4863 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -98,8 +98,8 @@ var e3 = t3[2]; // any >2 : number var e4 = t4[3]; // number ->e4 : number ->t4[3] : number +>e4 : E1 | E2 | number +>t4[3] : E1 | E2 | number >t4 : [E1, E2, number] >3 : number diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.types b/tests/baselines/reference/bestCommonTypeOfTuple2.types index 32196fdf668..573e3466376 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.types @@ -66,8 +66,8 @@ var t5: [C1, F] >F : F var e11 = t1[4]; // base ->e11 : base ->t1[4] : base +>e11 : C | base +>t1[4] : C | base >t1 : [C, base] >4 : number @@ -78,20 +78,20 @@ var e21 = t2[4]; // {} >4 : number var e31 = t3[4]; // C1 ->e31 : C1 ->t3[4] : C1 +>e31 : C1 | D1 +>t3[4] : C1 | D1 >t3 : [C1, D1] >4 : number var e41 = t4[2]; // base1 ->e41 : base1 ->t4[2] : base1 +>e41 : base1 | C1 +>t4[2] : base1 | C1 >t4 : [base1, C1] >2 : number var e51 = t5[2]; // {} ->e51 : F | C1 ->t5[2] : F | C1 +>e51 : C1 | F +>t5[2] : C1 | F >t5 : [C1, F] >2 : number diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types index df40291b0e5..4c47753a90d 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types @@ -27,43 +27,43 @@ var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; ->b1 : X[] ->[x, y, z] : X[] +>b1 : (X | Y | Z)[] +>[x, y, z] : (X | Y | Z)[] >x : X >y : Y >z : Z var b2 = [x, z, y]; ->b2 : X[] ->[x, z, y] : X[] +>b2 : (X | Z | Y)[] +>[x, z, y] : (X | Z | Y)[] >x : X >z : Z >y : Y var b3 = [y, x, z]; ->b3 : X[] ->[y, x, z] : X[] +>b3 : (Y | X | Z)[] +>[y, x, z] : (Y | X | Z)[] >y : Y >x : X >z : Z var b4 = [y, z, x]; ->b4 : X[] ->[y, z, x] : X[] +>b4 : (Y | Z | X)[] +>[y, z, x] : (Y | Z | X)[] >y : Y >z : Z >x : X var b5 = [z, x, y]; ->b5 : X[] ->[z, x, y] : X[] +>b5 : (Z | X | Y)[] +>[z, x, y] : (Z | X | Y)[] >z : Z >x : X >y : Y var b6 = [z, y, x]; ->b6 : X[] ->[z, y, x] : X[] +>b6 : (Z | Y | X)[] +>[z, y, x] : (Z | Y | X)[] >z : Z >y : Y >x : X diff --git a/tests/baselines/reference/callWithSpread.types b/tests/baselines/reference/callWithSpread.types index f7097727204..8964708c05e 100644 --- a/tests/baselines/reference/callWithSpread.types +++ b/tests/baselines/reference/callWithSpread.types @@ -163,8 +163,8 @@ xa[1].foo(1, 2, ...a, "abc"); >xa : X[] >1 : number >foo : (x: number, y: number, ...z: string[]) => any ->...[1, 2, "abc"] : string | number ->[1, 2, "abc"] : (string | number)[] +>...[1, 2, "abc"] : number | string +>[1, 2, "abc"] : (number | string)[] >1 : number >2 : number >"abc" : string diff --git a/tests/baselines/reference/callWithSpreadES6.types b/tests/baselines/reference/callWithSpreadES6.types index ba638207e8a..9c9e795ce24 100644 --- a/tests/baselines/reference/callWithSpreadES6.types +++ b/tests/baselines/reference/callWithSpreadES6.types @@ -164,8 +164,8 @@ xa[1].foo(1, 2, ...a, "abc"); >xa : X[] >1 : number >foo : (x: number, y: number, ...z: string[]) => any ->...[1, 2, "abc"] : string | number ->[1, 2, "abc"] : (string | number)[] +>...[1, 2, "abc"] : number | string +>[1, 2, "abc"] : (number | string)[] >1 : number >2 : number >"abc" : string diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index 98be259964d..62a36c9c156 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -8,11 +8,12 @@ tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Neithe 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'. + Property 'a' is missing in type 'C'. 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 '() => number | string' is not assignable to type '() => number'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'. @@ -61,14 +62,15 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot !!! error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other. !!! error TS2352: Types of property '0' are incompatible. !!! error TS2352: Type 'C' is not assignable to type 'A'. +!!! error TS2352: Property 'a' is missing in type 'C'. var array1 = numStrTuple; ~~~~~~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other. !!! error TS2352: Types of property 'pop' are incompatible. -!!! error TS2352: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2352: Type 'string | number' is not assignable to type 'number'. +!!! error TS2352: Type '() => number | string' is not assignable to type '() => number'. +!!! error TS2352: Type 'number | string' is not assignable to type 'number'. !!! error TS2352: Type 'string' is not assignable to type 'number'. t4[2] = 10; ~~ diff --git a/tests/baselines/reference/classExtendsNull.errors.txt b/tests/baselines/reference/classExtendsNull.errors.txt new file mode 100644 index 00000000000..7bb44774826 --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/classExtendsNull.ts(2,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null' + + +==== tests/cases/compiler/classExtendsNull.ts (1 errors) ==== + class C extends null { + constructor() { + ~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~ + return Object.create(null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null' + } + + class D extends null { + constructor() { + return Object.create(null); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsNull.js b/tests/baselines/reference/classExtendsNull.js new file mode 100644 index 00000000000..5627f10dca6 --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.js @@ -0,0 +1,35 @@ +//// [classExtendsNull.ts] +class C extends null { + constructor() { + super(); + return Object.create(null); + } +} + +class D extends null { + constructor() { + return Object.create(null); + } +} + +//// [classExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.call(this); + return Object.create(null); + } + return C; +})(null); +var D = (function (_super) { + __extends(D, _super); + function D() { + return Object.create(null); + } + return D; +})(null); diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index d6c97b5db81..a3a393fba0c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -17,9 +17,9 @@ declare function foo(obj: I): T >T : T foo({ ->foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] +>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 72a1d5ba04f..4abefe44843 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -17,9 +17,9 @@ declare function foo(obj: I): T >T : T foo({ ->foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] +>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types index 5674f6aa393..ae1004c9819 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types @@ -17,9 +17,9 @@ declare function foo(obj: I): T >T : T foo({ ->foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[] +>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types index 93558c075e7..e98e0fb8941 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types @@ -17,9 +17,9 @@ declare function foo(obj: I): T >T : T foo({ ->foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[] +>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/conditionalExpression1.errors.txt b/tests/baselines/reference/conditionalExpression1.errors.txt index 0e291986785..49ed2095353 100644 --- a/tests/baselines/reference/conditionalExpression1.errors.txt +++ b/tests/baselines/reference/conditionalExpression1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'number | string' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. ==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ==== var x: boolean = (true ? 1 : ""); // should be an error ~ -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file +!!! error TS2322: Type 'number | string' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index 722ec13c684..d5530f98fe8 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -31,27 +31,27 @@ var b: B; //Cond ? Expr1 : Expr2, Expr1 is supertype //Be Not contextually typed true ? x : a; ->true ? x : a : X +>true ? x : a : X | A >true : boolean >x : X >a : A var result1 = true ? x : a; ->result1 : X ->true ? x : a : X +>result1 : X | A +>true ? x : a : X | A >true : boolean >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; ->true ? {} : 1 : {} +>true ? {} : 1 : {} | number >true : boolean >{} : {} >1 : number true ? { a: 1 } : { a: 2, b: 'string' }; ->true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } +>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; } >true : boolean >{ a: 1 } : { a: number; } >a : number @@ -63,15 +63,15 @@ true ? { a: 1 } : { a: 2, b: 'string' }; >'string' : string var result2 = true ? {} : 1; ->result2 : {} ->true ? {} : 1 : {} +>result2 : {} | number +>true ? {} : 1 : {} | number >true : boolean >{} : {} >1 : number var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; ->result3 : { a: number; } ->true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } +>result3 : { a: number; } | { a: number; b: string; } +>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; } >true : boolean >{ a: 1 } : { a: number; } >a : number @@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X ->true ? x : a : X +>true ? x : a : X | A >true : boolean >x : X >a : A @@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any +>true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number) >true : boolean >(m) => m.propertyX : (m: A) => any >m : A @@ -111,27 +111,27 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Cond ? Expr1 : Expr2, Expr2 is supertype //Be Not contextually typed true ? a : x; ->true ? a : x : X +>true ? a : x : A | X >true : boolean >a : A >x : X var result5 = true ? a : x; ->result5 : X ->true ? a : x : X +>result5 : A | X +>true ? a : x : A | X >true : boolean >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; ->true ? 1 : {} : {} +>true ? 1 : {} : number | {} >true : boolean >1 : number >{} : {} true ? { a: 2, b: 'string' } : { a: 1 }; ->true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; } +>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; } >true : boolean >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number @@ -143,15 +143,15 @@ true ? { a: 2, b: 'string' } : { a: 1 }; >1 : number var result6 = true ? 1 : {}; ->result6 : {} ->true ? 1 : {} : {} +>result6 : number | {} +>true ? 1 : {} : number | {} >true : boolean >1 : number >{} : {} var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; ->result7 : { a: number; } ->true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; } +>result7 : { a: number; b: string; } | { a: number; } +>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; } >true : boolean >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number @@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X ->true ? x : a : X +>true ? x : a : X | A >true : boolean >x : X >a : A @@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any +>true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any) >true : boolean >(m) => m.propertyA : (m: A) => number >m : A @@ -218,7 +218,7 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2; //Expr1 and Expr2 are literals var result11: any = true ? 1 : 'string'; >result11 : any ->true ? 1 : 'string' : string | number +>true ? 1 : 'string' : number | string >true : boolean >1 : number >'string' : string diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index be7dad54eeb..4236544defa 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal. @@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member // forward reference to the element of the same enum X = Y, ~ -!!! error TS2474: In 'const' enum declarations member initializer must be constant expression. +!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. // forward reference to the element of the same enum Y = E1.Z, ~~~~ diff --git a/tests/baselines/reference/constEnumMergingWithValues1.js b/tests/baselines/reference/constEnumMergingWithValues1.js new file mode 100644 index 00000000000..f47fc227bae --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues1.js @@ -0,0 +1,14 @@ +//// [constEnumMergingWithValues1.ts] + +function foo() {} +module foo { + const enum E { X } +} + +export = foo + +//// [constEnumMergingWithValues1.js] +define(["require", "exports"], function (require, exports) { + function foo() { } + return foo; +}); diff --git a/tests/baselines/reference/constEnumMergingWithValues1.symbols b/tests/baselines/reference/constEnumMergingWithValues1.symbols new file mode 100644 index 00000000000..3dd1c80705c --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues1.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/constEnumMergingWithValues1.ts === + +function foo() {} +>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17)) + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17)) + + const enum E { X } +>E : Symbol(E, Decl(constEnumMergingWithValues1.ts, 2, 12)) +>X : Symbol(E.X, Decl(constEnumMergingWithValues1.ts, 3, 18)) +} + +export = foo +>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17)) + diff --git a/tests/baselines/reference/constEnumMergingWithValues1.types b/tests/baselines/reference/constEnumMergingWithValues1.types new file mode 100644 index 00000000000..8d5b15795f7 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues1.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/constEnumMergingWithValues1.ts === + +function foo() {} +>foo : typeof foo + +module foo { +>foo : typeof foo + + const enum E { X } +>E : E +>X : E +} + +export = foo +>foo : typeof foo + diff --git a/tests/baselines/reference/constEnumMergingWithValues2.js b/tests/baselines/reference/constEnumMergingWithValues2.js new file mode 100644 index 00000000000..393ab41fa1f --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues2.js @@ -0,0 +1,18 @@ +//// [constEnumMergingWithValues2.ts] + +class foo {} +module foo { + const enum E { X } +} + +export = foo + +//// [constEnumMergingWithValues2.js] +define(["require", "exports"], function (require, exports) { + var foo = (function () { + function foo() { + } + return foo; + })(); + return foo; +}); diff --git a/tests/baselines/reference/constEnumMergingWithValues2.symbols b/tests/baselines/reference/constEnumMergingWithValues2.symbols new file mode 100644 index 00000000000..bfb438a387d --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/constEnumMergingWithValues2.ts === + +class foo {} +>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12)) + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12)) + + const enum E { X } +>E : Symbol(E, Decl(constEnumMergingWithValues2.ts, 2, 12)) +>X : Symbol(E.X, Decl(constEnumMergingWithValues2.ts, 3, 18)) +} + +export = foo +>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12)) + diff --git a/tests/baselines/reference/constEnumMergingWithValues2.types b/tests/baselines/reference/constEnumMergingWithValues2.types new file mode 100644 index 00000000000..dd706ef33a1 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues2.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/constEnumMergingWithValues2.ts === + +class foo {} +>foo : foo + +module foo { +>foo : typeof foo + + const enum E { X } +>E : E +>X : E +} + +export = foo +>foo : foo + diff --git a/tests/baselines/reference/constEnumMergingWithValues3.js b/tests/baselines/reference/constEnumMergingWithValues3.js new file mode 100644 index 00000000000..d28f29f0962 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues3.js @@ -0,0 +1,17 @@ +//// [constEnumMergingWithValues3.ts] + +enum foo { A } +module foo { + const enum E { X } +} + +export = foo + +//// [constEnumMergingWithValues3.js] +define(["require", "exports"], function (require, exports) { + var foo; + (function (foo) { + foo[foo["A"] = 0] = "A"; + })(foo || (foo = {})); + return foo; +}); diff --git a/tests/baselines/reference/constEnumMergingWithValues3.symbols b/tests/baselines/reference/constEnumMergingWithValues3.symbols new file mode 100644 index 00000000000..33e020b5679 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues3.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/constEnumMergingWithValues3.ts === + +enum foo { A } +>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14)) +>A : Symbol(foo.A, Decl(constEnumMergingWithValues3.ts, 1, 10)) + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14)) + + const enum E { X } +>E : Symbol(E, Decl(constEnumMergingWithValues3.ts, 2, 12)) +>X : Symbol(E.X, Decl(constEnumMergingWithValues3.ts, 3, 18)) +} + +export = foo +>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14)) + diff --git a/tests/baselines/reference/constEnumMergingWithValues3.types b/tests/baselines/reference/constEnumMergingWithValues3.types new file mode 100644 index 00000000000..df2e8820466 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues3.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/constEnumMergingWithValues3.ts === + +enum foo { A } +>foo : foo +>A : foo + +module foo { +>foo : typeof foo + + const enum E { X } +>E : E +>X : E +} + +export = foo +>foo : foo + diff --git a/tests/baselines/reference/constEnumMergingWithValues4.js b/tests/baselines/reference/constEnumMergingWithValues4.js new file mode 100644 index 00000000000..7ed8b44dc76 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues4.js @@ -0,0 +1,21 @@ +//// [constEnumMergingWithValues4.ts] + +module foo { + const enum E { X } +} + +module foo { + var x = 1; +} + + +export = foo + +//// [constEnumMergingWithValues4.js] +define(["require", "exports"], function (require, exports) { + var foo; + (function (foo) { + var x = 1; + })(foo || (foo = {})); + return foo; +}); diff --git a/tests/baselines/reference/constEnumMergingWithValues4.symbols b/tests/baselines/reference/constEnumMergingWithValues4.symbols new file mode 100644 index 00000000000..817c9aeeff3 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues4.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/constEnumMergingWithValues4.ts === + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1)) + + const enum E { X } +>E : Symbol(E, Decl(constEnumMergingWithValues4.ts, 1, 12)) +>X : Symbol(E.X, Decl(constEnumMergingWithValues4.ts, 2, 18)) +} + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1)) + + var x = 1; +>x : Symbol(x, Decl(constEnumMergingWithValues4.ts, 6, 7)) +} + + +export = foo +>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1)) + diff --git a/tests/baselines/reference/constEnumMergingWithValues4.types b/tests/baselines/reference/constEnumMergingWithValues4.types new file mode 100644 index 00000000000..3da306fedbf --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues4.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/constEnumMergingWithValues4.ts === + +module foo { +>foo : typeof foo + + const enum E { X } +>E : E +>X : E +} + +module foo { +>foo : typeof foo + + var x = 1; +>x : number +>1 : number +} + + +export = foo +>foo : typeof foo + diff --git a/tests/baselines/reference/constEnumMergingWithValues5.js b/tests/baselines/reference/constEnumMergingWithValues5.js new file mode 100644 index 00000000000..378b11cfd22 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues5.js @@ -0,0 +1,19 @@ +//// [constEnumMergingWithValues5.ts] + +module foo { + const enum E { X } +} + +export = foo + +//// [constEnumMergingWithValues5.js] +define(["require", "exports"], function (require, exports) { + var foo; + (function (foo) { + var E; + (function (E) { + E[E["X"] = 0] = "X"; + })(E || (E = {})); + })(foo || (foo = {})); + return foo; +}); diff --git a/tests/baselines/reference/constEnumMergingWithValues5.symbols b/tests/baselines/reference/constEnumMergingWithValues5.symbols new file mode 100644 index 00000000000..6354f64d834 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues5.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/constEnumMergingWithValues5.ts === + +module foo { +>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0)) + + const enum E { X } +>E : Symbol(E, Decl(constEnumMergingWithValues5.ts, 1, 12)) +>X : Symbol(E.X, Decl(constEnumMergingWithValues5.ts, 2, 18)) +} + +export = foo +>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0)) + diff --git a/tests/baselines/reference/constEnumMergingWithValues5.types b/tests/baselines/reference/constEnumMergingWithValues5.types new file mode 100644 index 00000000000..617676ba0c0 --- /dev/null +++ b/tests/baselines/reference/constEnumMergingWithValues5.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/constEnumMergingWithValues5.ts === + +module foo { +>foo : typeof foo + + const enum E { X } +>E : E +>X : E +} + +export = foo +>foo : typeof foo + diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types index 49d6871804c..dd88a00ae3a 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.types +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -87,24 +87,24 @@ var a = baz(1, 1, g); // Should be number >g : (x: T, y: T) => T var b: number | string; ->b : string | number +>b : number | string var b = foo(g); // Should be number | string ->b : string | number ->foo(g) : string | number +>b : number | string +>foo(g) : number | string >foo : (cb: (x: number, y: string) => T) => T >g : (x: T, y: T) => T var b = bar(1, "one", g); // Should be number | string ->b : string | number ->bar(1, "one", g) : string | number +>b : number | string +>bar(1, "one", g) : number | string >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >1 : number >"one" : string >g : (x: T, y: T) => T var b = bar("one", 1, g); // Should be number | string ->b : string | number +>b : number | string >bar("one", 1, g) : string | number >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >"one" : string @@ -112,11 +112,11 @@ var b = bar("one", 1, g); // Should be number | string >g : (x: T, y: T) => T var b = baz(b, b, g); // Should be number | string ->b : string | number ->baz(b, b, g) : string | number +>b : number | string +>baz(b, b, g) : number | string >baz : (x: T, y: T, cb: (x: T, y: T) => U) => U ->b : string | number ->b : string | number +>b : number | string +>b : number | string >g : (x: T, y: T) => T var d: number[] | string[]; @@ -138,7 +138,7 @@ var d = bar(1, "one", h); // Should be number[] | string[] var d = bar("one", 1, h); // Should be number[] | string[] >d : number[] | string[] ->bar("one", 1, h) : number[] | string[] +>bar("one", 1, h) : string[] | number[] >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >"one" : string >1 : number diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index ff9ace5a2c0..e447ed62b39 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. Types of property 'pop' are incompatible. - Type '() => string | number | boolean' is not assignable to type '() => string | number'. - 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'. + Type '() => number | string | boolean' is not assignable to type '() => number | string'. + Type 'number | string | boolean' is not assignable to type 'number | string'. + Type 'boolean' is not assignable to type 'number | string'. + Type 'boolean' is not assignable to type 'string'. 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. @@ -31,10 +31,10 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 ~~~~~~~~~~~~ !!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number'. -!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number | string'. +!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number | string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'number | string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. 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 }]]; diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols index 3e23a7812f5..172336603ab 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols @@ -82,7 +82,5 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1)) >IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) ->a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types index 8e1915d4754..02dfecf5c08 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types @@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any >x4 : IWithCallSignatures | IWithCallSignatures4 >IWithCallSignatures : IWithCallSignatures >IWithCallSignatures4 : IWithCallSignatures4 ->a => /*here a should be any*/ a.toString() : (a: number) => string ->a : number ->a.toString() : string ->a.toString : (radix?: number) => string ->a : number ->toString : (radix?: number) => string +>a => /*here a should be any*/ a.toString() : (a: any) => any +>a : any +>a.toString() : any +>a.toString : any +>a : any +>toString : any diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types b/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types index c51227fd13a..8f2abf37e0e 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types @@ -187,7 +187,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 >Array : T[] >I1 : I1 >I2 : I2 ->[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1 | I2)[] +>[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1 | I2 | { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; methodOnlyInI2: (a: string) => string; propertyOnlyInI2: string; })[] >i1 : I1 >i2 : I2 >{ // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", } : { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; } diff --git a/tests/baselines/reference/contextualTyping12.errors.txt b/tests/baselines/reference/contextualTyping12.errors.txt new file mode 100644 index 00000000000..8b079ecc5e0 --- /dev/null +++ b/tests/baselines/reference/contextualTyping12.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. + Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. + Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping12.ts (1 errors) ==== + class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping12.symbols b/tests/baselines/reference/contextualTyping12.symbols deleted file mode 100644 index bafef4c8e0a..00000000000 --- a/tests/baselines/reference/contextualTyping12.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/contextualTyping12.ts === -class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } ->foo : Symbol(foo, Decl(contextualTyping12.ts, 0, 0)) ->bar : Symbol(bar, Decl(contextualTyping12.ts, 0, 11)) ->id : Symbol(id, Decl(contextualTyping12.ts, 0, 24)) ->id : Symbol(id, Decl(contextualTyping12.ts, 0, 42)) ->id : Symbol(id, Decl(contextualTyping12.ts, 0, 50)) ->name : Symbol(name, Decl(contextualTyping12.ts, 0, 55)) - diff --git a/tests/baselines/reference/contextualTyping12.types b/tests/baselines/reference/contextualTyping12.types deleted file mode 100644 index 68e2663fb6a..00000000000 --- a/tests/baselines/reference/contextualTyping12.types +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/contextualTyping12.ts === -class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } ->foo : foo ->bar : { id: number; }[] ->id : number ->[{id:1}, {id:2, name:"foo"}] : { id: number; }[] ->{id:1} : { id: number; } ->id : number ->1 : number ->{id:2, name:"foo"} : { id: number; name: string; } ->id : number ->2 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTyping17.errors.txt b/tests/baselines/reference/contextualTyping17.errors.txt new file mode 100644 index 00000000000..24c428db58b --- /dev/null +++ b/tests/baselines/reference/contextualTyping17.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping17.ts (1 errors) ==== + var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; + ~~~ +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping17.symbols b/tests/baselines/reference/contextualTyping17.symbols deleted file mode 100644 index 55631494105..00000000000 --- a/tests/baselines/reference/contextualTyping17.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/contextualTyping17.ts === -var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; ->foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping17.ts, 0, 10)) ->id : Symbol(id, Decl(contextualTyping17.ts, 0, 25)) ->foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping17.ts, 0, 39)) ->name : Symbol(name, Decl(contextualTyping17.ts, 0, 45)) - diff --git a/tests/baselines/reference/contextualTyping17.types b/tests/baselines/reference/contextualTyping17.types deleted file mode 100644 index 649bc339ba1..00000000000 --- a/tests/baselines/reference/contextualTyping17.types +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/contextualTyping17.ts === -var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; ->foo : { id: number; } ->id : number ->{id:4} : { id: number; } ->id : number ->4 : number ->foo = {id: 5, name:"foo"} : { id: number; name: string; } ->foo : { id: number; } ->{id: 5, name:"foo"} : { id: number; name: string; } ->id : number ->5 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTyping2.errors.txt b/tests/baselines/reference/contextualTyping2.errors.txt new file mode 100644 index 00000000000..2665204b167 --- /dev/null +++ b/tests/baselines/reference/contextualTyping2.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping2.ts (1 errors) ==== + var foo: {id:number;} = {id:4, name:"foo"}; + ~~~ +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping2.symbols b/tests/baselines/reference/contextualTyping2.symbols deleted file mode 100644 index 9c102092979..00000000000 --- a/tests/baselines/reference/contextualTyping2.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/contextualTyping2.ts === -var foo: {id:number;} = {id:4, name:"foo"}; ->foo : Symbol(foo, Decl(contextualTyping2.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping2.ts, 0, 10)) ->id : Symbol(id, Decl(contextualTyping2.ts, 0, 25)) ->name : Symbol(name, Decl(contextualTyping2.ts, 0, 30)) - diff --git a/tests/baselines/reference/contextualTyping2.types b/tests/baselines/reference/contextualTyping2.types deleted file mode 100644 index 0658247c089..00000000000 --- a/tests/baselines/reference/contextualTyping2.types +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/contextualTyping2.ts === -var foo: {id:number;} = {id:4, name:"foo"}; ->foo : { id: number; } ->id : number ->{id:4, name:"foo"} : { id: number; name: string; } ->id : number ->4 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTyping20.errors.txt b/tests/baselines/reference/contextualTyping20.errors.txt new file mode 100644 index 00000000000..d723dcd1d1b --- /dev/null +++ b/tests/baselines/reference/contextualTyping20.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. + Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. + Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping20.ts (1 errors) ==== + var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; + ~~~ +!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping20.symbols b/tests/baselines/reference/contextualTyping20.symbols deleted file mode 100644 index 505c6a04a59..00000000000 --- a/tests/baselines/reference/contextualTyping20.symbols +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/contextualTyping20.ts === -var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; ->foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping20.ts, 0, 9)) ->id : Symbol(id, Decl(contextualTyping20.ts, 0, 27)) ->foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping20.ts, 0, 43)) ->id : Symbol(id, Decl(contextualTyping20.ts, 0, 51)) ->name : Symbol(name, Decl(contextualTyping20.ts, 0, 56)) - diff --git a/tests/baselines/reference/contextualTyping20.types b/tests/baselines/reference/contextualTyping20.types deleted file mode 100644 index be863db836b..00000000000 --- a/tests/baselines/reference/contextualTyping20.types +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/compiler/contextualTyping20.ts === -var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; ->foo : { id: number; }[] ->id : number ->[{id:1}] : { id: number; }[] ->{id:1} : { id: number; } ->id : number ->1 : number ->foo = [{id:1}, {id:2, name:"foo"}] : { id: number; }[] ->foo : { id: number; }[] ->[{id:1}, {id:2, name:"foo"}] : { id: number; }[] ->{id:1} : { id: number; } ->id : number ->1 : number ->{id:2, name:"foo"} : { id: number; name: string; } ->id : number ->2 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTyping21.errors.txt b/tests/baselines/reference/contextualTyping21.errors.txt index d40192c6240..362ead49ad3 100644 --- a/tests/baselines/reference/contextualTyping21.errors.txt +++ b/tests/baselines/reference/contextualTyping21.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]'. - Type 'number | { id: number; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'. + Type '{ id: number; } | number' is not assignable to type '{ id: number; }'. Type 'number' is not assignable to type '{ id: number; }'. Property 'id' is missing in type 'Number'. @@ -7,7 +7,7 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number | ==== tests/cases/compiler/contextualTyping21.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1]; ~~~ -!!! error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]'. -!!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'. +!!! error TS2322: Type '{ id: number; } | number' is not assignable to type '{ id: number; }'. !!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'. !!! error TS2322: Property 'id' is missing in type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping30.errors.txt b/tests/baselines/reference/contextualTyping30.errors.txt index eda30769ac8..bce19c50896 100644 --- a/tests/baselines/reference/contextualTyping30.errors.txt +++ b/tests/baselines/reference/contextualTyping30.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. +tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/contextualTyping30.ts (1 errors) ==== function foo(param:number[]){}; foo([1, "a"]); ~~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'number'. !!! error TS2345: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping37.types b/tests/baselines/reference/contextualTyping37.types index 299b4400137..8acd4aedf04 100644 --- a/tests/baselines/reference/contextualTyping37.types +++ b/tests/baselines/reference/contextualTyping37.types @@ -3,7 +3,7 @@ var foo = <{ id: number; }[]>[{ foo: "s" }, { }]; >foo : { id: number; }[] ><{ id: number; }[]>[{ foo: "s" }, { }] : { id: number; }[] >id : number ->[{ foo: "s" }, { }] : {}[] +>[{ foo: "s" }, { }] : ({ foo: string; } | {})[] >{ foo: "s" } : { foo: string; } >foo : string >"s" : string diff --git a/tests/baselines/reference/contextualTyping4.errors.txt b/tests/baselines/reference/contextualTyping4.errors.txt new file mode 100644 index 00000000000..48eb2c406f0 --- /dev/null +++ b/tests/baselines/reference/contextualTyping4.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping4.ts (1 errors) ==== + class foo { public bar:{id:number;} = {id:5, name:"foo"}; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping4.symbols b/tests/baselines/reference/contextualTyping4.symbols deleted file mode 100644 index c5dcd4f1577..00000000000 --- a/tests/baselines/reference/contextualTyping4.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/contextualTyping4.ts === -class foo { public bar:{id:number;} = {id:5, name:"foo"}; } ->foo : Symbol(foo, Decl(contextualTyping4.ts, 0, 0)) ->bar : Symbol(bar, Decl(contextualTyping4.ts, 0, 11)) ->id : Symbol(id, Decl(contextualTyping4.ts, 0, 24)) ->id : Symbol(id, Decl(contextualTyping4.ts, 0, 39)) ->name : Symbol(name, Decl(contextualTyping4.ts, 0, 44)) - diff --git a/tests/baselines/reference/contextualTyping4.types b/tests/baselines/reference/contextualTyping4.types deleted file mode 100644 index 757c67745f1..00000000000 --- a/tests/baselines/reference/contextualTyping4.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/compiler/contextualTyping4.ts === -class foo { public bar:{id:number;} = {id:5, name:"foo"}; } ->foo : foo ->bar : { id: number; } ->id : number ->{id:5, name:"foo"} : { id: number; name: string; } ->id : number ->5 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTyping9.errors.txt b/tests/baselines/reference/contextualTyping9.errors.txt new file mode 100644 index 00000000000..f959d1e2e69 --- /dev/null +++ b/tests/baselines/reference/contextualTyping9.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. + Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. + Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. + + +==== tests/cases/compiler/contextualTyping9.ts (1 errors) ==== + var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; + ~~~ +!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping9.symbols b/tests/baselines/reference/contextualTyping9.symbols deleted file mode 100644 index f9ef2220c20..00000000000 --- a/tests/baselines/reference/contextualTyping9.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/contextualTyping9.ts === -var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; ->foo : Symbol(foo, Decl(contextualTyping9.ts, 0, 3)) ->id : Symbol(id, Decl(contextualTyping9.ts, 0, 9)) ->id : Symbol(id, Decl(contextualTyping9.ts, 0, 27)) ->id : Symbol(id, Decl(contextualTyping9.ts, 0, 35)) ->name : Symbol(name, Decl(contextualTyping9.ts, 0, 40)) - diff --git a/tests/baselines/reference/contextualTyping9.types b/tests/baselines/reference/contextualTyping9.types deleted file mode 100644 index 46480d64b30..00000000000 --- a/tests/baselines/reference/contextualTyping9.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/contextualTyping9.ts === -var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; ->foo : { id: number; }[] ->id : number ->[{id:1}, {id:2, name:"foo"}] : { id: number; }[] ->{id:1} : { id: number; } ->id : number ->1 : number ->{id:2, name:"foo"} : { id: number; name: string; } ->id : number ->2 : number ->name : string ->"foo" : string - diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index d3e5b9942e3..0bb61604336 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : ((x: A) => void)[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] +>xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index 26b06abf782..a1bfaf56336 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(number | Date)[]' is not assignable to type 'I'. +tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(Date | number)[]' is not assignable to type 'I'. Index signatures are incompatible. - Type 'number | Date' is not assignable to type 'Date'. + Type 'Date | number' is not assignable to type 'Date'. Type 'number' is not assignable to type 'Date'. Property 'toDateString' is missing in type 'Number'. @@ -12,9 +12,9 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ var x3: I = [new Date(), 1]; ~~ -!!! error TS2322: Type '(number | Date)[]' is not assignable to type 'I'. +!!! error TS2322: Type '(Date | number)[]' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'number | Date' is not assignable to type 'Date'. +!!! error TS2322: Type 'Date | number' is not assignable to type 'Date'. !!! error TS2322: Type 'number' is not assignable to type 'Date'. !!! error TS2322: Property 'toDateString' is missing in type 'Number'. var r2 = x3[1]; diff --git a/tests/baselines/reference/declFileTypeAnnotationParenType.js b/tests/baselines/reference/declFileTypeAnnotationParenType.js index c61517c7339..126ec3a873e 100644 --- a/tests/baselines/reference/declFileTypeAnnotationParenType.js +++ b/tests/baselines/reference/declFileTypeAnnotationParenType.js @@ -29,4 +29,4 @@ declare class c { declare var x: (() => c)[]; declare var y: (() => c)[]; declare var k: (() => c) | string; -declare var l: string | (() => c); +declare var l: (() => c) | string; diff --git a/tests/baselines/reference/declFileTypeAnnotationParenType.types b/tests/baselines/reference/declFileTypeAnnotationParenType.types index 31b6ad03751..6776a0f492f 100644 --- a/tests/baselines/reference/declFileTypeAnnotationParenType.types +++ b/tests/baselines/reference/declFileTypeAnnotationParenType.types @@ -23,9 +23,9 @@ var y = [() => new c()]; >c : typeof c var k: (() => c) | string = (() => new c()) || ""; ->k : string | (() => c) +>k : (() => c) | string >c : c ->(() => new c()) || "" : string | (() => c) +>(() => new c()) || "" : (() => c) | string >(() => new c()) : () => c >() => new c() : () => c >new c() : c @@ -33,8 +33,8 @@ var k: (() => c) | string = (() => new c()) || ""; >"" : string var l = (() => new c()) || ""; ->l : string | (() => c) ->(() => new c()) || "" : string | (() => c) +>l : (() => c) | string +>(() => new c()) || "" : (() => c) | string >(() => new c()) : () => c >() => new c() : () => c >new c() : c diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types b/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types index beef88c0ca2..e93f86dbde7 100644 --- a/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types +++ b/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types @@ -47,7 +47,7 @@ module M { >M : typeof M export type W = Window | string; ->W : string | Window +>W : Window | string >Window : Window export module N { @@ -57,7 +57,7 @@ module M { >Window : Window export var p: W; ->p : string | Window ->W : string | Window +>p : Window | string +>W : Window | string } } diff --git a/tests/baselines/reference/declarationEmitDestructuring3.js b/tests/baselines/reference/declarationEmitDestructuring3.js index b21c63203c8..81cb1d96fd8 100644 --- a/tests/baselines/reference/declarationEmitDestructuring3.js +++ b/tests/baselines/reference/declarationEmitDestructuring3.js @@ -15,4 +15,4 @@ function foo(_a) { //// [declarationEmitDestructuring3.d.ts] declare function bar([x, z, ...w]: any[]): void; -declare function foo([x, ...y]?: (string | number | boolean)[]): void; +declare function foo([x, ...y]?: (number | string | boolean)[]): void; diff --git a/tests/baselines/reference/declarationEmitDestructuring3.types b/tests/baselines/reference/declarationEmitDestructuring3.types index da9fc6d6606..737bb39e078 100644 --- a/tests/baselines/reference/declarationEmitDestructuring3.types +++ b/tests/baselines/reference/declarationEmitDestructuring3.types @@ -6,10 +6,10 @@ function bar([x, z, ...w]) { } >w : any[] function foo([x, ...y] = [1, "string", true]) { } ->foo : ([x, ...y]?: (string | number | boolean)[]) => void ->x : string | number | boolean ->y : (string | number | boolean)[] ->[1, "string", true] : (string | number | boolean)[] +>foo : ([x, ...y]?: (number | string | boolean)[]) => void +>x : number | string | boolean +>y : (number | string | boolean)[] +>[1, "string", true] : (number | string | boolean)[] >1 : number >"string" : string >true : boolean diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js index 9a9be8c69da..28330d94f77 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.js @@ -23,6 +23,6 @@ var x3 = a[0], y3 = a[1], z3 = a[2]; // emit x3, y3, z3 declare var x: number; declare var x1: number, y1: string; declare var z1: number; -declare var a: (string | number)[]; -declare var x2: string | number; -declare var x3: string | number, y3: string | number, z3: string | number; +declare var a: (number | string)[]; +declare var x2: number | string; +declare var x3: number | string, y3: number | string, z3: number | string; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types index 0feeaf2db1a..9629324b9f9 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types @@ -1,7 +1,7 @@ === tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts === var [] = [1, "hello"]; // Dont emit anything ->[1, "hello"] : (string | number)[] +>[1, "hello"] : (number | string)[] >1 : number >"hello" : string @@ -28,18 +28,18 @@ var [, , z1] = [0, 1, 2]; // emit z1: number >2 : number var a = [1, "hello"]; ->a : (string | number)[] ->[1, "hello"] : (string | number)[] +>a : (number | string)[] +>[1, "hello"] : (number | string)[] >1 : number >"hello" : string var [x2] = a; // emit x2: number | string ->x2 : string | number ->a : (string | number)[] +>x2 : number | string +>a : (number | string)[] var [x3, y3, z3] = a; // emit x3, y3, z3 ->x3 : string | number ->y3 : string | number ->z3 : string | number ->a : (string | number)[] +>x3 : number | string +>y3 : number | string +>z3 : number | string +>a : (number | string)[] diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js index 818b3a6f7a9..662b4625ec8 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.js @@ -25,7 +25,7 @@ declare var x11: number, y11: string; declare var a11: any, b11: any, c11: any; declare var a2: number, b2: string, x12: number, c2: boolean; declare var x13: number, y13: string; -declare var a3: (string | number)[], b3: { +declare var a3: (number | string)[], b3: { x: number; y: string; }; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types index 9fce72751cf..eb028aacff4 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types @@ -56,10 +56,10 @@ var [x13, y13] = [1, "hello"]; >"hello" : string var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; ->a3 : (string | number)[] +>a3 : (number | string)[] >b3 : { x: number; y: string; } ->[[x13, y13], { x: x13, y: y13 }] : [(string | number)[], { x: number; y: string; }] ->[x13, y13] : (string | number)[] +>[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }] +>[x13, y13] : (number | string)[] >x13 : number >y13 : string >{ x: x13, y: y13 } : { x: number; y: string; } diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js index 1bd07e7b974..d83c1b721d8 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.js @@ -25,7 +25,7 @@ declare var a5: number[]; declare var x14: number, a6: number[]; declare var x15: number, y15: number, a7: number[]; declare var x16: number, y16: number, z16: number, a8: number[]; -declare var a9: (string | number | boolean)[]; -declare var x17: string | number | boolean, a10: (string | number | boolean)[]; -declare var x18: string | number | boolean, y18: string | number | boolean, a12: (string | number | boolean)[]; -declare var x19: string | number | boolean, y19: string | number | boolean, z19: string | number | boolean, a13: (string | number | boolean)[]; +declare var a9: (number | string | boolean)[]; +declare var x17: number | string | boolean, a10: (number | string | boolean)[]; +declare var x18: number | string | boolean, y18: number | string | boolean, a12: (number | string | boolean)[]; +declare var x19: number | string | boolean, y19: number | string | boolean, z19: number | string | boolean, a13: (number | string | boolean)[]; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types index 2cc56abcb05..1e8701eedb5 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types @@ -34,35 +34,35 @@ var [x16, y16, z16, ...a8] = [1, 2, 3]; >3 : number var [...a9] = [1, "hello", true]; ->a9 : (string | number | boolean)[] ->[1, "hello", true] : (string | number | boolean)[] +>a9 : (number | string | boolean)[] +>[1, "hello", true] : (number | string | boolean)[] >1 : number >"hello" : string >true : boolean var [x17, ...a10] = [1, "hello", true]; ->x17 : string | number | boolean ->a10 : (string | number | boolean)[] ->[1, "hello", true] : (string | number | boolean)[] +>x17 : number | string | boolean +>a10 : (number | string | boolean)[] +>[1, "hello", true] : (number | string | boolean)[] >1 : number >"hello" : string >true : boolean var [x18, y18, ...a12] = [1, "hello", true]; ->x18 : string | number | boolean ->y18 : string | number | boolean ->a12 : (string | number | boolean)[] ->[1, "hello", true] : (string | number | boolean)[] +>x18 : number | string | boolean +>y18 : number | string | boolean +>a12 : (number | string | boolean)[] +>[1, "hello", true] : (number | string | boolean)[] >1 : number >"hello" : string >true : boolean var [x19, y19, z19, ...a13] = [1, "hello", true]; ->x19 : string | number | boolean ->y19 : string | number | boolean ->z19 : string | number | boolean ->a13 : (string | number | boolean)[] ->[1, "hello", true] : (string | number | boolean)[] +>x19 : number | string | boolean +>y19 : number | string | boolean +>z19 : number | string | boolean +>a13 : (number | string | boolean)[] +>[1, "hello", true] : (number | string | boolean)[] >1 : number >"hello" : string >true : boolean diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt new file mode 100644 index 00000000000..be08d976eeb --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'. +tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does not exist on type '() => number'. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default function Decl() { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + return 0; + } + + export interface Decl { + p1: number; + p2: number; + } + + export namespace Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + export var x = 10; + export var y = 20; + + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + + var x: Entity; + ~~~~~~ +!!! error TS2304: Cannot find name 'Entity'. + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + + Entity.x; + ~ +!!! error TS2339: Property 'x' does not exist on type '() => number'. + Entity.y; + ~ +!!! error TS2339: Property 'y' does not exist on type '() => number'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js new file mode 100644 index 00000000000..99b8ecab1d3 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -0,0 +1,50 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge01.ts] //// + +//// [m1.ts] + +export default function Decl() { + return 0; +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + export var x = 10; + export var y = 20; + + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; + +Entity.x; +Entity.y; + +//// [m1.js] +function Decl() { + return 0; +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +var Decl; +(function (Decl) { + Decl.x = 10; + Decl.y = 20; +})(Decl = exports.Decl || (exports.Decl = {})); +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +m1_1.default.x; +m1_1.default.y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt new file mode 100644 index 00000000000..ad9b85c7e94 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default class Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + } + + export interface Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + p1: number; + p2: number; + } + + export namespace Decl { + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? + + var x: Entity; + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + var z = new Entity(); + var sum = z.p1 + z.p2 + ~~ +!!! error TS2339: Property 'p1' does not exist on type 'Decl'. + ~~ +!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js new file mode 100644 index 00000000000..e3897395c74 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge02.ts] //// + +//// [m1.ts] + +export default class Decl { +} + +export interface Decl { + p1: number; + p2: number; +} + +export namespace Decl { + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 + +//// [m1.js] +var Decl = (function () { + function Decl() { + } + return Decl; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +var z = new m1_1.default(); +var sum = z.p1 + z.p2; diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt new file mode 100644 index 00000000000..b1d405671e3 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? +tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. +tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. + + +==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== + + export default class Decl { + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + } + + interface Decl { + ~~~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~~ +!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. + p1: number; + p2: number; + } + + namespace Decl { + interface I { + } + } + +==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? + + var x: Entity; + var y: Entity.I; + ~~~~~~ +!!! error TS2503: Cannot find namespace 'Entity'. + var z = new Entity(); + var sum = z.p1 + z.p2 + ~~ +!!! error TS2339: Property 'p1' does not exist on type 'Decl'. + ~~ +!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js new file mode 100644 index 00000000000..05e7de94120 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/es6/modules/defaultExportsCannotMerge03.ts] //// + +//// [m1.ts] + +export default class Decl { +} + +interface Decl { + p1: number; + p2: number; +} + +namespace Decl { + interface I { + } +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +var x: Entity; +var y: Entity.I; +var z = new Entity(); +var sum = z.p1 + z.p2 + +//// [m1.js] +var Decl = (function () { + function Decl() { + } + return Decl; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Decl; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); +var x; +var y; +var z = new m1_1.default(); +var sum = z.p1 + z.p2; diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt new file mode 100644 index 00000000000..000a9b8f30e --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge04.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(2,25): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(5,11): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(9,11): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(12,18): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + + +==== tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts (4 errors) ==== + + export default function Foo() { + ~~~ +!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. + } + + namespace Foo { + ~~~ +!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead. + export var x; + } + + interface Foo { + ~~~ +!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + } + + export interface Foo { + ~~~ +!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. + } \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.js b/tests/baselines/reference/defaultExportsCannotMerge04.js new file mode 100644 index 00000000000..eb1122a8197 --- /dev/null +++ b/tests/baselines/reference/defaultExportsCannotMerge04.js @@ -0,0 +1,23 @@ +//// [defaultExportsCannotMerge04.ts] + +export default function Foo() { +} + +namespace Foo { + export var x; +} + +interface Foo { +} + +export interface Foo { +} + +//// [defaultExportsCannotMerge04.js] +function Foo() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Foo; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt new file mode 100644 index 00000000000..dc2db292eb5 --- /dev/null +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,28): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts (1 errors) ==== + class Base { + foo(x: { a: number }): { a: number } { + return null; + } + } + + class Derived extends Base { + foo(x: { a: number; b: number }): { a: number; b: number } { + return null; + } + + bar() { + var r = super.foo({ a: 1 }); // { a: number } + var r2 = super.foo({ a: 1, b: 2 }); // { a: number } + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. + var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.symbols b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.symbols deleted file mode 100644 index e935d7bf66a..00000000000 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.symbols +++ /dev/null @@ -1,56 +0,0 @@ -=== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts === -class Base { ->Base : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0)) - - foo(x: { a: number }): { a: number } { ->foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12)) ->x : Symbol(x, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 8)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 12)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 28)) - - return null; - } -} - -class Derived extends Base { ->Derived : Symbol(Derived, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 4, 1)) ->Base : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0)) - - foo(x: { a: number; b: number }): { a: number; b: number } { ->foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28)) ->x : Symbol(x, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 8)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 12)) ->b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 23)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 39)) ->b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 50)) - - return null; - } - - bar() { ->bar : Symbol(bar, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 9, 5)) - - var r = super.foo({ a: 1 }); // { a: number } ->r : Symbol(r, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 12, 11)) ->super.foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12)) ->super : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0)) ->foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 12, 27)) - - var r2 = super.foo({ a: 1, b: 2 }); // { a: number } ->r2 : Symbol(r2, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 11)) ->super.foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12)) ->super : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0)) ->foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 28)) ->b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 34)) - - var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } ->r3 : Symbol(r3, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 11)) ->this.foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28)) ->this : Symbol(Derived, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 4, 1)) ->foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28)) ->a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 27)) ->b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 33)) - } -} diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.types b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.types deleted file mode 100644 index d8d9f657255..00000000000 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.types +++ /dev/null @@ -1,69 +0,0 @@ -=== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts === -class Base { ->Base : Base - - foo(x: { a: number }): { a: number } { ->foo : (x: { a: number; }) => { a: number; } ->x : { a: number; } ->a : number ->a : number - - return null; ->null : null - } -} - -class Derived extends Base { ->Derived : Derived ->Base : Base - - foo(x: { a: number; b: number }): { a: number; b: number } { ->foo : (x: { a: number; b: number; }) => { a: number; b: number; } ->x : { a: number; b: number; } ->a : number ->b : number ->a : number ->b : number - - return null; ->null : null - } - - bar() { ->bar : () => void - - var r = super.foo({ a: 1 }); // { a: number } ->r : { a: number; } ->super.foo({ a: 1 }) : { a: number; } ->super.foo : (x: { a: number; }) => { a: number; } ->super : Base ->foo : (x: { a: number; }) => { a: number; } ->{ a: 1 } : { a: number; } ->a : number ->1 : number - - var r2 = super.foo({ a: 1, b: 2 }); // { a: number } ->r2 : { a: number; } ->super.foo({ a: 1, b: 2 }) : { a: number; } ->super.foo : (x: { a: number; }) => { a: number; } ->super : Base ->foo : (x: { a: number; }) => { a: number; } ->{ a: 1, b: 2 } : { a: number; b: number; } ->a : number ->1 : number ->b : number ->2 : number - - var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } ->r3 : { a: number; b: number; } ->this.foo({ a: 1, b: 2 }) : { a: number; b: number; } ->this.foo : (x: { a: number; b: number; }) => { a: number; b: number; } ->this : Derived ->foo : (x: { a: number; b: number; }) => { a: number; b: number; } ->{ a: 1, b: 2 } : { a: number; b: number; } ->a : number ->1 : number ->b : number ->2 : number - } -} diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types index bde9c867e2b..adff61e407c 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types @@ -148,8 +148,8 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"]; > : undefined > : undefined > : undefined ->c10 : (string | number)[] ->[1, 2, 3, 4, "hello"] : (string | number)[] +>c10 : (number | string)[] +>[1, 2, 3, 4, "hello"] : (number | string)[] >1 : number >2 : number >3 : number @@ -157,10 +157,10 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"]; >"hello" : string var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : string | number ->c12 : string | number ->c13 : (string | number)[] ->[1, 2, "string"] : (string | number)[] +>c11 : number | string +>c12 : number | string +>c13 : (number | string)[] +>[1, 2, "string"] : (number | string)[] >1 : number >2 : number >"string" : string diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types index 2d5d82c5efe..0a9e75a8aed 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types @@ -149,8 +149,8 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"]; > : undefined > : undefined > : undefined ->c10 : (string | number)[] ->[1, 2, 3, 4, "hello"] : (string | number)[] +>c10 : (number | string)[] +>[1, 2, 3, 4, "hello"] : (number | string)[] >1 : number >2 : number >3 : number @@ -158,10 +158,10 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"]; >"hello" : string var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : string | number ->c12 : string | number ->c13 : (string | number)[] ->[1, 2, "string"] : (string | number)[] +>c11 : number | string +>c12 : number | string +>c13 : (number | string)[] +>[1, 2, "string"] : (number | string)[] >1 : number >2 : number >"string" : string diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 12f50d6886c..95524d4bf4d 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -4,8 +4,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. Types of property 'pop' are incompatible. - Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'. - Type 'string | number | string[][]' is not assignable to type 'number | string[][]'. + Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'. + Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'string[][]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -26,10 +26,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'. Types of property 'z' are incompatible. Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'. Types of property 'b' are incompatible. - Type 'boolean' is not assignable to type 'string | number'. - Type 'boolean' is not assignable to type 'number'. + Type 'boolean' is not assignable to type 'number | string'. + Type 'boolean' is not assignable to type 'string'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property '2' are incompatible. Type 'boolean' is not assignable to type '[[any]]'. @@ -73,8 +73,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. !!! error TS2345: Types of property 'pop' are incompatible. -!!! error TS2345: Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'. -!!! error TS2345: Type 'string | number | string[][]' is not assignable to type 'number | string[][]'. +!!! error TS2345: Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'. +!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'string[][]'. @@ -135,10 +135,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2345: Type 'boolean' is not assignable to type 'number'. c3({ b: true }); // Error, implied type is { b: number|string }. ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'. +!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'. !!! error TS2345: Types of property 'b' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. +!!! error TS2345: Type 'boolean' is not assignable to type 'number | string'. +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] ~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types index d51a0e32dc8..b8d48dcb9d4 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types @@ -23,8 +23,8 @@ type stringOrNumArray = Array; >Number : Number function a1(...x: (number|string)[]) { } ->a1 : (...x: (string | number)[]) => void ->x : (string | number)[] +>a1 : (...x: (number | string)[]) => void +>x : (number | string)[] function a2(...a) { } >a2 : (...a: any[]) => void @@ -75,8 +75,8 @@ var array = [1, 2, 3]; >3 : number var array2 = [true, false, "hello"]; ->array2 : (string | boolean)[] ->[true, false, "hello"] : (string | boolean)[] +>array2 : (boolean | string)[] +>[true, false, "hello"] : (boolean | string)[] >true : boolean >false : boolean >"hello" : string @@ -90,7 +90,7 @@ a2([...array]); a1(...array); >a1(...array) : void ->a1 : (...x: (string | number)[]) => void +>a1 : (...x: (number | string)[]) => void >...array : number >array : number[] @@ -109,7 +109,7 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]] a10([1, 2, [["string"]], false, true]); // Parameter type is any[] >a10([1, 2, [["string"]], false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void ->[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] +>[1, 2, [["string"]], false, true] : (number | string[][] | boolean)[] >1 : number >2 : number >[["string"]] : string[][] diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types index 63d5d074a8d..b439c4134ba 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types @@ -23,8 +23,8 @@ type stringOrNumArray = Array; >Number : Number function a1(...x: (number|string)[]) { } ->a1 : (...x: (string | number)[]) => void ->x : (string | number)[] +>a1 : (...x: (number | string)[]) => void +>x : (number | string)[] function a2(...a) { } >a2 : (...a: any[]) => void @@ -75,8 +75,8 @@ var array = [1, 2, 3]; >3 : number var array2 = [true, false, "hello"]; ->array2 : (string | boolean)[] ->[true, false, "hello"] : (string | boolean)[] +>array2 : (boolean | string)[] +>[true, false, "hello"] : (boolean | string)[] >true : boolean >false : boolean >"hello" : string @@ -90,7 +90,7 @@ a2([...array]); a1(...array); >a1(...array) : void ->a1 : (...x: (string | number)[]) => void +>a1 : (...x: (number | string)[]) => void >...array : number >array : number[] @@ -109,7 +109,7 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]] a10([1, 2, [["string"]], false, true]); // Parameter type is any[] >a10([1, 2, [["string"]], false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void ->[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] +>[1, 2, [["string"]], false, true] : (number | string[][] | boolean)[] >1 : number >2 : number >[["string"]] : string[][] diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 707fb005a80..7e71a2cd753 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. - Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'. + Type 'boolean' is not assignable to type 'string'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property '2' are incompatible. @@ -9,8 +9,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( Property '0' is missing in type 'String'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. Property '2' is missing in type '[number, number]'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,24): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'. @@ -43,8 +43,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'. +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2304: Cannot find name 'array2'. @@ -60,8 +60,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( !!! error TS2345: Property '2' is missing in type '[number, number]'. a6([1, 2, "string"]); // Error, parameter type is number[] ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'number'. !!! error TS2345: Type 'string' is not assignable to type 'number'. diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index dca02a9a84e..47e50b1df83 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. - Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. + Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== @@ -47,5 +47,5 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. !!! error TS2345: Types of property '0' are incompatible. !!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. +!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index ef3507f0f8b..a0630fee995 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -84,8 +84,8 @@ var [...c1] = [1,2,3]; >3 : number var [...c2] = [1,2,3, "string"]; ->c2 : (string | number)[] ->[1,2,3, "string"] : (string | number)[] +>c2 : (number | string)[] +>[1,2,3, "string"] : (number | string)[] >1 : number >2 : number >3 : number @@ -113,9 +113,9 @@ var temp1 = [true, false, true] >true : boolean var [d3, d4] = [1, "string", ...temp1]; ->d3 : string | number | boolean ->d4 : string | number | boolean ->[1, "string", ...temp1] : (string | number | boolean)[] +>d3 : number | string | boolean +>d4 : number | string | boolean +>[1, "string", ...temp1] : (number | string | boolean)[] >1 : number >"string" : string >...temp1 : boolean diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index d62574c28f0..f9faf519b0a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -84,8 +84,8 @@ var [...c1] = [1,2,3]; >3 : number var [...c2] = [1,2,3, "string"]; ->c2 : (string | number)[] ->[1,2,3, "string"] : (string | number)[] +>c2 : (number | string)[] +>[1,2,3, "string"] : (number | string)[] >1 : number >2 : number >3 : number @@ -113,9 +113,9 @@ var temp1 = [true, false, true] >true : boolean var [d3, d4] = [1, "string", ...temp1]; ->d3 : string | number | boolean ->d4 : string | number | boolean ->[1, "string", ...temp1] : (string | number | boolean)[] +>d3 : number | string | boolean +>d4 : number | string | boolean +>[1, "string", ...temp1] : (number | string | boolean)[] >1 : number >"string" : string >...temp1 : boolean diff --git a/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt b/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt index df4f8f13c31..85dd29b78a3 100644 --- a/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt +++ b/tests/baselines/reference/duplicateSymbolsExportMatching.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration I must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration I must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration E must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration E must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration inst must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration inst must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration v must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration v must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration w must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration w must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration F must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(24,15): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(25,22): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(26,22): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(27,15): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(32,12): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(35,19): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(42,9): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(43,16): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(44,9): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(45,16): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. tests/cases/compiler/duplicateSymbolsExportMatching.ts(49,12): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged -tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration F must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration C must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration D must be all exported or all local. -tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration D must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(52,21): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(56,11): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(57,12): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(58,19): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(64,11): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. +tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. ==== tests/cases/compiler/duplicateSymbolsExportMatching.ts (18 errors) ==== @@ -44,28 +44,28 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind module N2 { interface I { } ~ -!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. export interface I { } // error ~ -!!! error TS2395: Individual declarations in merged declaration I must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. export interface E { } ~ -!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. interface E { } // error ~ -!!! error TS2395: Individual declarations in merged declaration E must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. } // Should report error only once for instantiated module module M { module inst { ~~~~ -!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. var t; } export module inst { // one error ~~~~ -!!! error TS2395: Individual declarations in merged declaration inst must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. var t; } } @@ -74,41 +74,41 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind module M2 { var v: string; ~ -!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. export var v: string; // one error (visibility) ~ -!!! error TS2395: Individual declarations in merged declaration v must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. var w: number; ~ -!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. export var w: string; // two errors (visibility and type mismatch) ~ -!!! error TS2395: Individual declarations in merged declaration w must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. } module M { module F { ~ -!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. ~ !!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged var t; } export function F() { } // Only one error for duplicate identifier (don't consider visibility) ~ -!!! error TS2395: Individual declarations in merged declaration F must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. } module M { class C { } ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. module C { } ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) ~ -!!! error TS2395: Individual declarations in merged declaration C must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. var t; } } @@ -116,7 +116,7 @@ tests/cases/compiler/duplicateSymbolsExportMatching.ts(65,18): error TS2395: Ind // Top level interface D { } ~ -!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. export interface D { } ~ -!!! error TS2395: Individual declarations in merged declaration D must be all exported or all local. \ No newline at end of file +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. \ No newline at end of file diff --git a/tests/baselines/reference/enumBasics.types b/tests/baselines/reference/enumBasics.types index 6a147f01062..87f6f12b6b2 100644 --- a/tests/baselines/reference/enumBasics.types +++ b/tests/baselines/reference/enumBasics.types @@ -172,8 +172,8 @@ enum E9 { // (refer to .js to validate) // Enum constant members are propagated var doNotPropagate = [ ->doNotPropagate : (E3 | E4 | E7 | E8)[] ->[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : (E3 | E4 | E7 | E8)[] +>doNotPropagate : (E8 | E7 | E4 | E3)[] +>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : (E8 | E7 | E4 | E3)[] E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z >E8.B : E8 @@ -198,8 +198,8 @@ var doNotPropagate = [ ]; // Enum computed members are not propagated var doPropagate = [ ->doPropagate : (E5 | E6 | E9)[] ->[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E5 | E6 | E9)[] +>doPropagate : (E9 | E6 | E5)[] +>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E9 | E6 | E5)[] E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C >E9.A : E9 diff --git a/tests/baselines/reference/es5-commonjs.js b/tests/baselines/reference/es5-commonjs.js new file mode 100644 index 00000000000..2a0c6d924ca --- /dev/null +++ b/tests/baselines/reference/es5-commonjs.js @@ -0,0 +1,27 @@ +//// [es5-commonjs.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5-commonjs.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = A; diff --git a/tests/baselines/reference/es5-commonjs.symbols b/tests/baselines/reference/es5-commonjs.symbols new file mode 100644 index 00000000000..41e4484afcd --- /dev/null +++ b/tests/baselines/reference/es5-commonjs.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es5-commonjs.ts === + +export default class A +>A : Symbol(A, Decl(es5-commonjs.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-commonjs.ts, 6, 5)) + { + return 42; + } +} + diff --git a/tests/baselines/reference/es5-commonjs.types b/tests/baselines/reference/es5-commonjs.types new file mode 100644 index 00000000000..4c1bc922917 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es5-commonjs.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + diff --git a/tests/baselines/reference/es5-commonjs2.js b/tests/baselines/reference/es5-commonjs2.js new file mode 100644 index 00000000000..174665b4125 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs2.js @@ -0,0 +1,8 @@ +//// [es5-commonjs2.ts] + +export default 1; + + +//// [es5-commonjs2.js] +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = 1; diff --git a/tests/baselines/reference/es5-commonjs2.symbols b/tests/baselines/reference/es5-commonjs2.symbols new file mode 100644 index 00000000000..ee57f9ad5cd --- /dev/null +++ b/tests/baselines/reference/es5-commonjs2.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es5-commonjs2.ts === + +No type information for this code.export default 1; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es5-commonjs2.types b/tests/baselines/reference/es5-commonjs2.types new file mode 100644 index 00000000000..ee57f9ad5cd --- /dev/null +++ b/tests/baselines/reference/es5-commonjs2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es5-commonjs2.ts === + +No type information for this code.export default 1; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es5-commonjs3.js b/tests/baselines/reference/es5-commonjs3.js new file mode 100644 index 00000000000..cc3d0b1527a --- /dev/null +++ b/tests/baselines/reference/es5-commonjs3.js @@ -0,0 +1,9 @@ +//// [es5-commonjs3.ts] + +export default "test"; +export var __esModule = 1; + + +//// [es5-commonjs3.js] +exports.default = "test"; +exports.__esModule = 1; diff --git a/tests/baselines/reference/es5-commonjs3.symbols b/tests/baselines/reference/es5-commonjs3.symbols new file mode 100644 index 00000000000..9d5bc830099 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es5-commonjs3.ts === + +export default "test"; +export var __esModule = 1; +>__esModule : Symbol(__esModule, Decl(es5-commonjs3.ts, 2, 10)) + diff --git a/tests/baselines/reference/es5-commonjs3.types b/tests/baselines/reference/es5-commonjs3.types new file mode 100644 index 00000000000..facdfae00ce --- /dev/null +++ b/tests/baselines/reference/es5-commonjs3.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5-commonjs3.ts === + +export default "test"; +export var __esModule = 1; +>__esModule : number +>1 : number + diff --git a/tests/baselines/reference/es5-commonjs4.js b/tests/baselines/reference/es5-commonjs4.js new file mode 100644 index 00000000000..50a4c49e464 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs4.js @@ -0,0 +1,28 @@ +//// [es5-commonjs4.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} +export var __esModule = 1; + + +//// [es5-commonjs4.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +exports.default = A; +exports.__esModule = 1; diff --git a/tests/baselines/reference/es5-commonjs4.symbols b/tests/baselines/reference/es5-commonjs4.symbols new file mode 100644 index 00000000000..22d41128d74 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs4.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es5-commonjs4.ts === + +export default class A +>A : Symbol(A, Decl(es5-commonjs4.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-commonjs4.ts, 6, 5)) + { + return 42; + } +} +export var __esModule = 1; +>__esModule : Symbol(__esModule, Decl(es5-commonjs4.ts, 13, 10)) + diff --git a/tests/baselines/reference/es5-commonjs4.types b/tests/baselines/reference/es5-commonjs4.types new file mode 100644 index 00000000000..d3471afbfeb --- /dev/null +++ b/tests/baselines/reference/es5-commonjs4.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/es5-commonjs4.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} +export var __esModule = 1; +>__esModule : number +>1 : number + diff --git a/tests/baselines/reference/es5-commonjs5.js b/tests/baselines/reference/es5-commonjs5.js new file mode 100644 index 00000000000..ead6079eff1 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs5.js @@ -0,0 +1,13 @@ +//// [es5-commonjs5.ts] + +export default function () { + return "test"; +} + + +//// [es5-commonjs5.js] +function default_1() { + return "test"; +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = default_1; diff --git a/tests/baselines/reference/es5-commonjs5.symbols b/tests/baselines/reference/es5-commonjs5.symbols new file mode 100644 index 00000000000..b134e216668 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5-commonjs5.ts === + +No type information for this code.export default function () { +No type information for this code. return "test"; +No type information for this code.} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es5-commonjs5.types b/tests/baselines/reference/es5-commonjs5.types new file mode 100644 index 00000000000..d8094e1e0ea --- /dev/null +++ b/tests/baselines/reference/es5-commonjs5.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5-commonjs5.ts === + +export default function () { + return "test"; +>"test" : string +} + diff --git a/tests/baselines/reference/es5-commonjs6.js b/tests/baselines/reference/es5-commonjs6.js new file mode 100644 index 00000000000..7c2c8b21779 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs6.js @@ -0,0 +1,10 @@ +//// [es5-commonjs6.ts] + +export default "test"; +var __esModule = 1; + + +//// [es5-commonjs6.js] +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = "test"; +var __esModule = 1; diff --git a/tests/baselines/reference/es5-commonjs6.symbols b/tests/baselines/reference/es5-commonjs6.symbols new file mode 100644 index 00000000000..7a2847e0f25 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es5-commonjs6.ts === + +export default "test"; +var __esModule = 1; +>__esModule : Symbol(__esModule, Decl(es5-commonjs6.ts, 2, 3)) + diff --git a/tests/baselines/reference/es5-commonjs6.types b/tests/baselines/reference/es5-commonjs6.types new file mode 100644 index 00000000000..904b69dec22 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs6.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5-commonjs6.ts === + +export default "test"; +var __esModule = 1; +>__esModule : number +>1 : number + diff --git a/tests/baselines/reference/es5-system.js b/tests/baselines/reference/es5-system.js new file mode 100644 index 00000000000..2674527722a --- /dev/null +++ b/tests/baselines/reference/es5-system.js @@ -0,0 +1,34 @@ +//// [es5-system.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5-system.js] +System.register([], function(exports_1) { + var A; + return { + setters:[], + execute: function() { + A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; + })(); + exports_1("default", A); + } + } +}); diff --git a/tests/baselines/reference/es5-system.symbols b/tests/baselines/reference/es5-system.symbols new file mode 100644 index 00000000000..5211e3c4259 --- /dev/null +++ b/tests/baselines/reference/es5-system.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es5-system.ts === + +export default class A +>A : Symbol(A, Decl(es5-system.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-system.ts, 6, 5)) + { + return 42; + } +} + diff --git a/tests/baselines/reference/es5-system.types b/tests/baselines/reference/es5-system.types new file mode 100644 index 00000000000..eae884a78b4 --- /dev/null +++ b/tests/baselines/reference/es5-system.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es5-system.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js index 3abb92f816f..92ac306698a 100644 --- a/tests/baselines/reference/es5-umd3.js +++ b/tests/baselines/reference/es5-umd3.js @@ -31,5 +31,6 @@ export default class A }; return A; })(); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = A; }); diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js index b5cfdb02f78..0d4076e39a1 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js @@ -12,6 +12,7 @@ var C = (function () { C.prototype.method = function () { }; return C; })(); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js index de0d109dadf..5e5eeae1f0f 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -12,6 +12,7 @@ var default_1 = (function () { default_1.prototype.method = function () { }; return default_1; })(); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js index bff80940a02..a977447f9ad 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js @@ -24,6 +24,7 @@ var C = (function () { }; return C; })(); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; var after = new C(); var t = C; diff --git a/tests/baselines/reference/es5ExportDefaultExpression.js b/tests/baselines/reference/es5ExportDefaultExpression.js index 944b6fc71a5..a825e45971b 100644 --- a/tests/baselines/reference/es5ExportDefaultExpression.js +++ b/tests/baselines/reference/es5ExportDefaultExpression.js @@ -4,6 +4,7 @@ export default (1 + 2); //// [es5ExportDefaultExpression.js] +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (1 + 2); diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js index 673cc3cb453..afc44ac53f5 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js @@ -5,6 +5,7 @@ export default function f() { } //// [es5ExportDefaultFunctionDeclaration.js] function f() { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js index ad1334e810b..10f1db6a0eb 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -5,6 +5,7 @@ export default function () { } //// [es5ExportDefaultFunctionDeclaration2.js] function default_1() { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js index 1fc57976439..af437c08766 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js @@ -13,6 +13,7 @@ var before = func(); function func() { return func; } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = func; var after = func(); diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.js b/tests/baselines/reference/es5ExportDefaultIdentifier.js index 739f3d6c109..c8fb6b3be27 100644 --- a/tests/baselines/reference/es5ExportDefaultIdentifier.js +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.js @@ -8,6 +8,7 @@ export default f; //// [es5ExportDefaultIdentifier.js] function f() { } exports.f = f; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index 70e4f7e2f57..9c8cbec9db5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -14,6 +14,7 @@ import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import //// [es6ImportDefaultBindingAmd_0.js] define(["require", "exports"], function (require, exports) { var a = 10; + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index caa46ed30ef..a5e8d509da1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -17,6 +17,7 @@ var c = (function () { } return c; })(); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = c; //// [client.js] var server_1 = require("server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 15ca1284a1e..7090b7a0663 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -22,6 +22,7 @@ var x: number = defaultBinding6; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.js] var a = 10; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index b6b03176df1..2b0e3ebbeb5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -22,6 +22,7 @@ export var x1: number = defaultBinding6; //// [server.js] var a = 10; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] var server_1 = require("server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index e6211ac1ebe..dad034c618c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -25,6 +25,7 @@ var a = (function () { } return a; })(); +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] var server_1 = require("server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js index 90521007735..b7da05d7dbb 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -27,6 +27,7 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; exports.x = exports.a; exports.m = exports.a; + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = {}; }); //// [client.js] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index c2bd5476a7c..4a987110224 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -11,6 +11,7 @@ var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] var a = 10; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index ed40582e923..a032325fbb4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -12,6 +12,7 @@ export var x: number = defaultBinding; //// [server.js] define(["require", "exports"], function (require, exports) { var a = 10; + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; }); //// [client.js] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index e03ded5fd5a..639ffce59fd 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -16,6 +16,7 @@ define(["require", "exports"], function (require, exports) { } return a; })(); + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; }); //// [client.js] diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 1208ace5dde..10b8bec03c7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -18,6 +18,7 @@ import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be //// [es6ImportDefaultBindingMergeErrors_0.js] var a = 10; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] var es6ImportDefaultBindingMergeErrors_0_1 = require("es6ImportDefaultBindingMergeErrors_0"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index e2c5fab4c94..2fb7f0644b9 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -13,6 +13,7 @@ export import defaultBinding2 from "server"; // non referenced //// [server.js] define(["require", "exports"], function (require, exports) { var a = 10; + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; }); //// [client.js] diff --git a/tests/baselines/reference/exportAndImport-es3-amd.js b/tests/baselines/reference/exportAndImport-es3-amd.js index a4552e70d68..d2293a56e23 100644 --- a/tests/baselines/reference/exportAndImport-es3-amd.js +++ b/tests/baselines/reference/exportAndImport-es3-amd.js @@ -16,6 +16,7 @@ export default function f2() { define(["require", "exports"], function (require, exports) { function f1() { } + exports.__esModule = true; exports["default"] = f1; }); //// [m2.js] @@ -23,5 +24,6 @@ define(["require", "exports", "./m1"], function (require, exports, m1_1) { function f2() { m1_1["default"](); } + exports.__esModule = true; exports["default"] = f2; }); diff --git a/tests/baselines/reference/exportAndImport-es3.js b/tests/baselines/reference/exportAndImport-es3.js index 5f467509b68..1be548bc930 100644 --- a/tests/baselines/reference/exportAndImport-es3.js +++ b/tests/baselines/reference/exportAndImport-es3.js @@ -15,10 +15,12 @@ export default function f2() { //// [m1.js] function f1() { } +exports.__esModule = true; exports["default"] = f1; //// [m2.js] var m1_1 = require("./m1"); function f2() { m1_1["default"](); } +exports.__esModule = true; exports["default"] = f2; diff --git a/tests/baselines/reference/exportAndImport-es5-amd.js b/tests/baselines/reference/exportAndImport-es5-amd.js index 4966af874f7..447356b1230 100644 --- a/tests/baselines/reference/exportAndImport-es5-amd.js +++ b/tests/baselines/reference/exportAndImport-es5-amd.js @@ -16,6 +16,7 @@ export default function f2() { define(["require", "exports"], function (require, exports) { function f1() { } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f1; }); //// [m2.js] @@ -23,5 +24,6 @@ define(["require", "exports", "./m1"], function (require, exports, m1_1) { function f2() { m1_1.default(); } + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f2; }); diff --git a/tests/baselines/reference/exportAndImport-es5.js b/tests/baselines/reference/exportAndImport-es5.js index 02d0e43e5a9..c0bacb94aee 100644 --- a/tests/baselines/reference/exportAndImport-es5.js +++ b/tests/baselines/reference/exportAndImport-es5.js @@ -15,10 +15,12 @@ export default function f2() { //// [m1.js] function f1() { } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f1; //// [m2.js] var m1_1 = require("./m1"); function f2() { m1_1.default(); } +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f2; diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index dcd2d126a35..534a23b4d5b 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -36,6 +36,7 @@ define(["require", "exports"], function (require, exports) { }); //// [t2.js] define(["require", "exports"], function (require, exports) { + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; function foo() { } exports.foo = foo; diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index d219a3650e7..74cf24a0f97 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -33,6 +33,7 @@ foo; exports.x = 1; exports.y = 2; //// [t2.js] +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; function foo() { } exports.foo = foo; diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index db28ed5b350..e6a431854b2 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -41,6 +41,7 @@ export { a, b, c, d, e1, e2, f1, f2 }; //// [t1.js] define(["require", "exports"], function (require, exports) { + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; }); //// [t3.js] diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index ea5f34b882b..7358b31eace 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -40,6 +40,7 @@ export { a, b, c, d, e1, e2, f1, f2 }; //// [t1.js] +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] var a = require("./t1"); diff --git a/tests/baselines/reference/for-of11.errors.txt b/tests/baselines/reference/for-of11.errors.txt index dc527e73efe..7c00e454d4e 100644 --- a/tests/baselines/reference/for-of11.errors.txt +++ b/tests/baselines/reference/for-of11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of11.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of11.ts(2,6): error TS2322: Type 'number | string' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. @@ -6,5 +6,5 @@ tests/cases/conformance/es6/for-ofStatements/for-of11.ts(2,6): error TS2322: Typ var v: string; for (v of [0, ""]) { } ~ -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number | string' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of12.errors.txt b/tests/baselines/reference/for-of12.errors.txt index f19fa5ed014..6100564ba58 100644 --- a/tests/baselines/reference/for-of12.errors.txt +++ b/tests/baselines/reference/for-of12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of12.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of12.ts(2,6): error TS2322: Type 'number | string' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. @@ -6,5 +6,5 @@ tests/cases/conformance/es6/for-ofStatements/for-of12.ts(2,6): error TS2322: Typ var v: string; for (v of [0, ""].values()) { } ~ -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number | string' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 53ecb88363d..098afe94b47 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index f277821d696..4facd65bda7 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -324,7 +324,7 @@ class AnotherClass { private x } 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 => { // should be (x: number) => number | string if (x < 0) { return x; } return x.toString();} : (x: number) => number | string >x : number if (x < 0) { return x; } @@ -342,7 +342,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb 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 => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base | Derived2 >x : number return new Base(); @@ -356,7 +356,7 @@ var f8: (x: number) => any = x => { // should be (x: number) => Base 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 => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base | Derived | Derived2 >x : number return new Base(); diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index e8f434d31a8..06745d0d7aa 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2125,8 +2125,8 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >d2 : Derived2 var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : () => Base[] ->(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] +>x217 : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>(<() => Base[]>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2137,8 +2137,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : () => Base[] ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] +>x218 : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2150,8 +2150,8 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : () => Base[] ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] +>x219 : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2162,8 +2162,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : () => Base[] ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] +>x220 : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2175,8 +2175,8 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x221 = (undefined) || [d1, d2]; ->x221 : Base[] ->(undefined) || [d1, d2] : Base[] +>x221 : Base[] | (Derived1 | Derived2)[] +>(undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] >(undefined) : Base[] >undefined : Base[] >Base : Base @@ -2186,8 +2186,8 @@ var x221 = (undefined) || [d1, d2]; >d2 : Derived2 var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] ->(>undefined) || [d1, d2] : Base[] +>x222 : Base[] | (Derived1 | Derived2)[] +>(>undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] >(>undefined) : Base[] >>undefined : Base[] >Array : T[] @@ -2198,8 +2198,8 @@ var x222 = (>undefined) || [d1, d2]; >d2 : Derived2 var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } +>x223 : { [n: number]: Base; } | (Derived1 | Derived2)[] +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } | (Derived1 | Derived2)[] >(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } ><{ [n: number]: Base; }>undefined : { [n: number]: Base; } >n : number @@ -2210,8 +2210,8 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >d2 : Derived2 var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } +>x224 : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } >(<{n: Base[]; } >undefined) : { n: Base[]; } ><{n: Base[]; } >undefined : { n: Base[]; } >n : Base[] diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index c5fd984d327..5c7500fb5ed 100644 --- a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types +++ b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types @@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true, 1, null, 'yes'] : (string | number | boolean)[] +>[true, 1, null, 'yes'] : (boolean | number | string)[] >true : boolean >1 : number >null : null diff --git a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types index 48a7150ef44..c8e8b41b5fd 100644 --- a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types +++ b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types @@ -46,10 +46,10 @@ var r3 = foo([]); // number[] >[] : undefined[] var r4 = foo([1, '']); // {}[] ->r4 : (string | number)[] ->foo([1, '']) : (string | number)[] +>r4 : (number | string)[] +>foo([1, '']) : (number | string)[] >foo : (t: T) => T ->[1, ''] : (string | number)[] +>[1, ''] : (number | string)[] >1 : number >'' : string @@ -57,7 +57,7 @@ var r5 = foo([1, '']); // any[] >r5 : any[] >foo([1, '']) : any[] >foo : (t: T) => T ->[1, ''] : (string | number)[] +>[1, ''] : (number | string)[] >1 : number >'' : string @@ -66,7 +66,7 @@ var r6 = foo([1, '']); // Object[] >foo([1, '']) : Object[] >foo : (t: T) => T >Object : Object ->[1, ''] : (string | number)[] +>[1, ''] : (number | string)[] >1 : number >'' : string diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index 2d64c8f5c58..405c328bc45 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -42,12 +42,12 @@ declare var _: Underscore.Static; >Static : Underscore.Static var r = _.all([true, 1, null, 'yes'], _.identity); ->r : string | number | boolean ->_.all([true, 1, null, 'yes'], _.identity) : string | number | boolean +>r : boolean | number | string +>_.all([true, 1, null, 'yes'], _.identity) : boolean | number | string >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : (string | number | boolean)[] +>[true, 1, null, 'yes'] : (boolean | number | string)[] >true : boolean >1 : number >null : null diff --git a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt index e5c2be7a598..20e113faf2a 100644 --- a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt +++ b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'string[]'. - Type 'string | number' is not assignable to type 'string'. +tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'string[]'. + Type 'number | string' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. @@ -14,8 +14,8 @@ tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argu this.test([]); this.test([1, 2, "hi", 5]); // Error ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'string[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'string'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'string[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'string'. !!! error TS2345: Type 'number' is not assignable to type 'string'. } } \ No newline at end of file diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index ecfbf75e864..952200d74f8 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -2,8 +2,8 @@ // type of an array is the best common type of its elements (plus its contextual type if it exists) var a = [1, '']; // {}[] ->a : (string | number)[] ->[1, ''] : (string | number)[] +>a : (number | string)[] +>[1, ''] : (number | string)[] >1 : number >'' : string @@ -14,21 +14,21 @@ var b = [1, null]; // number[] >null : null var c = [1, '', null]; // {}[] ->c : (string | number)[] ->[1, '', null] : (string | number)[] +>c : (number | string)[] +>[1, '', null] : (number | string)[] >1 : number >'' : string >null : null var d = [{}, 1]; // {}[] ->d : {}[] ->[{}, 1] : {}[] +>d : ({} | number)[] +>[{}, 1] : ({} | number)[] >{} : {} >1 : number var e = [{}, Object]; // {}[] ->e : {}[] ->[{}, Object] : {}[] +>e : ({} | ObjectConstructor)[] +>[{}, Object] : ({} | ObjectConstructor)[] >{} : {} >Object : ObjectConstructor @@ -48,8 +48,8 @@ var g = [[1], ['']]; // {}[] >'' : string var h = [{ foo: 1, bar: '' }, { foo: 2 }]; // {foo: number}[] ->h : { foo: number; }[] ->[{ foo: 1, bar: '' }, { foo: 2 }] : { foo: number; }[] +>h : ({ foo: number; bar: string; } | { foo: number; })[] +>[{ foo: 1, bar: '' }, { foo: 2 }] : ({ foo: number; bar: string; } | { foo: number; })[] >{ foo: 1, bar: '' } : { foo: number; bar: string; } >foo : number >1 : number @@ -88,16 +88,16 @@ var k = [() => 1, () => 1]; // { (): number }[] >1 : number var l = [() => 1, () => null]; // { (): any }[] ->l : (() => any)[] ->[() => 1, () => null] : (() => any)[] +>l : ((() => number) | (() => any))[] +>[() => 1, () => null] : ((() => number) | (() => any))[] >() => 1 : () => number >1 : number >() => null : () => any >null : null var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : (() => any)[] ->[() => 1, () => '', () => null] : (() => any)[] +>m : ((() => number) | (() => string) | (() => any))[] +>[() => 1, () => '', () => null] : ((() => number) | (() => string) | (() => any))[] >() => 1 : () => number >1 : number >() => '' : () => string @@ -145,8 +145,8 @@ module Derived { >Derived : typeof Derived var h = [{ foo: base, basear: derived }, { foo: base }]; // {foo: Base}[] ->h : { foo: Base; }[] ->[{ foo: base, basear: derived }, { foo: base }] : { foo: Base; }[] +>h : ({ foo: Base; basear: Derived; } | { foo: Base; })[] +>[{ foo: base, basear: derived }, { foo: base }] : ({ foo: Base; basear: Derived; } | { foo: Base; })[] >{ foo: base, basear: derived } : { foo: Base; basear: Derived; } >foo : Base >base : Base @@ -169,8 +169,8 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : (() => Base)[] ->[() => base, () => derived] : (() => Base)[] +>j : ((() => Base) | (() => Derived))[] +>[() => base, () => derived] : ((() => Base) | (() => Derived))[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -185,16 +185,16 @@ module Derived { >1 : number var l = [() => base, () => null]; // { (): any }[] ->l : (() => any)[] ->[() => base, () => null] : (() => any)[] +>l : ((() => Base) | (() => any))[] +>[() => base, () => null] : ((() => Base) | (() => any))[] >() => base : () => Base >base : Base >() => null : () => any >null : null var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : (() => any)[] ->[() => base, () => derived, () => null] : (() => any)[] +>m : ((() => Base) | (() => Derived) | (() => any))[] +>[() => base, () => derived, () => null] : ((() => Base) | (() => Derived) | (() => any))[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -203,8 +203,8 @@ module Derived { >null : null var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : (() => Base)[][] ->[[() => base], [() => derived]] : (() => Base)[][] +>n : ((() => Base)[] | (() => Derived)[])[] +>[[() => base], [() => derived]] : ((() => Base)[] | (() => Derived)[])[] >[() => base] : (() => Base)[] >() => base : () => Base >base : Base @@ -219,8 +219,8 @@ module Derived { >derived2 : Derived2 var p = [derived, derived2, base]; // Base[] ->p : Base[] ->[derived, derived2, base] : Base[] +>p : (Derived | Derived2 | Base)[] +>[derived, derived2, base] : (Derived | Derived2 | Base)[] >derived : Derived >derived2 : Derived2 >base : Base @@ -296,8 +296,8 @@ function foo(t: T, u: U) { >u : U var d = [t, 1]; // {}[] ->d : (number | T)[] ->[t, 1] : (number | T)[] +>d : (T | number)[] +>[t, 1] : (T | number)[] >t : T >1 : number @@ -310,8 +310,8 @@ function foo(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : (() => any)[] ->[() => t, () => u, () => null] : (() => any)[] +>f : ((() => T) | (() => U) | (() => any))[] +>[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] >() => t : () => T >t : T >() => u : () => U @@ -350,8 +350,8 @@ function foo2(t: T, u: U) { >u : U var d = [t, 1]; // {}[] ->d : (number | T)[] ->[t, 1] : (number | T)[] +>d : (T | number)[] +>[t, 1] : (T | number)[] >t : T >1 : number @@ -364,8 +364,8 @@ function foo2(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : (() => any)[] ->[() => t, () => u, () => null] : (() => any)[] +>f : ((() => T) | (() => U) | (() => any))[] +>[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] >() => t : () => T >t : T >() => u : () => U @@ -374,26 +374,26 @@ function foo2(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : Base[] ->[t, base] : Base[] +>g : (T | Base)[] +>[t, base] : (T | Base)[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (Derived | T)[] ->[t, derived] : (Derived | T)[] +>h : (T | Derived)[] +>[t, derived] : (T | Derived)[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : Base[] ->[u, base] : Base[] +>i : (U | Base)[] +>[u, base] : (U | Base)[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : Derived[] ->[u, derived] : Derived[] +>j : (U | Derived)[] +>[u, derived] : (U | Derived)[] >u : U >derived : Derived } @@ -428,8 +428,8 @@ function foo3(t: T, u: U) { >u : U var d = [t, 1]; // {}[] ->d : (number | T)[] ->[t, 1] : (number | T)[] +>d : (T | number)[] +>[t, 1] : (T | number)[] >t : T >1 : number @@ -442,8 +442,8 @@ function foo3(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : (() => any)[] ->[() => t, () => u, () => null] : (() => any)[] +>f : ((() => T) | (() => U) | (() => any))[] +>[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] >() => t : () => T >t : T >() => u : () => U @@ -452,26 +452,26 @@ function foo3(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : Base[] ->[t, base] : Base[] +>g : (T | Base)[] +>[t, base] : (T | Base)[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : Derived[] ->[t, derived] : Derived[] +>h : (T | Derived)[] +>[t, derived] : (T | Derived)[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : Base[] ->[u, base] : Base[] +>i : (U | Base)[] +>[u, base] : (U | Base)[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : Derived[] ->[u, derived] : Derived[] +>j : (U | Derived)[] +>[u, derived] : (U | Derived)[] >u : U >derived : Derived } @@ -506,8 +506,8 @@ function foo4(t: T, u: U) { >u : U var d = [t, 1]; // {}[] ->d : (number | T)[] ->[t, 1] : (number | T)[] +>d : (T | number)[] +>[t, 1] : (T | number)[] >t : T >1 : number @@ -520,8 +520,8 @@ function foo4(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : (() => any)[] ->[() => t, () => u, () => null] : (() => any)[] +>f : ((() => T) | (() => U) | (() => any))[] +>[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] >() => t : () => T >t : T >() => u : () => U @@ -530,26 +530,26 @@ function foo4(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : Base[] ->[t, base] : Base[] +>g : (T | Base)[] +>[t, base] : (T | Base)[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (Derived | T)[] ->[t, derived] : (Derived | T)[] +>h : (T | Derived)[] +>[t, derived] : (T | Derived)[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : Base[] ->[u, base] : Base[] +>i : (U | Base)[] +>[u, base] : (U | Base)[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (Derived | U)[] ->[u, derived] : (Derived | U)[] +>j : (U | Derived)[] +>[u, derived] : (U | Derived)[] >u : U >derived : Derived diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index 504ff0088fa..e8763b0d54c 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -19,9 +19,9 @@ tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type Type '() => string' is not assignable to type '(s: string) => number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. - Property 'c' is missing in type '{ e: number; f: number; }'. + Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. - Property 'a' is missing in type '{ e: number; f: number; }'. + Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'. tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. @@ -103,7 +103,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => of1({ e: 0, f: 0 }); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. -!!! error TS2345: Property 'c' is missing in type '{ e: number; f: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. interface IMap { [key:string]:string; @@ -123,7 +123,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => var o1: { a: { a: string; }; b: string; } = { e: 0, f: 0 }; ~~ !!! error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. -!!! error TS2322: Property 'a' is missing in type '{ e: number; f: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. var a1 = [{ e: 0, f: 0 }, { e: 0, f: 0 }, { e: 0, g: 0 }]; diff --git a/tests/baselines/reference/indexerWithTuple.types b/tests/baselines/reference/indexerWithTuple.types index 4faae2cda29..7605fba0518 100644 --- a/tests/baselines/reference/indexerWithTuple.types +++ b/tests/baselines/reference/indexerWithTuple.types @@ -101,20 +101,20 @@ var eleUnion11 = unionTuple1[1]; // string | number >1 : number var eleUnion12 = unionTuple1[2]; // string | number ->eleUnion12 : string | number ->unionTuple1[2] : string | number +>eleUnion12 : number | string +>unionTuple1[2] : number | string >unionTuple1 : [number, string | number] >2 : number var eleUnion13 = unionTuple1[idx0]; // string | number ->eleUnion13 : string | number ->unionTuple1[idx0] : string | number +>eleUnion13 : number | string +>unionTuple1[idx0] : number | string >unionTuple1 : [number, string | number] >idx0 : number var eleUnion14 = unionTuple1[idx1]; // string | number ->eleUnion14 : string | number ->unionTuple1[idx1] : string | number +>eleUnion14 : number | string +>unionTuple1[idx1] : number | string >unionTuple1 : [number, string | number] >idx1 : number @@ -143,20 +143,20 @@ var eleUnion21 = unionTuple2[1]; // string | number >1 : number var eleUnion22 = unionTuple2[2]; // string | number | boolean ->eleUnion22 : string | number | boolean ->unionTuple2[2] : string | number | boolean +>eleUnion22 : boolean | string | number +>unionTuple2[2] : boolean | string | number >unionTuple2 : [boolean, string | number] >2 : number var eleUnion23 = unionTuple2[idx0]; // string | number | boolean ->eleUnion23 : string | number | boolean ->unionTuple2[idx0] : string | number | boolean +>eleUnion23 : boolean | string | number +>unionTuple2[idx0] : boolean | string | number >unionTuple2 : [boolean, string | number] >idx0 : number var eleUnion24 = unionTuple2[idx1]; // string | number | boolean ->eleUnion24 : string | number | boolean ->unionTuple2[idx1] : string | number | boolean +>eleUnion24 : boolean | string | number +>unionTuple2[idx1] : boolean | string | number >unionTuple2 : [boolean, string | number] >idx1 : number diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types index 7d0da8f4b06..9e0a4ceaea6 100644 --- a/tests/baselines/reference/inferentialTypingUsingApparentType3.types +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -49,10 +49,10 @@ class ObjectField }> { } var person = new ObjectField({ ->person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> ->new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> +>person : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> +>new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> >ObjectField : typeof ObjectField ->{ id: new NumberField(), name: new CharField()} : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>{ id: new NumberField(), name: new CharField()} : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } id: new NumberField(), >id : NumberField @@ -68,8 +68,8 @@ var person = new ObjectField({ person.fields.id; >person.fields.id : NumberField ->person.fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } ->person : ObjectField<{}, { [x: string]: CharField | NumberField; id: NumberField; name: CharField; }> ->fields : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } +>person.fields : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } +>person : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> +>fields : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } >id : NumberField diff --git a/tests/baselines/reference/innerModExport2.errors.txt b/tests/baselines/reference/innerModExport2.errors.txt index 52a9d01c997..f9568bb45a4 100644 --- a/tests/baselines/reference/innerModExport2.errors.txt +++ b/tests/baselines/reference/innerModExport2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/innerModExport2.ts(5,5): error TS2304: Cannot find name 'module'. tests/cases/compiler/innerModExport2.ts(5,12): error TS1005: ';' expected. -tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. -tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. +tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExportFunc' does not exist on type 'typeof Outer'. @@ -18,7 +18,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport var non_export_var = 0; export var export_var = 1; ~~~~~~~~~~ -!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. function NonExportFunc() { return 0; } @@ -26,7 +26,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport } var export_var: number; ~~~~~~~~~~ -!!! error TS2395: Individual declarations in merged declaration export_var must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. export var outer_var_export = 0; export function outerFuncExport() { return 0; } diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 3ec718f3b25..0c4b95214b0 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/isolatedModulesSourceMap.errors.txt b/tests/baselines/reference/isolatedModulesSourceMap.errors.txt deleted file mode 100644 index 6383e85ecd5..00000000000 --- a/tests/baselines/reference/isolatedModulesSourceMap.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'. - - -!!! error TS5043: Option 'sourceMap' cannot be specified with option 'isolatedModules'. -==== tests/cases/compiler/isolatedModulesSourceMap.ts (0 errors) ==== - - export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.js b/tests/baselines/reference/isolatedModulesSourceMap.js index ca6f4b4190e..2722a3ce7ab 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.js +++ b/tests/baselines/reference/isolatedModulesSourceMap.js @@ -1,7 +1,7 @@ //// [isolatedModulesSourceMap.ts] -export var x; +export var x = 1; //// [isolatedModulesSourceMap.js] -export var x; +export var x = 1; //# sourceMappingURL=isolatedModulesSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.js.map b/tests/baselines/reference/isolatedModulesSourceMap.js.map index 8e505dcda7a..9fa3e0da0d6 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.js.map +++ b/tests/baselines/reference/isolatedModulesSourceMap.js.map @@ -1,2 +1,2 @@ //// [isolatedModulesSourceMap.js.map] -{"version":3,"file":"isolatedModulesSourceMap.js","sourceRoot":"","sources":["isolatedModulesSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"isolatedModulesSourceMap.js","sourceRoot":"","sources":["isolatedModulesSourceMap.ts"],"names":[],"mappings":"AACA,WAAW,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt index 5c6b7659bc6..d31445505f7 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt +++ b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt @@ -8,20 +8,26 @@ sources: isolatedModulesSourceMap.ts emittedFile:tests/cases/compiler/isolatedModulesSourceMap.js sourceFile:isolatedModulesSourceMap.ts ------------------------------------------------------------------- ->>>export var x; +>>>export var x = 1; 1 > 2 >^^^^^^^^^^^ 3 > ^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >export var 3 > x -4 > ; +4 > = +5 > 1 +6 > ; 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(1, 12) Source(2, 12) + SourceIndex(0) 3 >Emitted(1, 13) Source(2, 13) + SourceIndex(0) -4 >Emitted(1, 14) Source(2, 14) + SourceIndex(0) +4 >Emitted(1, 16) Source(2, 16) + SourceIndex(0) +5 >Emitted(1, 17) Source(2, 17) + SourceIndex(0) +6 >Emitted(1, 18) Source(2, 18) + SourceIndex(0) --- >>>//# sourceMappingURL=isolatedModulesSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.symbols b/tests/baselines/reference/isolatedModulesSourceMap.symbols new file mode 100644 index 00000000000..d4ae3c34cf1 --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSourceMap.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/isolatedModulesSourceMap.ts === + +export var x = 1; +>x : Symbol(x, Decl(isolatedModulesSourceMap.ts, 1, 10)) + diff --git a/tests/baselines/reference/isolatedModulesSourceMap.types b/tests/baselines/reference/isolatedModulesSourceMap.types new file mode 100644 index 00000000000..1955fe5da6e --- /dev/null +++ b/tests/baselines/reference/isolatedModulesSourceMap.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/isolatedModulesSourceMap.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index fcc4bbc3d45..4307daa78b0 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts === new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo +>new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo >Foo : typeof Foo ->...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol ->[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] +>...[...new SymbolIterator, ...[...new StringIterator]] : symbol | string +>[...new SymbolIterator, ...[...new StringIterator]] : (symbol | string)[] >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index 2401a41cca8..631ad940554 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts === foo(...new SymbolIterator, ...new StringIterator); >foo(...new SymbolIterator, ...new StringIterator) : void ->foo : (...s: (string | symbol)[]) => void +>foo : (...s: (symbol | string)[]) => void >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator @@ -10,8 +10,8 @@ foo(...new SymbolIterator, ...new StringIterator); >StringIterator : typeof StringIterator function foo(...s: (symbol | string)[]) { } ->foo : (...s: (string | symbol)[]) => void ->s : (string | symbol)[] +>foo : (...s: (symbol | string)[]) => void +>s : (symbol | string)[] class SymbolIterator { >SymbolIterator : SymbolIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt index be085beb632..0a0da985ace 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. - Type 'string' is not assignable to type 'symbol'. +tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol | number'. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts (1 errors) ==== foo(...new SymbolIterator, ...new StringIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. -!!! error TS2345: Type 'string' is not assignable to type 'symbol'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol | number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. function foo(...s: (symbol | number)[]) { } class SymbolIterator { diff --git a/tests/baselines/reference/jsxImportInAttribute.js b/tests/baselines/reference/jsxImportInAttribute.js new file mode 100644 index 00000000000..40b21e87c3f --- /dev/null +++ b/tests/baselines/reference/jsxImportInAttribute.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/jsxImportInAttribute.tsx] //// + +//// [component.d.ts] + +declare module "Test" { + export default class Text { } +} + +//// [consumer.tsx] +/// +import Test from 'Test'; + +let x = Test; // emit test_1.default +; // ? + + +//// [consumer.jsx] +/// +var Test_1 = require('Test'); +var x = Test_1["default"]; // emit test_1.default +; // ? diff --git a/tests/baselines/reference/jsxImportInAttribute.symbols b/tests/baselines/reference/jsxImportInAttribute.symbols new file mode 100644 index 00000000000..8481771f085 --- /dev/null +++ b/tests/baselines/reference/jsxImportInAttribute.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/consumer.tsx === +/// +import Test from 'Test'; +>Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) + +let x = Test; // emit test_1.default +>x : Symbol(x, Decl(consumer.tsx, 3, 3)) +>Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) + +; // ? +>attr : Symbol(unknown) + +=== tests/cases/compiler/component.d.ts === + +declare module "Test" { + export default class Text { } +>Text : Symbol(Text, Decl(component.d.ts, 1, 23)) +} + diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types new file mode 100644 index 00000000000..8dfbe292fe0 --- /dev/null +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/consumer.tsx === +/// +import Test from 'Test'; +>Test : typeof Test + +let x = Test; // emit test_1.default +>x : typeof Test +>Test : typeof Test + +; // ? +> : any +>anything : any +>attr : any +>Test : any + +=== tests/cases/compiler/component.d.ts === + +declare module "Test" { + export default class Text { } +>Text : Text +} + diff --git a/tests/baselines/reference/jsxViaImport.errors.txt b/tests/baselines/reference/jsxViaImport.errors.txt new file mode 100644 index 00000000000..8fa22809a44 --- /dev/null +++ b/tests/baselines/reference/jsxViaImport.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/consumer.tsx(5,17): error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures. + + +==== tests/cases/compiler/consumer.tsx (1 errors) ==== + /// + import BaseComponent = require('BaseComponent'); + class TestComponent extends React.Component { + render() { + return ; + ~~~~~~~~~~~~~ +!!! error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures. + } + } + +==== tests/cases/compiler/component.d.ts (0 errors) ==== + + declare module JSX { + interface ElementAttributesProperty { props; } + } + declare module React { + class Component { } + } + declare module "BaseComponent" { + var base: React.Component; + export = base; + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsxViaImport.js b/tests/baselines/reference/jsxViaImport.js new file mode 100644 index 00000000000..6bf61af67f5 --- /dev/null +++ b/tests/baselines/reference/jsxViaImport.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/jsxViaImport.tsx] //// + +//// [component.d.ts] + +declare module JSX { + interface ElementAttributesProperty { props; } +} +declare module React { + class Component { } +} +declare module "BaseComponent" { + var base: React.Component; + export = base; +} + +//// [consumer.tsx] +/// +import BaseComponent = require('BaseComponent'); +class TestComponent extends React.Component { + render() { + return ; + } +} + + +//// [consumer.jsx] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +/// +var BaseComponent = require('BaseComponent'); +var TestComponent = (function (_super) { + __extends(TestComponent, _super); + function TestComponent() { + _super.apply(this, arguments); + } + TestComponent.prototype.render = function () { + return ; + }; + return TestComponent; +})(React.Component); diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt new file mode 100644 index 00000000000..bd210c55570 --- /dev/null +++ b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,5): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. + + +==== tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts (1 errors) ==== + // The || operator permits the operands to be of any type. + // If the || expression is contextually typed, the operands are contextually typed by the + // same type and the result is of the best common type of the contextual type and the two + // operand types. + + var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; + ~ +!!! error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. +!!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.symbols b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.symbols deleted file mode 100644 index 90fc4ac163c..00000000000 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts === -// The || operator permits the operands to be of any type. -// If the || expression is contextually typed, the operands are contextually typed by the -// same type and the result is of the best common type of the contextual type and the two -// operand types. - -var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; ->r : Symbol(r, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 3)) ->a : Symbol(a, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 8)) ->a : Symbol(a, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 24)) ->b : Symbol(b, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 31)) ->a : Symbol(a, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 45)) ->b : Symbol(b, Decl(logicalOrExpressionIsContextuallyTyped.ts, 5, 52)) - diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types deleted file mode 100644 index 52315226bb6..00000000000 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts === -// The || operator permits the operands to be of any type. -// If the || expression is contextually typed, the operands are contextually typed by the -// same type and the result is of the best common type of the contextual type and the two -// operand types. - -var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; ->r : { a: string; } ->a : string ->{ a: '', b: 123 } || { a: '', b: true } : { a: string; b: number; } | { a: string; b: boolean; } ->{ a: '', b: 123 } : { a: string; b: number; } ->a : string ->'' : string ->b : number ->123 : number ->{ a: '', b: true } : { a: string; b: boolean; } ->a : string ->'' : string ->b : boolean ->true : boolean - diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index ecf6b23e729..04bc188e308 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -121,26 +121,26 @@ var rb4 = a4 || a2; // string || boolean is string | boolean >a2 : boolean var rb5 = a5 || a2; // void || boolean is void | boolean ->rb5 : boolean | void ->a5 || a2 : boolean | void +>rb5 : void | boolean +>a5 || a2 : void | boolean >a5 : void >a2 : boolean var rb6 = a6 || a2; // enum || boolean is E | boolean ->rb6 : boolean | E ->a6 || a2 : boolean | E +>rb6 : E | boolean +>a6 || a2 : E | boolean >a6 : E >a2 : boolean var rb7 = a7 || a2; // object || boolean is object | boolean ->rb7 : boolean | { a: string; } ->a7 || a2 : boolean | { a: string; } +>rb7 : { a: string; } | boolean +>a7 || a2 : { a: string; } | boolean >a7 : { a: string; } >a2 : boolean var rb8 = a8 || a2; // array || boolean is array | boolean ->rb8 : boolean | string[] ->a8 || a2 : boolean | string[] +>rb8 : string[] | boolean +>a8 || a2 : string[] | boolean >a8 : string[] >a2 : boolean @@ -163,8 +163,8 @@ var rc1 = a1 || a3; // any || number is any >a3 : number var rc2 = a2 || a3; // boolean || number is boolean | number ->rc2 : number | boolean ->a2 || a3 : number | boolean +>rc2 : boolean | number +>a2 || a3 : boolean | number >a2 : boolean >a3 : number @@ -181,26 +181,26 @@ var rc4 = a4 || a3; // string || number is string | number >a3 : number var rc5 = a5 || a3; // void || number is void | number ->rc5 : number | void ->a5 || a3 : number | void +>rc5 : void | number +>a5 || a3 : void | number >a5 : void >a3 : number var rc6 = a6 || a3; // enum || number is number ->rc6 : number ->a6 || a3 : number +>rc6 : E | number +>a6 || a3 : E | number >a6 : E >a3 : number var rc7 = a7 || a3; // object || number is object | number ->rc7 : number | { a: string; } ->a7 || a3 : number | { a: string; } +>rc7 : { a: string; } | number +>a7 || a3 : { a: string; } | number >a7 : { a: string; } >a3 : number var rc8 = a8 || a3; // array || number is array | number ->rc8 : number | string[] ->a8 || a3 : number | string[] +>rc8 : string[] | number +>a8 || a3 : string[] | number >a8 : string[] >a3 : number @@ -223,14 +223,14 @@ var rd1 = a1 || a4; // any || string is any >a4 : string var rd2 = a2 || a4; // boolean || string is boolean | string ->rd2 : string | boolean ->a2 || a4 : string | boolean +>rd2 : boolean | string +>a2 || a4 : boolean | string >a2 : boolean >a4 : string var rd3 = a3 || a4; // number || string is number | string ->rd3 : string | number ->a3 || a4 : string | number +>rd3 : number | string +>a3 || a4 : number | string >a3 : number >a4 : string @@ -241,26 +241,26 @@ var rd4 = a4 || a4; // string || string is string >a4 : string var rd5 = a5 || a4; // void || string is void | string ->rd5 : string | void ->a5 || a4 : string | void +>rd5 : void | string +>a5 || a4 : void | string >a5 : void >a4 : string var rd6 = a6 || a4; // enum || string is enum | string ->rd6 : string | E ->a6 || a4 : string | E +>rd6 : E | string +>a6 || a4 : E | string >a6 : E >a4 : string var rd7 = a7 || a4; // object || string is object | string ->rd7 : string | { a: string; } ->a7 || a4 : string | { a: string; } +>rd7 : { a: string; } | string +>a7 || a4 : { a: string; } | string >a7 : { a: string; } >a4 : string var rd8 = a8 || a4; // array || string is array | string ->rd8 : string | string[] ->a8 || a4 : string | string[] +>rd8 : string[] | string +>a8 || a4 : string[] | string >a8 : string[] >a4 : string @@ -307,20 +307,20 @@ var re5 = a5 || a5; // void || void is void >a5 : void var re6 = a6 || a5; // enum || void is enum | void ->re6 : void | E ->a6 || a5 : void | E +>re6 : E | void +>a6 || a5 : E | void >a6 : E >a5 : void var re7 = a7 || a5; // object || void is object | void ->re7 : void | { a: string; } ->a7 || a5 : void | { a: string; } +>re7 : { a: string; } | void +>a7 || a5 : { a: string; } | void >a7 : { a: string; } >a5 : void var re8 = a8 || a5; // array || void is array | void ->re8 : void | string[] ->a8 || a5 : void | string[] +>re8 : string[] | void +>a8 || a5 : string[] | void >a8 : string[] >a5 : void @@ -349,8 +349,8 @@ var rg2 = a2 || a6; // boolean || enum is boolean | enum >a6 : E var rg3 = a3 || a6; // number || enum is number ->rg3 : number ->a3 || a6 : number +>rg3 : number | E +>a3 || a6 : number | E >a3 : number >a6 : E @@ -373,14 +373,14 @@ var rg6 = a6 || a6; // enum || enum is E >a6 : E var rg7 = a7 || a6; // object || enum is object | enum ->rg7 : E | { a: string; } ->a7 || a6 : E | { a: string; } +>rg7 : { a: string; } | E +>a7 || a6 : { a: string; } | E >a7 : { a: string; } >a6 : E var rg8 = a8 || a6; // array || enum is array | enum ->rg8 : E | string[] ->a8 || a6 : E | string[] +>rg8 : string[] | E +>a8 || a6 : string[] | E >a8 : string[] >a6 : E @@ -439,8 +439,8 @@ var rh7 = a7 || a7; // object || object is object >a7 : { a: string; } var rh8 = a8 || a7; // array || object is array | object ->rh8 : { a: string; } | string[] ->a8 || a7 : { a: string; } | string[] +>rh8 : string[] | { a: string; } +>a8 || a7 : string[] | { a: string; } >a8 : string[] >a7 : { a: string; } diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index f887ad7ae14..df8f6cac6db 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -107,8 +107,8 @@ function fn3u : U var r3 = t || { a: '' }; ->r3 : { a: string; } ->t || { a: '' } : { a: string; } +>r3 : T | { a: string; } +>t || { a: '' } : T | { a: string; } >t : T >{ a: '' } : { a: string; } >a : string diff --git a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt index 2fb7bd1bfbb..7445ab85a54 100644 --- a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt +++ b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt @@ -1,10 +1,11 @@ -tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. +tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(7,30): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (2 errors) ==== +==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (3 errors) ==== function map(xs: T[], f: (x: T) => U) { var ys: U[] = []; xs.forEach(x => ys.push(f(x))); @@ -12,12 +13,14 @@ tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): e } var r0 = map([1, ""], (x) => x.toString()); + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. var r5 = map([1, ""], (x) => x.toString()); var r6 = map([1, ""], (x) => x.toString()); var r7 = map([1, ""], (x) => x.toString()); // error ~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'number'. !!! error TS2345: Type 'string' is not assignable to type 'number'. var r7b = map([1, ""], (x) => x.toString()); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/multipleDefaultExports01.errors.txt b/tests/baselines/reference/multipleDefaultExports01.errors.txt new file mode 100644 index 00000000000..7b49afe1a4e --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports01.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/es6/modules/m1.ts(11,1): error TS2300: Duplicate identifier 'default'. +tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'? + + +==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== + + export default class foo { + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. + + } + + export default function bar() { + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. + + } + + var x = 10; + export default x; + ~~~~~~~~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'default'. + +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== + import Entity from "m1" + + Entity(); + ~~~~~~~~ +!!! error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'? \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js new file mode 100644 index 00000000000..e633cf69f55 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/es6/modules/multipleDefaultExports01.ts] //// + +//// [m1.ts] + +export default class foo { + +} + +export default function bar() { + +} + +var x = 10; +export default x; + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +//// [m1.js] +var foo = (function () { + function foo() { + } + return foo; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = foo; +function bar() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = bar; +var x = 10; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = x; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.errors.txt b/tests/baselines/reference/multipleDefaultExports02.errors.txt new file mode 100644 index 00000000000..51220ecfae2 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports02.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate function implementation. + + +==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== + + export default function foo() { + ~~~ +!!! error TS2393: Duplicate function implementation. + + } + + export default function bar() { + ~~~ +!!! error TS2393: Duplicate function implementation. + + } + +==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ==== + import Entity from "m1" + + Entity(); \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js new file mode 100644 index 00000000000..3d1b84ff6a6 --- /dev/null +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/es6/modules/multipleDefaultExports02.ts] //// + +//// [m1.ts] + +export default function foo() { + +} + +export default function bar() { + +} + +//// [m2.ts] +import Entity from "m1" + +Entity(); + +//// [m1.js] +function foo() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = foo; +function bar() { +} +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = bar; +//// [m2.js] +var m1_1 = require("m1"); +m1_1.default(); diff --git a/tests/baselines/reference/multivar.errors.txt b/tests/baselines/reference/multivar.errors.txt index 931e61de5ae..44061b9d74c 100644 --- a/tests/baselines/reference/multivar.errors.txt +++ b/tests/baselines/reference/multivar.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. -tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +tests/cases/compiler/multivar.ts(6,19): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. +tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. ==== tests/cases/compiler/multivar.ts (2 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in export var a, b2: number = 10, b; ~~ -!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. var m1; var a2, b22: number = 10, b222; var m3; @@ -28,7 +28,7 @@ tests/cases/compiler/multivar.ts(22,9): error TS2395: Individual declarations in declare var d1, d2; var b2; ~~ -!!! error TS2395: Individual declarations in merged declaration b2 must be all exported or all local. +!!! error TS2395: Individual declarations in merged declaration 'b2' must be all exported or all local. declare var v1; } diff --git a/tests/baselines/reference/narrowTypeByInstanceof.types b/tests/baselines/reference/narrowTypeByInstanceof.types index b98b1e4d234..e6a3466b88f 100644 --- a/tests/baselines/reference/narrowTypeByInstanceof.types +++ b/tests/baselines/reference/narrowTypeByInstanceof.types @@ -22,24 +22,24 @@ } type FileMatchOrMatch = FileMatch | Match; ->FileMatchOrMatch : Match | FileMatch +>FileMatchOrMatch : FileMatch | Match >FileMatch : FileMatch >Match : Match let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; ->elementA : Match | FileMatch ->FileMatchOrMatch : Match | FileMatch ->elementB : Match | FileMatch ->FileMatchOrMatch : Match | FileMatch +>elementA : FileMatch | Match +>FileMatchOrMatch : FileMatch | Match +>elementB : FileMatch | Match +>FileMatchOrMatch : FileMatch | Match if (elementA instanceof FileMatch && elementB instanceof FileMatch) { >elementA instanceof FileMatch && elementB instanceof FileMatch : boolean >elementA instanceof FileMatch : boolean ->elementA : Match | FileMatch +>elementA : FileMatch | Match >FileMatch : typeof FileMatch >elementB instanceof FileMatch : boolean ->elementB : Match | FileMatch +>elementB : FileMatch | Match >FileMatch : typeof FileMatch let a = elementA.resource().path; @@ -63,10 +63,10 @@ if (elementA instanceof FileMatch && elementB instanceof FileMatch) { } else if (elementA instanceof Match && elementB instanceof Match) { >elementA instanceof Match && elementB instanceof Match : boolean >elementA instanceof Match : boolean ->elementA : Match | FileMatch +>elementA : FileMatch | Match >Match : typeof Match >elementB instanceof Match : boolean ->elementB : Match | FileMatch +>elementB : FileMatch | Match >Match : typeof Match let a = elementA.range(); diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 7f73ac6da0a..71e164d5d62 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Index signatures are incompatible. - Type 'number | A' is not assignable to type 'A'. + Type 'A | B | number' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -54,9 +54,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'number | A' is not assignable to type 'A'. +!!! error TS2322: Type 'A | B | number' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), diff --git a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt index 0b218d3227b..465c4d6d9f6 100644 --- a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt +++ b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,5): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. - Property 'a' is missing in type '{ b: number; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. ==== tests/cases/compiler/objectLitStructuralTypeMismatch.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,5): error TS2322: Type var x: { a: number; } = { b: 5 }; ~ !!! error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. -!!! error TS2322: Property 'a' is missing in type '{ b: number; }'. \ No newline at end of file +!!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt index f031031b0a8..149aca43a42 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt @@ -1,5 +1,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. - Property 'value' is missing in type '{ hello: number; }'. + Object literal may only specify known properties, and 'hello' does not exist in type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. + Object literal may only specify known properties, and 'what' does not exist in type 'I'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(11,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. Property 'value' is missing in type '{ toString: (s: string) => string; }'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(12,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. @@ -7,7 +9,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(12,4): error TS tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error TS2339: Property 'uhhh' does not exist on type 'string'. -==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts (4 errors) ==== +==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts (5 errors) ==== interface I { value: string; toString: (t: string) => string; @@ -18,9 +20,12 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error T f2({ hello: 1 }) // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. -!!! error TS2345: Property 'value' is missing in type '{ hello: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I'. f2({ value: '' }) // missing toString satisfied by Object's member f2({ value: '', what: 1 }) // missing toString satisfied by Object's member + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. +!!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I'. f2({ toString: (s) => s }) // error, missing property value from ArgsString ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 7cb3304aa2f..367a676abc6 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. - Property 'value' is missing in type '{ hello: number; }'. + Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. Property 'doStuff' is missing in type '{ value: string; }'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. - Property 'doStuff' is missing in type '{ value: string; what: number; }'. + Object literal may only specify known properties, and 'what' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,4): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. Property 'value' is missing in type '{ toString: (s: any) => any; }'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'. @@ -23,7 +23,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T f2({ hello: 1 }) ~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Property 'value' is missing in type '{ hello: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. f2({ value: '' }) ~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. @@ -31,7 +31,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T f2({ value: '', what: 1 }) ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. -!!! error TS2345: Property 'doStuff' is missing in type '{ value: string; what: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index c35e49f02a3..edb6d031b1f 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. @@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index d5add00ebaf..55cec857c70 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,7 +31,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { [x: string]: A | B; [x: number]: B; 0: B; x: A; } >x : A >a : A >b : B diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index f12e29f5117..d00a8ddf074 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. - Property 'b' is missing in type '{ name: string; id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var person: { b: string; id: number } = { name, id }; // error ~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. -!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // error: can't use short-hand property assignment in type position ~~~~ !!! error TS1131: Property or signature expected. diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index 26b0224f2b0..f6f4f625c45 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. - Property 'b' is missing in type '{ name: string; id: number; }'. + Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. Type 'string' is not assignable to type 'number'. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var person: { b: string; id: number } = { name, id }; // error ~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. -!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error ~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. diff --git a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt index b7b9f437735..47401a7ae8b 100644 --- a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt +++ b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt @@ -1,7 +1,11 @@ +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. + Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. + Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. -==== tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts (1 errors) ==== +==== tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts (3 errors) ==== interface A { (x: { s: string }): string (x: { n: number }): number @@ -21,10 +25,16 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(22,5): error TS240 var v: B; v({ s: "", n: 0 }).toLowerCase(); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. var w: A; var w: C; ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. - w({ s: "", n: 0 }).toLowerCase(); \ No newline at end of file + w({ s: "", n: 0 }).toLowerCase(); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +!!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 61ec1a24ec5..1423901a28f 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -149,8 +149,8 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : number >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any ->Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any +>(Math.random() < 0.5 ? x => x : x => undefined) : ((x: number) => number) | ((x: number) => any) +>Math.random() < 0.5 ? x => x : x => undefined : ((x: number) => number) | ((x: number) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -169,8 +169,8 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) +>Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -191,8 +191,8 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) +>Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -216,9 +216,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : number >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : ((x: number) => number) | ((x: number) => any) +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : ((x: number) => number) | ((x: number) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index a055f2f1bbd..344933ea1fc 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/strictModeInConstructor.errors.txt b/tests/baselines/reference/strictModeInConstructor.errors.txt index 11ba2e26a68..9a80732842a 100644 --- a/tests/baselines/reference/strictModeInConstructor.errors.txt +++ b/tests/baselines/reference/strictModeInConstructor.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/strictModeInConstructor.ts(9,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/compiler/strictModeInConstructor.ts(27,5): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. -==== tests/cases/compiler/strictModeInConstructor.ts (2 errors) ==== +==== tests/cases/compiler/strictModeInConstructor.ts (1 errors) ==== class A { } @@ -12,14 +11,9 @@ tests/cases/compiler/strictModeInConstructor.ts(27,5): error TS2376: A 'super' c public s: number = 9; constructor () { - ~~~~~~~~~~~~~~~~ "use strict"; // No error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ super(); - ~~~~~~~~~~~~~~~~ } - ~~~~~ -!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. } class C extends A { diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e3dfd6133c9..e6cba35be25 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. - Type 'string | number | MyString | (() => void)' is not assignable to type 'string'. + Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number | MyString | (() => void)' is not assignable to type 'string'. +!!! error TS2322: Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index faef7905453..13d5adcf1f5 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. Index signatures are incompatible. - Type 'typeof A' is not assignable to type 'A'. - Property 'foo' is missing in type 'typeof A'. + Type 'typeof A | typeof B' is not assignable to type 'A'. + Type 'typeof A' is not assignable to type 'A'. + Property 'foo' is missing in type 'typeof A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -60,10 +61,11 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: A } = { ~ -!!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'typeof A'. +!!! error TS2322: Type 'typeof A | typeof B' is not assignable to type 'A'. +!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. +!!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, b: B } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfUnion.errors.txt b/tests/baselines/reference/subtypesOfUnion.errors.txt index fade5377814..7c2e88ec8fd 100644 --- a/tests/baselines/reference/subtypesOfUnion.errors.txt +++ b/tests/baselines/reference/subtypesOfUnion.errors.txt @@ -12,21 +12,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'E | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'E | number'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts (29 errors) ==== @@ -94,49 +94,49 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf foo: any; // ok foo2: string; // error ~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'E | number'. foo3: number; // ok foo4: boolean; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'E | number'. foo5: E; // ok foo6: Date; // error ~~~~~~~~~~~ -!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'E | number'. foo7: RegExp; // error ~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'E | number'. foo8: { bar: number }; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'E | number'. foo9: I8; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'E | number'. foo10: A; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'E | number'. foo11: A2; // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'E | number'. foo12: (x) => number; //error ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'E | number'. foo13: (x: T) => T; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'E | number'. foo14: typeof f; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'E | number'. foo15: typeof c; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'E | number'. foo16: T; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'E | number'. foo17: Object; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'E | number'. foo18: {}; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'E | number'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 8a56e05a9c2..e43382766ac 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -331,14 +331,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : ((x: T) => T[])[] ->[r1arg2, r1arg1] : ((x: T) => T[])[] +>r1a : (((x: number) => number[]) | ((x: T) => T[]))[] +>[r1arg2, r1arg1] : (((x: number) => number[]) | ((x: T) => T[]))[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : ((x: T) => T[])[] ->[r1arg1, r1arg2] : ((x: T) => T[])[] +>r1b : (((x: T) => T[]) | ((x: number) => number[]))[] +>[r1arg1, r1arg2] : (((x: T) => T[]) | ((x: number) => number[]))[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -365,14 +365,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : ((x: T) => string[])[] ->[r2arg1, r2arg2] : ((x: T) => string[])[] +>r2a : (((x: T) => string[]) | ((x: number) => string[]))[] +>[r2arg1, r2arg2] : (((x: T) => string[]) | ((x: number) => string[]))[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : ((x: T) => string[])[] ->[r2arg2, r2arg1] : ((x: T) => string[])[] +>r2b : (((x: number) => string[]) | ((x: T) => string[]))[] +>[r2arg2, r2arg1] : (((x: number) => string[]) | ((x: T) => string[]))[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -396,14 +396,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : ((x: T) => T)[] ->[r3arg1, r3arg2] : ((x: T) => T)[] +>r3a : (((x: T) => T) | ((x: number) => void))[] +>[r3arg1, r3arg2] : (((x: T) => T) | ((x: number) => void))[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : ((x: T) => T)[] ->[r3arg2, r3arg1] : ((x: T) => T)[] +>r3b : (((x: number) => void) | ((x: T) => T))[] +>[r3arg2, r3arg1] : (((x: number) => void) | ((x: T) => T))[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -432,14 +432,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : ((x: T, y: U) => T)[] ->[r4arg1, r4arg2] : ((x: T, y: U) => T)[] +>r4a : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] +>[r4arg1, r4arg2] : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : ((x: T, y: U) => T)[] ->[r4arg2, r4arg1] : ((x: T, y: U) => T)[] +>r4b : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] +>[r4arg2, r4arg1] : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((x: (arg: T) => U) => T)[] ->[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] +>r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((x: (arg: T) => U) => T)[] ->[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] +>r5b : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] +>[r5arg2, r5arg1] : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((x: (arg: T) => U) => T)[] ->[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] +>r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((x: (arg: T) => U) => T)[] ->[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] +>r6b : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] +>[r6arg2, r6arg1] : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((x: (arg: T) => U) => (r: T) => U)[] ->[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] +>r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((x: (arg: T) => U) => (r: T) => U)[] ->[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] +>r7b : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] +>[r7arg2, r7arg1] : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] ->[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] ->[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>r8b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] +>[r8arg2, r8arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] ->[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] ->[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>r9b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] +>[r9arg2, r9arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -719,14 +719,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : ((...x: T[]) => T)[] ->[r10arg1, r10arg2] : ((...x: T[]) => T)[] +>r10a : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] +>[r10arg1, r10arg2] : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : ((...x: T[]) => T)[] ->[r10arg2, r10arg1] : ((...x: T[]) => T)[] +>r10b : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] +>[r10arg2, r10arg1] : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -760,14 +760,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : ((x: T, y: T) => T)[] ->[r11arg1, r11arg2] : ((x: T, y: T) => T)[] +>r11a : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>[r11arg1, r11arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : ((x: T, y: T) => T)[] ->[r11arg2, r11arg1] : ((x: T, y: T) => T)[] +>r11b : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>[r11arg2, r11arg1] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -808,14 +808,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : ((x: Base[], y: T) => Derived[])[] ->[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] +>r12a : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>[r12arg1, r12arg2] : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : ((x: Base[], y: T) => Derived[])[] ->[r12arg2, r12arg1] : ((x: Base[], y: T) => Derived[])[] +>r12b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] +>[r12arg2, r12arg1] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -853,14 +853,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : ((x: Base[], y: T) => T)[] ->[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] +>r13a : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] +>[r13arg1, r13arg2] : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : ((x: Base[], y: T) => T)[] ->[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] +>r13b : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] +>[r13arg2, r13arg1] : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -894,14 +894,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((x: { a: T; b: T; }) => T)[] ->[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] +>r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((x: { a: T; b: T; }) => T)[] ->[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] +>r14b : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] +>[r14arg2, r14arg1] : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 379810b2541..0d3a84ac99c 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -219,8 +219,8 @@ module Errors { >null : null var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : ((x: T) => U[])[] ->[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] +>r1a : (((x: number) => string[]) | ((x: T) => U[]))[] +>[(x: number) => [''], (x: T) => null] : (((x: number) => string[]) | ((x: T) => U[]))[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -235,8 +235,8 @@ module Errors { >null : null var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : ((x: T) => U[])[] ->[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] +>r1b : (((x: T) => U[]) | ((x: number) => string[]))[] +>[(x: T) => null, (x: number) => ['']] : (((x: T) => U[]) | ((x: number) => string[]))[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : ((x: (arg: T) => U) => (r: T) => V)[] ->[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] +>r2a : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] +>[r2arg2, r2arg] : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : ((x: (arg: T) => U) => (r: T) => V)[] ->[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] +>r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -349,8 +349,8 @@ module Errors { >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3a = [r3arg2, r3arg]; ->r3a : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r3arg2, r3arg] : (((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r3a : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U))[] +>[r3arg2, r3arg] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U))[] >r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U @@ -387,14 +387,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : ((...x: T[]) => T)[] ->[r4arg2, r4arg] : ((...x: T[]) => T)[] +>r4a : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] +>[r4arg2, r4arg] : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : ((...x: T[]) => T)[] ->[r4arg, r4arg2] : ((...x: T[]) => T)[] +>r4b : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] +>[r4arg, r4arg2] : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -430,14 +430,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : ((x: T, y: T) => T)[] ->[r5arg2, r5arg] : ((x: T, y: T) => T)[] +>r5a : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>[r5arg2, r5arg] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : ((x: T, y: T) => T)[] ->[r5arg, r5arg2] : ((x: T, y: T) => T)[] +>r5b : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>[r5arg, r5arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -478,14 +478,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : ((x: Base[], y: Base[]) => T)[] ->[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] +>r6a : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>[r6arg2, r6arg] : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : ((x: Base[], y: Base[]) => T)[] ->[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] +>r6b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] +>[r6arg, r6arg2] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -517,14 +517,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : ((x: { a: T; b: T; }) => T)[] ->[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] +>r7a : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] +>[r7arg2, r7arg] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : ((x: { a: T; b: T; }) => T)[] ->[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] +>r7b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] +>[r7arg, r7arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -547,14 +547,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : ((x: { a: string; b: number; }) => number)[] ->[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] +>r7d : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] +>[r7arg2, r7arg3] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : ((x: { a: string; b: number; }) => number)[] ->[r7arg3, r7arg2] : ((x: { a: string; b: number; }) => number)[] +>r7e : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] +>[r7arg3, r7arg2] : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index e76d36114e9..830f065f556 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -317,14 +317,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : ((x: T) => T)[] ->[r3arg, r3arg2] : ((x: T) => T)[] +>r3a : (((x: T) => T) | ((x: T) => void))[] +>[r3arg, r3arg2] : (((x: T) => T) | ((x: T) => void))[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : ((x: T) => T)[] ->[r3arg2, r3arg] : ((x: T) => T)[] +>r3b : (((x: T) => void) | ((x: T) => T))[] +>[r3arg2, r3arg] : (((x: T) => void) | ((x: T) => T))[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((x: (arg: T) => U) => T)[] ->[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] +>r6a : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] +>[r6arg, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((x: (arg: T) => U) => T)[] ->[r6arg2, r6arg] : ((x: (arg: T) => U) => T)[] +>r6b : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] +>[r6arg2, r6arg] : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -498,14 +498,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>[r11arg, r11arg2] : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>[r11arg2, r11arg] : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -543,14 +543,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : ((x: { a: U; b: V; }) => U[])[] ->[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] +>r15a : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] +>[r15arg, r15arg2] : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : ((x: { a: U; b: V; }) => U[])[] ->[r15arg2, r15arg] : ((x: { a: U; b: V; }) => U[])[] +>r15b : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] +>[r15arg2, r15arg] : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index d723a367ecb..f00ad0332ca 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : (new (x: T) => T[])[] ->[r1arg2, r1arg1] : (new (x: T) => T[])[] +>r1a : ((new (x: number) => number[]) | (new (x: T) => T[]))[] +>[r1arg2, r1arg1] : ((new (x: number) => number[]) | (new (x: T) => T[]))[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : (new (x: T) => T[])[] ->[r1arg1, r1arg2] : (new (x: T) => T[])[] +>r1b : ((new (x: T) => T[]) | (new (x: number) => number[]))[] +>[r1arg1, r1arg2] : ((new (x: T) => T[]) | (new (x: number) => number[]))[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : (new (x: T) => string[])[] ->[r2arg1, r2arg2] : (new (x: T) => string[])[] +>r2a : ((new (x: T) => string[]) | (new (x: number) => string[]))[] +>[r2arg1, r2arg2] : ((new (x: T) => string[]) | (new (x: number) => string[]))[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : (new (x: T) => string[])[] ->[r2arg2, r2arg1] : (new (x: T) => string[])[] +>r2b : ((new (x: number) => string[]) | (new (x: T) => string[]))[] +>[r2arg2, r2arg1] : ((new (x: number) => string[]) | (new (x: T) => string[]))[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : (new (x: T) => T)[] ->[r3arg1, r3arg2] : (new (x: T) => T)[] +>r3a : ((new (x: T) => T) | (new (x: number) => void))[] +>[r3arg1, r3arg2] : ((new (x: T) => T) | (new (x: number) => void))[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : (new (x: T) => T)[] ->[r3arg2, r3arg1] : (new (x: T) => T)[] +>r3b : ((new (x: number) => void) | (new (x: T) => T))[] +>[r3arg2, r3arg1] : ((new (x: number) => void) | (new (x: T) => T))[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : (new (x: T, y: U) => T)[] ->[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] +>r4a : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] +>[r4arg1, r4arg2] : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : (new (x: T, y: U) => T)[] ->[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] +>r4b : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] +>[r4arg2, r4arg1] : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (new (x: new (arg: T) => U) => T)[] ->[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] +>r5a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] +>[r5arg1, r5arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (new (x: new (arg: T) => U) => T)[] ->[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] +>r5b : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] +>[r5arg2, r5arg1] : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (new (x: new (arg: T) => U) => T)[] ->[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] +>r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] +>[r6arg1, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (new (x: new (arg: T) => U) => T)[] ->[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] +>r6b : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] +>[r6arg2, r6arg1] : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] ->[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>r7a : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] +>[r7arg1, r7arg2] : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] ->[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>r7b : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] +>[r7arg2, r7arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] ->[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>r8a : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>[r8arg1, r8arg2] : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] ->[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>r8b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] +>[r8arg2, r8arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -636,8 +636,8 @@ var r9a = [r9arg1, r9arg2]; >r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r9arg2, r9arg1] : ((new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r9b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U))[] +>[r9arg2, r9arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U))[] >r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r9arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : (new (...x: T[]) => T)[] ->[r10arg1, r10arg2] : (new (...x: T[]) => T)[] +>r10a : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] +>[r10arg1, r10arg2] : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : (new (...x: T[]) => T)[] ->[r10arg2, r10arg1] : (new (...x: T[]) => T)[] +>r10b : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] +>[r10arg2, r10arg1] : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : (new (x: T, y: T) => T)[] ->[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] +>r11a : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>[r11arg1, r11arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : (new (x: T, y: T) => T)[] ->[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] +>r11b : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>[r11arg2, r11arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : (new (x: Base[], y: T) => Derived[])[] ->[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] +>r12a : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>[r12arg1, r12arg2] : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : (new (x: Base[], y: T) => Derived[])[] ->[r12arg2, r12arg1] : (new (x: Base[], y: T) => Derived[])[] +>r12b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] +>[r12arg2, r12arg1] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : (new (x: Base[], y: T) => T)[] ->[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] +>r13a : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] +>[r13arg1, r13arg2] : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : (new (x: Base[], y: T) => T)[] ->[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] +>r13b : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] +>[r13arg2, r13arg1] : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (new (x: { a: T; b: T; }) => T)[] ->[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] +>r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (new (x: { a: T; b: T; }) => T)[] ->[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] +>r14b : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] +>[r14arg2, r14arg1] : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index b0f0680c7a0..b7c90d8697e 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : (new (x: T) => U[])[] ->[r1arg2, r1arg1] : (new (x: T) => U[])[] +>r1a : ((new (x: number) => string[]) | (new (x: T) => U[]))[] +>[r1arg2, r1arg1] : ((new (x: number) => string[]) | (new (x: T) => U[]))[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : (new (x: T) => U[])[] ->[r1arg1, r1arg2] : (new (x: T) => U[])[] +>r1b : ((new (x: T) => U[]) | (new (x: number) => string[]))[] +>[r1arg1, r1arg2] : ((new (x: T) => U[]) | (new (x: number) => string[]))[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] ->[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>r2a : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] +>[r2arg2, r2arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] ->[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>r2b : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] +>[r2arg1, r2arg2] : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -318,8 +318,8 @@ module Errors { >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U var r3a = [r3arg2, r3arg1]; ->r3a : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r3arg2, r3arg1] : ((new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U) | (new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r3a : ((new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U))[] +>[r3arg2, r3arg1] : ((new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U))[] >r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : (new (...x: T[]) => T)[] ->[r4arg2, r4arg1] : (new (...x: T[]) => T)[] +>r4a : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] +>[r4arg2, r4arg1] : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : (new (...x: T[]) => T)[] ->[r4arg1, r4arg2] : (new (...x: T[]) => T)[] +>r4b : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] +>[r4arg1, r4arg2] : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : (new (x: T, y: T) => T)[] ->[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] +>r5a : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>[r5arg2, r5arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : (new (x: T, y: T) => T)[] ->[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] +>r5b : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>[r5arg1, r5arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : (new (x: Base[], y: Base[]) => T)[] ->[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] +>r6a : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>[r6arg2, r6arg1] : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : (new (x: Base[], y: Base[]) => T)[] ->[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] +>r6b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] +>[r6arg1, r6arg2] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : (new (x: { a: T; b: T; }) => T)[] ->[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] +>r7a : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] +>[r7arg2, r7arg1] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : (new (x: { a: T; b: T; }) => T)[] ->[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] +>r7b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] +>[r7arg1, r7arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : (new (x: { a: string; b: number; }) => number)[] ->[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] +>r7d : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] +>[r7arg2, r7arg3] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : (new (x: { a: string; b: number; }) => number)[] ->[r7arg3, r7arg2] : (new (x: { a: string; b: number; }) => number)[] +>r7e : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] +>[r7arg3, r7arg2] : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 21a40ecf7fc..328dadad41c 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : (new (x: T) => T)[] ->[r3arg, r3arg2] : (new (x: T) => T)[] +>r3a : ((new (x: T) => T) | (new (x: T) => void))[] +>[r3arg, r3arg2] : ((new (x: T) => T) | (new (x: T) => void))[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : (new (x: T) => T)[] ->[r3arg2, r3arg] : (new (x: T) => T)[] +>r3b : ((new (x: T) => void) | (new (x: T) => T))[] +>[r3arg2, r3arg] : ((new (x: T) => void) | (new (x: T) => T))[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : (new (x: new (arg: T) => U) => T)[] ->[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] +>r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] +>[r6arg, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : (new (x: new (arg: T) => U) => T)[] ->[r6arg2, r6arg] : (new (x: new (arg: T) => U) => T)[] +>r6b : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] +>[r6arg2, r6arg] : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>[r11arg, r11arg2] : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>[r11arg2, r11arg] : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : (new (x: { a: U; b: V; }) => U[])[] ->[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] +>r15a : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] +>[r15arg, r15arg2] : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : (new (x: { a: U; b: V; }) => U[])[] ->[r15arg2, r15arg] : (new (x: { a: U; b: V; }) => U[])[] +>r15b : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] +>[r15arg2, r15arg] : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 815f2d60740..0d55d78e266 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -85,8 +85,8 @@ var b = { Foo: null }; >null : null var r = true ? a : b; ->r : { Foo?: Base; } ->true ? a : b : { Foo?: Base; } +>r : { Foo?: Base; } | { Foo: Derived; } +>true ? a : b : { Foo?: Base; } | { Foo: Derived; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -156,8 +156,8 @@ module TwoLevels { >null : null var r = true ? a : b; ->r : { Foo?: Base; } ->true ? a : b : { Foo?: Base; } +>r : { Foo?: Base; } | { Foo: Derived2; } +>true ? a : b : { Foo?: Base; } | { Foo: Derived2; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived2; } diff --git a/tests/baselines/reference/switchStatements.errors.txt b/tests/baselines/reference/switchStatements.errors.txt new file mode 100644 index 00000000000..aa5b796e252 --- /dev/null +++ b/tests/baselines/reference/switchStatements.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. + Object literal may only specify known properties, and 'name' does not exist in type 'C'. + + +==== tests/cases/conformance/statements/switchStatements/switchStatements.ts (1 errors) ==== + module M { + export function fn(x: number) { + return ''; + } + } + + var x: any; + switch (x) { + case '': + case 12: + case true: + case null: + case undefined: + case new Date(12): + case new Object(): + case /[a-z]/: + case[]: + case {}: + case { id: 12 }: + case['a']: + case typeof x: + case typeof M: + case M.fn(1): + case (x: number) => '': + case ((x: number) => '')(2): + default: + } + + // basic assignable check, rest covered in tests for 'assignement compatibility' + class C { id: number; } + class D extends C { name: string } + + switch (new C()) { + case new D(): + case { id: 12, name: '' }: + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. +!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type 'C'. + case new C(): + } + + switch ('') { } + switch (12) { } + switch (true) { } + switch (null) { } + switch (undefined) { } + switch (new Date(12)) { } + switch (new Object()) { } + switch (/[a-z]/) { } + switch ([]) { } + switch ({}) { } + switch ({ id: 12 }) { } + switch (['a']) { } + switch ((x: number) => '') { } + switch (((x: T) => '')(1)) { } + + + \ No newline at end of file diff --git a/tests/baselines/reference/switchStatements.symbols b/tests/baselines/reference/switchStatements.symbols deleted file mode 100644 index fc8f076a12c..00000000000 --- a/tests/baselines/reference/switchStatements.symbols +++ /dev/null @@ -1,115 +0,0 @@ -=== tests/cases/conformance/statements/switchStatements/switchStatements.ts === -module M { ->M : Symbol(M, Decl(switchStatements.ts, 0, 0)) - - export function fn(x: number) { ->fn : Symbol(fn, Decl(switchStatements.ts, 0, 10)) ->x : Symbol(x, Decl(switchStatements.ts, 1, 23)) - - return ''; - } -} - -var x: any; ->x : Symbol(x, Decl(switchStatements.ts, 6, 3)) - -switch (x) { ->x : Symbol(x, Decl(switchStatements.ts, 6, 3)) - - case '': - case 12: - case true: - case null: - case undefined: ->undefined : Symbol(undefined) - - case new Date(12): ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) - - case new Object(): ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) - - case /[a-z]/: - case[]: - case {}: - case { id: 12 }: ->id : Symbol(id, Decl(switchStatements.ts, 18, 10)) - - case['a']: - case typeof x: ->x : Symbol(x, Decl(switchStatements.ts, 6, 3)) - - case typeof M: ->M : Symbol(M, Decl(switchStatements.ts, 0, 0)) - - case M.fn(1): ->M.fn : Symbol(M.fn, Decl(switchStatements.ts, 0, 10)) ->M : Symbol(M, Decl(switchStatements.ts, 0, 0)) ->fn : Symbol(M.fn, Decl(switchStatements.ts, 0, 10)) - - case (x: number) => '': ->T : Symbol(T, Decl(switchStatements.ts, 23, 10)) ->x : Symbol(x, Decl(switchStatements.ts, 23, 13)) - - case ((x: number) => '')(2): ->T : Symbol(T, Decl(switchStatements.ts, 24, 11)) ->x : Symbol(x, Decl(switchStatements.ts, 24, 14)) - - default: -} - -// basic assignable check, rest covered in tests for 'assignement compatibility' -class C { id: number; } ->C : Symbol(C, Decl(switchStatements.ts, 26, 1)) ->id : Symbol(id, Decl(switchStatements.ts, 29, 9)) - -class D extends C { name: string } ->D : Symbol(D, Decl(switchStatements.ts, 29, 23)) ->C : Symbol(C, Decl(switchStatements.ts, 26, 1)) ->name : Symbol(name, Decl(switchStatements.ts, 30, 19)) - -switch (new C()) { ->C : Symbol(C, Decl(switchStatements.ts, 26, 1)) - - case new D(): ->D : Symbol(D, Decl(switchStatements.ts, 29, 23)) - - case { id: 12, name: '' }: ->id : Symbol(id, Decl(switchStatements.ts, 34, 10)) ->name : Symbol(name, Decl(switchStatements.ts, 34, 18)) - - case new C(): ->C : Symbol(C, Decl(switchStatements.ts, 26, 1)) -} - -switch ('') { } -switch (12) { } -switch (true) { } -switch (null) { } -switch (undefined) { } ->undefined : Symbol(undefined) - -switch (new Date(12)) { } ->Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) - -switch (new Object()) { } ->Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) - -switch (/[a-z]/) { } -switch ([]) { } -switch ({}) { } -switch ({ id: 12 }) { } ->id : Symbol(id, Decl(switchStatements.ts, 48, 9)) - -switch (['a']) { } -switch ((x: number) => '') { } ->T : Symbol(T, Decl(switchStatements.ts, 50, 9)) ->x : Symbol(x, Decl(switchStatements.ts, 50, 12)) - -switch (((x: T) => '')(1)) { } ->T : Symbol(T, Decl(switchStatements.ts, 51, 10)) ->x : Symbol(x, Decl(switchStatements.ts, 51, 13)) ->T : Symbol(T, Decl(switchStatements.ts, 51, 10)) - - - diff --git a/tests/baselines/reference/switchStatements.types b/tests/baselines/reference/switchStatements.types deleted file mode 100644 index a5679547c12..00000000000 --- a/tests/baselines/reference/switchStatements.types +++ /dev/null @@ -1,184 +0,0 @@ -=== tests/cases/conformance/statements/switchStatements/switchStatements.ts === -module M { ->M : typeof M - - export function fn(x: number) { ->fn : (x: number) => string ->x : number - - return ''; ->'' : string - } -} - -var x: any; ->x : any - -switch (x) { ->x : any - - case '': ->'' : string - - case 12: ->12 : number - - case true: ->true : boolean - - case null: ->null : null - - case undefined: ->undefined : undefined - - case new Date(12): ->new Date(12) : Date ->Date : DateConstructor ->12 : number - - case new Object(): ->new Object() : Object ->Object : ObjectConstructor - - case /[a-z]/: ->/[a-z]/ : RegExp - - case[]: ->[] : undefined[] - - case {}: ->{} : {} - - case { id: 12 }: ->{ id: 12 } : { id: number; } ->id : number ->12 : number - - case['a']: ->['a'] : string[] ->'a' : string - - case typeof x: ->typeof x : string ->x : any - - case typeof M: ->typeof M : string ->M : typeof M - - case M.fn(1): ->M.fn(1) : string ->M.fn : (x: number) => string ->M : typeof M ->fn : (x: number) => string ->1 : number - - case (x: number) => '': ->(x: number) => '' : (x: number) => string ->T : T ->x : number ->'' : string - - case ((x: number) => '')(2): ->((x: number) => '')(2) : string ->((x: number) => '') : (x: number) => string ->(x: number) => '' : (x: number) => string ->T : T ->x : number ->'' : string ->2 : number - - default: -} - -// basic assignable check, rest covered in tests for 'assignement compatibility' -class C { id: number; } ->C : C ->id : number - -class D extends C { name: string } ->D : D ->C : C ->name : string - -switch (new C()) { ->new C() : C ->C : typeof C - - case new D(): ->new D() : D ->D : typeof D - - case { id: 12, name: '' }: ->{ id: 12, name: '' } : { id: number; name: string; } ->id : number ->12 : number ->name : string ->'' : string - - case new C(): ->new C() : C ->C : typeof C -} - -switch ('') { } ->'' : string - -switch (12) { } ->12 : number - -switch (true) { } ->true : boolean - -switch (null) { } ->null : null - -switch (undefined) { } ->undefined : undefined - -switch (new Date(12)) { } ->new Date(12) : Date ->Date : DateConstructor ->12 : number - -switch (new Object()) { } ->new Object() : Object ->Object : ObjectConstructor - -switch (/[a-z]/) { } ->/[a-z]/ : RegExp - -switch ([]) { } ->[] : undefined[] - -switch ({}) { } ->{} : {} - -switch ({ id: 12 }) { } ->{ id: 12 } : { id: number; } ->id : number ->12 : number - -switch (['a']) { } ->['a'] : string[] ->'a' : string - -switch ((x: number) => '') { } ->(x: number) => '' : (x: number) => string ->T : T ->x : number ->'' : string - -switch (((x: T) => '')(1)) { } ->((x: T) => '')(1) : string ->((x: T) => '') : (x: T) => string ->(x: T) => '' : (x: T) => string ->T : T ->x : T ->T : T ->'' : string ->1 : number - - - diff --git a/tests/baselines/reference/symbolProperty21.errors.txt b/tests/baselines/reference/symbolProperty21.errors.txt new file mode 100644 index 00000000000..b9162acc84f --- /dev/null +++ b/tests/baselines/reference/symbolProperty21.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. + Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. + + +==== tests/cases/conformance/es6/Symbols/symbolProperty21.ts (1 errors) ==== + interface I { + [Symbol.unscopables]: T; + [Symbol.isConcatSpreadable]: U; + } + + declare function foo(p: I): { t: T; u: U }; + + foo({ + ~ + [Symbol.isConcatSpreadable]: "", + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [Symbol.toPrimitive]: 0, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [Symbol.unscopables]: true + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }); + ~ +!!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols deleted file mode 100644 index 09997f687d5..00000000000 --- a/tests/baselines/reference/symbolProperty21.symbols +++ /dev/null @@ -1,51 +0,0 @@ -=== tests/cases/conformance/es6/Symbols/symbolProperty21.ts === -interface I { ->I : Symbol(I, Decl(symbolProperty21.ts, 0, 0)) ->T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) ->U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) - - [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->T : Symbol(T, Decl(symbolProperty21.ts, 0, 12)) - - [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) -} - -declare function foo(p: I): { t: T; u: U }; ->foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) ->T : Symbol(T, Decl(symbolProperty21.ts, 5, 21)) ->U : Symbol(U, Decl(symbolProperty21.ts, 5, 23)) ->p : Symbol(p, Decl(symbolProperty21.ts, 5, 27)) ->I : Symbol(I, Decl(symbolProperty21.ts, 0, 0)) ->T : Symbol(T, Decl(symbolProperty21.ts, 5, 21)) ->U : Symbol(U, Decl(symbolProperty21.ts, 5, 23)) ->t : Symbol(t, Decl(symbolProperty21.ts, 5, 41)) ->T : Symbol(T, Decl(symbolProperty21.ts, 5, 21)) ->u : Symbol(u, Decl(symbolProperty21.ts, 5, 47)) ->U : Symbol(U, Decl(symbolProperty21.ts, 5, 23)) - -foo({ ->foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) - - [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) - - [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) - - [Symbol.unscopables]: true ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) - -}); diff --git a/tests/baselines/reference/symbolProperty21.types b/tests/baselines/reference/symbolProperty21.types deleted file mode 100644 index e2cda0a896f..00000000000 --- a/tests/baselines/reference/symbolProperty21.types +++ /dev/null @@ -1,56 +0,0 @@ -=== tests/cases/conformance/es6/Symbols/symbolProperty21.ts === -interface I { ->I : I ->T : T ->U : U - - [Symbol.unscopables]: T; ->Symbol.unscopables : symbol ->Symbol : SymbolConstructor ->unscopables : symbol ->T : T - - [Symbol.isConcatSpreadable]: U; ->Symbol.isConcatSpreadable : symbol ->Symbol : SymbolConstructor ->isConcatSpreadable : symbol ->U : U -} - -declare function foo(p: I): { t: T; u: U }; ->foo : (p: I) => { t: T; u: U; } ->T : T ->U : U ->p : I ->I : I ->T : T ->U : U ->t : T ->T : T ->u : U ->U : U - -foo({ ->foo({ [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, [Symbol.unscopables]: true}) : { t: boolean; u: string; } ->foo : (p: I) => { t: T; u: U; } ->{ [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, [Symbol.unscopables]: true} : { [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; } - - [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : symbol ->Symbol : SymbolConstructor ->isConcatSpreadable : symbol ->"" : string - - [Symbol.toPrimitive]: 0, ->Symbol.toPrimitive : symbol ->Symbol : SymbolConstructor ->toPrimitive : symbol ->0 : number - - [Symbol.unscopables]: true ->Symbol.unscopables : symbol ->Symbol : SymbolConstructor ->unscopables : symbol ->true : boolean - -}); diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index 903c4ec0ecc..a7de59a11b7 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -28,12 +28,12 @@ s || s; >s : symbol s || 1; ->s || 1 : number | symbol +>s || 1 : symbol | number >s : symbol >1 : number ({}) || s; ->({}) || s : {} +>({}) || s : {} | symbol >({}) : {} >{} : {} >s : symbol diff --git a/tests/baselines/reference/systemModule11.js b/tests/baselines/reference/systemModule11.js index 55011214042..34dd0d3df5f 100644 --- a/tests/baselines/reference/systemModule11.js +++ b/tests/baselines/reference/systemModule11.js @@ -51,9 +51,11 @@ System.register(['bar'], function(exports_1) { 'foo': true }; function exportStar_1(m) { + var exports = {}; for(var n in m) { - if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]); + if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } + exports_1(exports); } return { setters:[ @@ -72,9 +74,11 @@ System.register(['bar'], function(exports_1) { 'y1': true }; function exportStar_1(m) { + var exports = {}; for(var n in m) { - if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]); + if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } + exports_1(exports); } return { setters:[ @@ -96,15 +100,19 @@ System.register(['a', 'bar'], function(exports_1) { 'z': true }; function exportStar_1(m) { + var exports = {}; for(var n in m) { - if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]); + if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } + exports_1(exports); } return { setters:[ function (_a_1) { - exports_1("x", _a_1["x"]); - exports_1("z", _a_1["y"]); + var reexports_1 = {}; + reexports_1["x"] = _a_1["x"]; + reexports_1["z"] = _a_1["y"]; + exports_1(reexports_1); }, function (_bar_1) { exportStar_1(_bar_1); @@ -123,8 +131,10 @@ System.register(['a'], function(exports_1) { return { setters:[ function (_a_1) { - exports_1("s", _a_1["s"]); - exports_1("s2", _a_1["s1"]); + var reexports_1 = {}; + reexports_1["s"] = _a_1["s"]; + reexports_1["s2"] = _a_1["s1"]; + exports_1(reexports_1); }], execute: function() { exports_1("z", z); @@ -136,9 +146,11 @@ System.register(['a'], function(exports_1) { System.register(['a'], function(exports_1) { function foo() { } function exportStar_1(m) { + var exports = {}; for(var n in m) { - if (n !== "default") exports_1(n, m[n]); + if (n !== "default") exports[n] = m[n]; } + exports_1(exports); } return { setters:[ diff --git a/tests/baselines/reference/systemModule9.js b/tests/baselines/reference/systemModule9.js index af05948c351..c282a47b686 100644 --- a/tests/baselines/reference/systemModule9.js +++ b/tests/baselines/reference/systemModule9.js @@ -30,9 +30,11 @@ System.register(['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7'], 'z': true }; function exportStar_1(m) { + var exports = {}; for(var n in m) { - if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]); + if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n]; } + exports_1(exports); } return { setters:[ diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index f3706ae8f17..6464366d33d 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. - Property 'z' is missing in type '{ x: number; y: string; }'. + Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (2 errors) ==== @@ -89,7 +89,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. -!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. +!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt index 1a4a1dc5aac..be8c517d39c 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. - Property 'z' is missing in type '{ x: number; y: string; }'. + Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts (2 errors) ==== @@ -88,7 +88,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. -!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. +!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/targetTypeTest2.types b/tests/baselines/reference/targetTypeTest2.types index 25b36f948c6..53381b9de43 100644 --- a/tests/baselines/reference/targetTypeTest2.types +++ b/tests/baselines/reference/targetTypeTest2.types @@ -4,7 +4,7 @@ var a : any[] = [1,2,"3"]; >a : any[] ->[1,2,"3"] : (string | number)[] +>[1,2,"3"] : (number | string)[] >1 : number >2 : number >"3" : string diff --git a/tests/baselines/reference/targetTypeTest3.errors.txt b/tests/baselines/reference/targetTypeTest3.errors.txt index f5dab732ed3..935a9b9e68e 100644 --- a/tests/baselines/reference/targetTypeTest3.errors.txt +++ b/tests/baselines/reference/targetTypeTest3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '(string | number)[]' is not assignable to type 'string[]'. - Type 'string | number' is not assignable to type 'string'. +tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '(number | string)[]' is not assignable to type 'string[]'. + Type 'number | string' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. @@ -9,8 +9,8 @@ tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '(string | numb var a : string[] = [1,2,"3"]; // should produce an error ~ -!!! 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 | string)[]' is not assignable to type 'string[]'. +!!! error TS2322: Type 'number | string' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/templateStringInArray.types b/tests/baselines/reference/templateStringInArray.types index 04cc09a1005..aec30c02e00 100644 --- a/tests/baselines/reference/templateStringInArray.types +++ b/tests/baselines/reference/templateStringInArray.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInArray.ts === var x = [1, 2, `abc${ 123 }def`]; ->x : (string | number)[] ->[1, 2, `abc${ 123 }def`] : (string | number)[] +>x : (number | string)[] +>[1, 2, `abc${ 123 }def`] : (number | string)[] >1 : number >2 : number >`abc${ 123 }def` : string diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditional.types b/tests/baselines/reference/templateStringWithEmbeddedConditional.types index 7ec1ef97a30..2a741dc271b 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedConditional.types +++ b/tests/baselines/reference/templateStringWithEmbeddedConditional.types @@ -2,7 +2,7 @@ var x = `abc${ true ? false : " " }def`; >x : string >`abc${ true ? false : " " }def` : string ->true ? false : " " : string | boolean +>true ? false : " " : boolean | string >true : boolean >false : boolean >" " : string diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types index 5453880ce16..d0a228ee673 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types @@ -2,7 +2,7 @@ var x = `abc${ true ? false : " " }def`; >x : string >`abc${ true ? false : " " }def` : string ->true ? false : " " : string | boolean +>true ? false : " " : boolean | string >true : boolean >false : boolean >" " : string diff --git a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt index b502eaad7e5..498e74ce350 100644 --- a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt +++ b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. +tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. +tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. @@ -13,13 +13,13 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS // these two should give the same error this.test([1, 2, "hi", 5, ]); ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'number'. !!! error TS2345: Type 'string' is not assignable to type 'number'. this.test([1, 2, "hi", 5]); ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. +!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'. +!!! error TS2345: Type 'number | string' is not assignable to type 'number'. !!! error TS2345: Type 'string' is not assignable to type 'number'. } } diff --git a/tests/baselines/reference/tsxAttributeResolution9.symbols b/tests/baselines/reference/tsxAttributeResolution9.symbols deleted file mode 100644 index 081482d5d47..00000000000 --- a/tests/baselines/reference/tsxAttributeResolution9.symbols +++ /dev/null @@ -1,47 +0,0 @@ -=== tests/cases/conformance/jsx/react.d.ts === - -declare module JSX { ->JSX : Symbol(JSX, Decl(react.d.ts, 0, 0)) - - interface Element { } ->Element : Symbol(Element, Decl(react.d.ts, 1, 20)) - - interface IntrinsicElements { ->IntrinsicElements : Symbol(IntrinsicElements, Decl(react.d.ts, 2, 22)) - } - interface ElementAttributesProperty { ->ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 4, 2)) - - props; ->props : Symbol(props, Decl(react.d.ts, 5, 38)) - } -} - -interface Props { ->Props : Symbol(Props, Decl(react.d.ts, 8, 1)) - - foo: string; ->foo : Symbol(foo, Decl(react.d.ts, 10, 17)) -} - -=== tests/cases/conformance/jsx/file.tsx === -export class MyComponent { ->MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) - - render() { ->render : Symbol(render, Decl(file.tsx, 0, 26)) - } - - props: { foo: string; } ->props : Symbol(props, Decl(file.tsx, 2, 3)) ->foo : Symbol(foo, Decl(file.tsx, 4, 10)) -} - -; // ok ->MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) ->foo : Symbol(unknown) - -; // should be an error ->MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0)) ->foo : Symbol(unknown) - diff --git a/tests/baselines/reference/tsxAttributeResolution9.types b/tests/baselines/reference/tsxAttributeResolution9.types deleted file mode 100644 index 1b2c6d42389..00000000000 --- a/tests/baselines/reference/tsxAttributeResolution9.types +++ /dev/null @@ -1,49 +0,0 @@ -=== tests/cases/conformance/jsx/react.d.ts === - -declare module JSX { ->JSX : any - - interface Element { } ->Element : Element - - interface IntrinsicElements { ->IntrinsicElements : IntrinsicElements - } - interface ElementAttributesProperty { ->ElementAttributesProperty : ElementAttributesProperty - - props; ->props : any - } -} - -interface Props { ->Props : Props - - foo: string; ->foo : string -} - -=== tests/cases/conformance/jsx/file.tsx === -export class MyComponent { ->MyComponent : MyComponent - - render() { ->render : () => void - } - - props: { foo: string; } ->props : { foo: string; } ->foo : string -} - -; // ok -> : JSX.Element ->MyComponent : typeof MyComponent ->foo : any - -; // should be an error -> : JSX.Element ->MyComponent : typeof MyComponent ->foo : any - diff --git a/tests/baselines/reference/tsxElementResolution8.errors.txt b/tests/baselines/reference/tsxElementResolution8.errors.txt index 5710c4e177d..92ff05d1aed 100644 --- a/tests/baselines/reference/tsxElementResolution8.errors.txt +++ b/tests/baselines/reference/tsxElementResolution8.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(8,2): error TS2604: JSX element type 'Div' does not have any construct or call signatures. -tests/cases/conformance/jsx/tsxElementResolution8.tsx(16,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution8.tsx(29,2): error TS2601: The return type of a JSX element constructor must return an object type. tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX element type 'Obj3' does not have any construct or call signatures. -==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (4 errors) ==== +==== tests/cases/conformance/jsx/tsxElementResolution8.tsx (2 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { } @@ -23,8 +21,6 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e // Error function Fnum(): number{ return 42; } - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. interface Obj1 { new(): {}; @@ -38,8 +34,6 @@ tests/cases/conformance/jsx/tsxElementResolution8.tsx(34,2): error TS2604: JSX e } var Obj2: Obj2; ; // Error - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. interface Obj3 { } diff --git a/tests/baselines/reference/tsxElementResolution9.errors.txt b/tests/baselines/reference/tsxElementResolution9.errors.txt deleted file mode 100644 index f4412719b33..00000000000 --- a/tests/baselines/reference/tsxElementResolution9.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/jsx/tsxElementResolution9.tsx(11,2): error TS2601: The return type of a JSX element constructor must return an object type. -tests/cases/conformance/jsx/tsxElementResolution9.tsx(18,2): error TS2601: The return type of a JSX element constructor must return an object type. - - -==== tests/cases/conformance/jsx/tsxElementResolution9.tsx (2 errors) ==== - declare module JSX { - interface Element { } - interface IntrinsicElements { } - } - - interface Obj1 { - new(n: string): { x: number }; - new(n: number): { y: string }; - } - var Obj1: Obj1; - ; // Error, return type is not an object type - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. - - interface Obj2 { - (n: string): { x: number }; - (n: number): { y: string }; - } - var Obj2: Obj2; - ; // Error, return type is not an object type - ~~~~ -!!! error TS2601: The return type of a JSX element constructor must return an object type. - - interface Obj3 { - (n: string): { x: number }; - (n: number): { x: number; y: string }; - } - var Obj3: Obj3; - ; // OK - \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution9.symbols b/tests/baselines/reference/tsxElementResolution9.symbols new file mode 100644 index 00000000000..bfa04219ef9 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.symbols @@ -0,0 +1,67 @@ +=== tests/cases/conformance/jsx/tsxElementResolution9.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxElementResolution9.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxElementResolution9.tsx, 0, 20)) + + interface IntrinsicElements { } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxElementResolution9.tsx, 1, 22)) +} + +interface Obj1 { +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + + new(n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 6, 5)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 6, 18)) + + new(n: number): { y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 7, 5)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 7, 18)) +} +var Obj1: Obj1; +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + +; // Error, return type is not an object type +>Obj1 : Symbol(Obj1, Decl(tsxElementResolution9.tsx, 3, 1), Decl(tsxElementResolution9.tsx, 9, 3)) + +interface Obj2 { +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + + (n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 13, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 13, 15)) + + (n: number): { y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 14, 2)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 14, 15)) +} +var Obj2: Obj2; +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + +; // Error, return type is not an object type +>Obj2 : Symbol(Obj2, Decl(tsxElementResolution9.tsx, 10, 9), Decl(tsxElementResolution9.tsx, 16, 3)) + +interface Obj3 { +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) + + (n: string): { x: number }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 20, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 20, 15)) + + (n: number): { x: number; y: string }; +>n : Symbol(n, Decl(tsxElementResolution9.tsx, 21, 2)) +>x : Symbol(x, Decl(tsxElementResolution9.tsx, 21, 15)) +>y : Symbol(y, Decl(tsxElementResolution9.tsx, 21, 26)) +} +var Obj3: Obj3; +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) + +; // OK +>Obj3 : Symbol(Obj3, Decl(tsxElementResolution9.tsx, 17, 9), Decl(tsxElementResolution9.tsx, 23, 3)) +>x : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types new file mode 100644 index 00000000000..525e4600b2e --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/jsx/tsxElementResolution9.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { } +>IntrinsicElements : IntrinsicElements +} + +interface Obj1 { +>Obj1 : Obj1 + + new(n: string): { x: number }; +>n : string +>x : number + + new(n: number): { y: string }; +>n : number +>y : string +} +var Obj1: Obj1; +>Obj1 : Obj1 +>Obj1 : Obj1 + +; // Error, return type is not an object type +> : JSX.Element +>Obj1 : Obj1 + +interface Obj2 { +>Obj2 : Obj2 + + (n: string): { x: number }; +>n : string +>x : number + + (n: number): { y: string }; +>n : number +>y : string +} +var Obj2: Obj2; +>Obj2 : Obj2 +>Obj2 : Obj2 + +; // Error, return type is not an object type +> : JSX.Element +>Obj2 : Obj2 + +interface Obj3 { +>Obj3 : Obj3 + + (n: string): { x: number }; +>n : string +>x : number + + (n: number): { x: number; y: string }; +>n : number +>x : number +>y : string +} +var Obj3: Obj3; +>Obj3 : Obj3 +>Obj3 : Obj3 + +; // OK +> : JSX.Element +>Obj3 : Obj3 +>x : any + diff --git a/tests/baselines/reference/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index d1257be13ef..8f418f98157 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -9,13 +9,14 @@ tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' tests/cases/compiler/tupleTypes.ts(41,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]'. tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => number'. - Type 'string | number' is not assignable to type 'number'. + Type '() => number | string' is not assignable to type '() => number'. + Type 'number | string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]'. Types of property 'pop' are incompatible. - Type '() => {}' is not assignable to type '() => number'. - Type '{}' is not assignable to type 'number'. + Type '() => number | {}' is not assignable to type '() => number'. + Type 'number | {}' is not assignable to type 'number'. + Type '{}' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(50,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. Types of property '1' are incompatible. Type 'number' is not assignable to type 'string'. @@ -89,16 +90,17 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n ~ !!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | string' is not assignable to type '() => number'. +!!! error TS2322: Type 'number | string' is not assignable to type 'number'. !!! error TS2322: Type 'string' is not assignable to type 'number'. a = a2; a = a3; // Error ~ !!! error TS2322: Type '[number, {}]' is not assignable to type 'number[]'. !!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => {}' is not assignable to type '() => number'. -!!! error TS2322: Type '{}' is not assignable to type 'number'. +!!! error TS2322: Type '() => number | {}' is not assignable to type '() => number'. +!!! error TS2322: Type 'number | {}' is not assignable to type 'number'. +!!! error TS2322: Type '{}' is not assignable to type 'number'. a1 = a2; // Error ~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. diff --git a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types index 45ddf8cd949..eb0fcdcbbca 100644 --- a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types +++ b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.types @@ -4,7 +4,7 @@ declare module m { // type alias declaration here shouldnt make the module declaration instantiated type Selector = string| string[] |Function; ->Selector : string | Function | string[] +>Selector : string | string[] | Function >Function : Function export interface IStatic { diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt index dd2e227f2ff..71d2a13f4a1 100644 --- a/tests/baselines/reference/typeArgInference2.errors.txt +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. - Property 'a' is missing in type '{ name: string; b: number; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. ==== tests/cases/compiler/typeArgInference2.ts (1 errors) ==== @@ -19,4 +19,4 @@ tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argumen ~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. -!!! error TS2453: Property 'a' is missing in type '{ name: string; b: number; }'. \ No newline at end of file +!!! error TS2453: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt index 126fe3d772f..669ebadd28a 100644 --- a/tests/baselines/reference/typeArgumentInference.errors.txt +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -2,10 +2,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11 Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. - Property 'z' is missing in type '{ x: number; y: string; }'. + Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. + Object literal may only specify known properties, and 'y' does not exist in type 'A92'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts (2 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts (3 errors) ==== // Generic call with no parameters function noParams() { } noParams(); @@ -94,9 +96,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11 ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. -!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. +!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; // Generic call with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index c82dab89e94..305eee1c941 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -14,12 +14,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. - Property 'z' is missing in type '{ x: number; y: string; }'. + Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. + Object literal may only specify known properties, and 'y' does not exist in type 'A92'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (10 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (11 errors) ==== // Generic call with no parameters interface NoParams { new (); @@ -164,13 +166,16 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. -!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. +!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; // Generic call with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 56370ac03d5..6b81cd6f232 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -19,12 +19,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. - Property 'z' is missing in type '{ x: number; y: string; }'. + Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,62): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. + Object literal may only specify known properties, and 'y' does not exist in type 'A92'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (15 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (16 errors) ==== // Generic call with no parameters function noParams() { } noParams(); @@ -146,13 +148,16 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. -!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. +!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; // Generic call with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/typeGuardFunction.types b/tests/baselines/reference/typeGuardFunction.types index 6cc278f122f..50a5fcaf324 100644 --- a/tests/baselines/reference/typeGuardFunction.types +++ b/tests/baselines/reference/typeGuardFunction.types @@ -216,7 +216,7 @@ acceptingTypeGuardFunction(isA); // Binary expressions let union2: C | B; ->union2 : B | C +>union2 : C | B >C : C >B : B @@ -226,6 +226,6 @@ let union3: boolean | B = isA(union2) || union2; >isA(union2) || union2 : boolean | B >isA(union2) : boolean >isA : (p1: any) => p1 is A ->union2 : B | C +>union2 : C | B >union2 : B diff --git a/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types b/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types index 6714ecf5570..10f50bed52e 100644 --- a/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types +++ b/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types @@ -26,7 +26,7 @@ var c: C; >C : C var cOrBool: C| boolean; ->cOrBool : boolean | C +>cOrBool : C | boolean >C : C var strOrNumOrBoolOrC: string | number | boolean | C; @@ -108,7 +108,7 @@ if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "numbe cOrBool = strOrNumOrBoolOrC; // C | boolean >cOrBool = strOrNumOrBoolOrC : boolean | C ->cOrBool : boolean | C +>cOrBool : C | boolean >strOrNumOrBoolOrC : boolean | C bool = strOrNumOrBool; // boolean diff --git a/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types b/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types index 2cad437ddeb..acd929a7ca1 100644 --- a/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types +++ b/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types @@ -26,7 +26,7 @@ var c: C; >C : C var cOrBool: C| boolean; ->cOrBool : boolean | C +>cOrBool : C | boolean >C : C var strOrNumOrBoolOrC: string | number | boolean | C; @@ -118,7 +118,7 @@ if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "numbe else { cOrBool = strOrNumOrBoolOrC; // C | boolean >cOrBool = strOrNumOrBoolOrC : boolean | C ->cOrBool : boolean | C +>cOrBool : C | boolean >strOrNumOrBoolOrC : boolean | C bool = strOrNumOrBool; // boolean diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.types b/tests/baselines/reference/typeGuardOfFormInstanceOf.types index 891e8c1bea2..c824e907733 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.types +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.types @@ -121,7 +121,7 @@ str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1 >p1 : string var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 ->r2 : C2 | D1 +>r2 : D1 | C2 >D1 : D1 >C2 : C2 >c2Ord1 instanceof C1 && c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types b/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types index fe23d6d303e..20d1c1644fc 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types +++ b/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types @@ -151,7 +151,7 @@ str = c2Ord1 instanceof d1 && c2Ord1.p1; // D1 >p1 : string var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1 ->r2 : C2 | D1 +>r2 : D1 | C2 >D1 : D1 >C2 : C2 >c2Ord1 instanceof c1 && c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardsDefeat.types b/tests/baselines/reference/typeGuardsDefeat.types index d3a017bd913..cc655d3ce0f 100644 --- a/tests/baselines/reference/typeGuardsDefeat.types +++ b/tests/baselines/reference/typeGuardsDefeat.types @@ -2,21 +2,21 @@ // Also note that it is possible to defeat a type guard by calling a function that changes the // type of the guarded variable. function foo(x: number | string) { ->foo : (x: string | number) => number ->x : string | number +>foo : (x: number | string) => number +>x : number | string function f() { >f : () => void x = 10; >x = 10 : number ->x : string | number +>x : number | string >10 : number } if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number +>x : number | string >"string" : string f(); @@ -35,13 +35,13 @@ function foo(x: number | string) { } } function foo2(x: number | string) { ->foo2 : (x: string | number) => number ->x : string | number +>foo2 : (x: number | string) => number +>x : number | string if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number +>x : number | string >"string" : string return x.length; // string @@ -63,7 +63,7 @@ function foo2(x: number | string) { } x = "hello"; >x = "hello" : string ->x : string | number +>x : number | string >"hello" : string f(); @@ -71,13 +71,13 @@ function foo2(x: number | string) { >f : () => number } function foo3(x: number | string) { ->foo3 : (x: string | number) => number ->x : string | number +>foo3 : (x: number | string) => number +>x : number | string if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number +>x : number | string >"string" : string return x.length; // string @@ -95,7 +95,7 @@ function foo3(x: number | string) { } x = "hello"; >x = "hello" : string ->x : string | number +>x : number | string >"hello" : string f(); diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt b/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt new file mode 100644 index 00000000000..37a662e007c --- /dev/null +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.errors.txt @@ -0,0 +1,103 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts(93,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts (1 errors) ==== + // In the true expression of a conditional expression, + // the type of a variable or parameter is narrowed by any type guard in the condition when true, + // provided the true expression contains no assignments to the variable or parameter. + // In the false expression of a conditional expression, + // the type of a variable or parameter is narrowed by any type guard in the condition when false, + // provided the false expression contains no assignments to the variable or parameter. + + function foo(x: number | string) { + return typeof x === "string" + ? x.length // string + : x++; // number + } + function foo2(x: number | string) { + // x is assigned in the if true branch, the type is not narrowed + return typeof x === "string" + ? (x = 10 && x)// string | number + : x; // string | number + } + function foo3(x: number | string) { + // x is assigned in the if false branch, the type is not narrowed + // even though assigned using same type as narrowed expression + return typeof x === "string" + ? (x = "Hello" && x) // string | number + : x; // string | number + } + function foo4(x: number | string) { + // false branch updates the variable - so here it is not number + // even though assigned using same type as narrowed expression + return typeof x === "string" + ? x // string | number + : (x = 10 && x); // string | number + } + function foo5(x: number | string) { + // false branch updates the variable - so here it is not number + return typeof x === "string" + ? x // string | number + : (x = "hello" && x); // string | number + } + function foo6(x: number | string) { + // Modify in both branches + return typeof x === "string" + ? (x = 10 && x) // string | number + : (x = "hello" && x); // string | number + } + function foo7(x: number | string | boolean) { + return typeof x === "string" + ? x === "hello" // string + : typeof x === "boolean" + ? x // boolean + : x == 10; // number + } + function foo8(x: number | string | boolean) { + var b: number | boolean; + return typeof x === "string" + ? x === "hello" + : ((b = x) && // number | boolean + (typeof x === "boolean" + ? x // boolean + : x == 10)); // number + } + function foo9(x: number | string) { + var y = 10; + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + return typeof x === "string" + ? ((y = x.length) && x === "hello") // string + : x === 10; // number + } + function foo10(x: number | string | boolean) { + // Mixing typeguards + var b: boolean | number; + return typeof x === "string" + ? x // string + : ((b = x) // x is number | boolean + && typeof x === "number" + && x.toString()); // x is number + } + function foo11(x: number | string | boolean) { + // Mixing typeguards + // Assigning value to x deep inside another guard stops narrowing of type too + var b: number | boolean | string; + return typeof x === "string" + ? x // number | boolean | string - changed in the false branch + : ((b = x) // x is number | boolean | string - because the assignment changed it + && typeof x === "number" + && (x = 10) // assignment to x + && x); // x is number | boolean | string + } + function foo12(x: number | string | boolean) { + // Mixing typeguards + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + var b: number | boolean | string; + return typeof x === "string" + ? (x = 10 && x.toString().length) // number | boolean | string - changed here + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + : ((b = x) // x is number | boolean | string - changed in true branch + && typeof x === "number" + && x); // x is number + } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.symbols b/tests/baselines/reference/typeGuardsInConditionalExpression.symbols deleted file mode 100644 index 2a7eb47523f..00000000000 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.symbols +++ /dev/null @@ -1,251 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts === -// In the true expression of a conditional expression, -// the type of a variable or parameter is narrowed by any type guard in the condition when true, -// provided the true expression contains no assignments to the variable or parameter. -// In the false expression of a conditional expression, -// the type of a variable or parameter is narrowed by any type guard in the condition when false, -// provided the false expression contains no assignments to the variable or parameter. - -function foo(x: number | string) { ->foo : Symbol(foo, Decl(typeGuardsInConditionalExpression.ts, 0, 0)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) - - ? x.length // string ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) - - : x++; // number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 7, 13)) -} -function foo2(x: number | string) { ->foo2 : Symbol(foo2, Decl(typeGuardsInConditionalExpression.ts, 11, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) - - // x is assigned in the if true branch, the type is not narrowed - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) - - ? (x = 10 && x)// string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) - - : x; // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 12, 14)) -} -function foo3(x: number | string) { ->foo3 : Symbol(foo3, Decl(typeGuardsInConditionalExpression.ts, 17, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) - - // x is assigned in the if false branch, the type is not narrowed - // even though assigned using same type as narrowed expression - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) - - ? (x = "Hello" && x) // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) - - : x; // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 18, 14)) -} -function foo4(x: number | string) { ->foo4 : Symbol(foo4, Decl(typeGuardsInConditionalExpression.ts, 24, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) - - // false branch updates the variable - so here it is not number - // even though assigned using same type as narrowed expression - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) - - ? x // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) - - : (x = 10 && x); // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 25, 14)) -} -function foo5(x: number | string) { ->foo5 : Symbol(foo5, Decl(typeGuardsInConditionalExpression.ts, 31, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) - - // false branch updates the variable - so here it is not number - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) - - ? x // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) - - : (x = "hello" && x); // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 32, 14)) -} -function foo6(x: number | string) { ->foo6 : Symbol(foo6, Decl(typeGuardsInConditionalExpression.ts, 37, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) - - // Modify in both branches - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) - - ? (x = 10 && x) // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) - - : (x = "hello" && x); // string | number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 38, 14)) -} -function foo7(x: number | string | boolean) { ->foo7 : Symbol(foo7, Decl(typeGuardsInConditionalExpression.ts, 43, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) - - ? x === "hello" // string ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) - - : typeof x === "boolean" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) - - ? x // boolean ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) - - : x == 10; // number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 44, 14)) -} -function foo8(x: number | string | boolean) { ->foo8 : Symbol(foo8, Decl(typeGuardsInConditionalExpression.ts, 50, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - var b: number | boolean; ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 52, 7)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - ? x === "hello" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - : ((b = x) && // number | boolean ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 52, 7)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - (typeof x === "boolean" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - ? x // boolean ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) - - : x == 10)); // number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 51, 14)) -} -function foo9(x: number | string) { ->foo9 : Symbol(foo9, Decl(typeGuardsInConditionalExpression.ts, 59, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) - - var y = 10; ->y : Symbol(y, Decl(typeGuardsInConditionalExpression.ts, 61, 7)) - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) - - ? ((y = x.length) && x === "hello") // string ->y : Symbol(y, Decl(typeGuardsInConditionalExpression.ts, 61, 7)) ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) - - : x === 10; // number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 60, 14)) -} -function foo10(x: number | string | boolean) { ->foo10 : Symbol(foo10, Decl(typeGuardsInConditionalExpression.ts, 66, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) - - // Mixing typeguards - var b: boolean | number; ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 69, 7)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) - - ? x // string ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) - - : ((b = x) // x is number | boolean ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 69, 7)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) - - && typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) - - && x.toString()); // x is number ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 67, 15)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) -} -function foo11(x: number | string | boolean) { ->foo11 : Symbol(foo11, Decl(typeGuardsInConditionalExpression.ts, 75, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - // Mixing typeguards - // Assigning value to x deep inside another guard stops narrowing of type too - var b: number | boolean | string; ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 79, 7)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - ? x // number | boolean | string - changed in the false branch ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - : ((b = x) // x is number | boolean | string - because the assignment changed it ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 79, 7)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - && typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - && (x = 10) // assignment to x ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) - - && x); // x is number | boolean | string ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 76, 15)) -} -function foo12(x: number | string | boolean) { ->foo12 : Symbol(foo12, Decl(typeGuardsInConditionalExpression.ts, 86, 1)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) - - // Mixing typeguards - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - var b: number | boolean | string; ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 90, 7)) - - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) - - ? (x = 10 && x.toString().length) // number | boolean | string - changed here ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) ->x.toString().length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) - - : ((b = x) // x is number | boolean | string - changed in true branch ->b : Symbol(b, Decl(typeGuardsInConditionalExpression.ts, 90, 7)) ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) - - && typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) - - && x); // x is number ->x : Symbol(x, Decl(typeGuardsInConditionalExpression.ts, 87, 15)) -} diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types deleted file mode 100644 index 3965abfe962..00000000000 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ /dev/null @@ -1,388 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts === -// In the true expression of a conditional expression, -// the type of a variable or parameter is narrowed by any type guard in the condition when true, -// provided the true expression contains no assignments to the variable or parameter. -// In the false expression of a conditional expression, -// the type of a variable or parameter is narrowed by any type guard in the condition when false, -// provided the false expression contains no assignments to the variable or parameter. - -function foo(x: number | string) { ->foo : (x: string | number) => number ->x : string | number - - return typeof x === "string" ->typeof x === "string" ? x.length // string : x++ : number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? x.length // string ->x.length : number ->x : string ->length : number - - : x++; // number ->x++ : number ->x : number -} -function foo2(x: number | string) { ->foo2 : (x: string | number) => string | number ->x : string | number - - // x is assigned in the if true branch, the type is not narrowed - return typeof x === "string" ->typeof x === "string" ? (x = 10 && x)// string | number : x : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? (x = 10 && x)// string | number ->(x = 10 && x) : string | number ->x = 10 && x : string | number ->x : string | number ->10 && x : string | number ->10 : number ->x : string | number - - : x; // string | number ->x : string | number -} -function foo3(x: number | string) { ->foo3 : (x: string | number) => string | number ->x : string | number - - // x is assigned in the if false branch, the type is not narrowed - // even though assigned using same type as narrowed expression - return typeof x === "string" ->typeof x === "string" ? (x = "Hello" && x) // string | number : x : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? (x = "Hello" && x) // string | number ->(x = "Hello" && x) : string | number ->x = "Hello" && x : string | number ->x : string | number ->"Hello" && x : string | number ->"Hello" : string ->x : string | number - - : x; // string | number ->x : string | number -} -function foo4(x: number | string) { ->foo4 : (x: string | number) => string | number ->x : string | number - - // false branch updates the variable - so here it is not number - // even though assigned using same type as narrowed expression - return typeof x === "string" ->typeof x === "string" ? x // string | number : (x = 10 && x) : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? x // string | number ->x : string | number - - : (x = 10 && x); // string | number ->(x = 10 && x) : string | number ->x = 10 && x : string | number ->x : string | number ->10 && x : string | number ->10 : number ->x : string | number -} -function foo5(x: number | string) { ->foo5 : (x: string | number) => string | number ->x : string | number - - // false branch updates the variable - so here it is not number - return typeof x === "string" ->typeof x === "string" ? x // string | number : (x = "hello" && x) : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? x // string | number ->x : string | number - - : (x = "hello" && x); // string | number ->(x = "hello" && x) : string | number ->x = "hello" && x : string | number ->x : string | number ->"hello" && x : string | number ->"hello" : string ->x : string | number -} -function foo6(x: number | string) { ->foo6 : (x: string | number) => string | number ->x : string | number - - // Modify in both branches - return typeof x === "string" ->typeof x === "string" ? (x = 10 && x) // string | number : (x = "hello" && x) : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? (x = 10 && x) // string | number ->(x = 10 && x) : string | number ->x = 10 && x : string | number ->x : string | number ->10 && x : string | number ->10 : number ->x : string | number - - : (x = "hello" && x); // string | number ->(x = "hello" && x) : string | number ->x = "hello" && x : string | number ->x : string | number ->"hello" && x : string | number ->"hello" : string ->x : string | number -} -function foo7(x: number | string | boolean) { ->foo7 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - return typeof x === "string" ->typeof x === "string" ? x === "hello" // string : typeof x === "boolean" ? x // boolean : x == 10 : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - ? x === "hello" // string ->x === "hello" : boolean ->x : string ->"hello" : string - - : typeof x === "boolean" ->typeof x === "boolean" ? x // boolean : x == 10 : boolean ->typeof x === "boolean" : boolean ->typeof x : string ->x : number | boolean ->"boolean" : string - - ? x // boolean ->x : boolean - - : x == 10; // number ->x == 10 : boolean ->x : number ->10 : number -} -function foo8(x: number | string | boolean) { ->foo8 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - var b: number | boolean; ->b : number | boolean - - return typeof x === "string" ->typeof x === "string" ? x === "hello" : ((b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10)) : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - ? x === "hello" ->x === "hello" : boolean ->x : string ->"hello" : string - - : ((b = x) && // number | boolean ->((b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10)) : boolean ->(b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10) : boolean ->(b = x) : number | boolean ->b = x : number | boolean ->b : number | boolean ->x : number | boolean - - (typeof x === "boolean" ->(typeof x === "boolean" ? x // boolean : x == 10) : boolean ->typeof x === "boolean" ? x // boolean : x == 10 : boolean ->typeof x === "boolean" : boolean ->typeof x : string ->x : number | boolean ->"boolean" : string - - ? x // boolean ->x : boolean - - : x == 10)); // number ->x == 10 : boolean ->x : number ->10 : number -} -function foo9(x: number | string) { ->foo9 : (x: string | number) => boolean ->x : string | number - - var y = 10; ->y : number ->10 : number - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - return typeof x === "string" ->typeof x === "string" ? ((y = x.length) && x === "hello") // string : x === 10 : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - ? ((y = x.length) && x === "hello") // string ->((y = x.length) && x === "hello") : boolean ->(y = x.length) && x === "hello" : boolean ->(y = x.length) : number ->y = x.length : number ->y : number ->x.length : number ->x : string ->length : number ->x === "hello" : boolean ->x : string ->"hello" : string - - : x === 10; // number ->x === 10 : boolean ->x : number ->10 : number -} -function foo10(x: number | string | boolean) { ->foo10 : (x: string | number | boolean) => string ->x : string | number | boolean - - // Mixing typeguards - var b: boolean | number; ->b : number | boolean - - return typeof x === "string" ->typeof x === "string" ? x // string : ((b = x) // x is number | boolean && typeof x === "number" && x.toString()) : string ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - ? x // string ->x : string - - : ((b = x) // x is number | boolean ->((b = x) // x is number | boolean && typeof x === "number" && x.toString()) : string ->(b = x) // x is number | boolean && typeof x === "number" && x.toString() : string ->(b = x) // x is number | boolean && typeof x === "number" : boolean ->(b = x) : number | boolean ->b = x : number | boolean ->b : number | boolean ->x : number | boolean - - && typeof x === "number" ->typeof x === "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - && x.toString()); // x is number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string -} -function foo11(x: number | string | boolean) { ->foo11 : (x: string | number | boolean) => string | number | boolean ->x : string | number | boolean - - // Mixing typeguards - // Assigning value to x deep inside another guard stops narrowing of type too - var b: number | boolean | string; ->b : string | number | boolean - - return typeof x === "string" ->typeof x === "string" ? x // number | boolean | string - changed in the false branch : ((b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x) : string | number | boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - ? x // number | boolean | string - changed in the false branch ->x : string | number | boolean - - : ((b = x) // x is number | boolean | string - because the assignment changed it ->((b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x) : string | number | boolean ->(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) // assignment to x && x : string | number | boolean ->(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" && (x = 10) : number ->(b = x) // x is number | boolean | string - because the assignment changed it && typeof x === "number" : boolean ->(b = x) : string | number | boolean ->b = x : string | number | boolean ->b : string | number | boolean ->x : string | number | boolean - - && typeof x === "number" ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - && (x = 10) // assignment to x ->(x = 10) : number ->x = 10 : number ->x : string | number | boolean ->10 : number - - && x); // x is number | boolean | string ->x : string | number | boolean -} -function foo12(x: number | string | boolean) { ->foo12 : (x: string | number | boolean) => number ->x : string | number | boolean - - // Mixing typeguards - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - var b: number | boolean | string; ->b : string | number | boolean - - return typeof x === "string" ->typeof x === "string" ? (x = 10 && x.toString().length) // number | boolean | string - changed here : ((b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x) : number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - ? (x = 10 && x.toString().length) // number | boolean | string - changed here ->(x = 10 && x.toString().length) : number ->x = 10 && x.toString().length : number ->x : string | number | boolean ->10 && x.toString().length : number ->10 : number ->x.toString().length : number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : string | number | boolean ->toString : (radix?: number) => string ->length : number - - : ((b = x) // x is number | boolean | string - changed in true branch ->((b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x) : number ->(b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" && x : number ->(b = x) // x is number | boolean | string - changed in true branch && typeof x === "number" : boolean ->(b = x) : string | number | boolean ->b = x : string | number | boolean ->b : string | number | boolean ->x : string | number | boolean - - && typeof x === "number" ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - && x); // x is number ->x : number -} diff --git a/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types b/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types index 600b2720404..0a084d6eb54 100644 --- a/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types +++ b/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types @@ -2,14 +2,14 @@ // typeguards are scoped in function/module block function foo(x: number | string | boolean) { ->foo : (x: string | number | boolean) => string ->x : string | number | boolean +>foo : (x: number | string | boolean) => string +>x : number | string | boolean return typeof x === "string" >typeof x === "string" ? x : function f() { var b = x; // number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } () : string >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string ? x @@ -46,14 +46,14 @@ function foo(x: number | string | boolean) { } (); } function foo2(x: number | string | boolean) { ->foo2 : (x: string | number | boolean) => string ->x : string | number | boolean +>foo2 : (x: number | string | boolean) => string +>x : number | string | boolean return typeof x === "string" >typeof x === "string" ? x : function f(a: number | boolean) { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } (x) : string >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string ? x @@ -92,14 +92,14 @@ function foo2(x: number | string | boolean) { >x : number | boolean } function foo3(x: number | string | boolean) { ->foo3 : (x: string | number | boolean) => string ->x : string | number | boolean +>foo3 : (x: number | string | boolean) => string +>x : number | string | boolean return typeof x === "string" >typeof x === "string" ? x : (() => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number })() : string >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string ? x @@ -136,14 +136,14 @@ function foo3(x: number | string | boolean) { })(); } function foo4(x: number | string | boolean) { ->foo4 : (x: string | number | boolean) => string ->x : string | number | boolean +>foo4 : (x: number | string | boolean) => string +>x : number | string | boolean return typeof x === "string" >typeof x === "string" ? x : ((a: number | boolean) => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number })(x) : string >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string ? x @@ -183,13 +183,13 @@ function foo4(x: number | string | boolean) { } // Type guards affect nested function expressions, but not nested function declarations function foo5(x: number | string | boolean) { ->foo5 : (x: string | number | boolean) => void ->x : string | number | boolean +>foo5 : (x: number | string | boolean) => void +>x : number | string | boolean if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string var y = x; // string; @@ -200,8 +200,8 @@ function foo5(x: number | string | boolean) { >foo : () => void var z = x; // number | string | boolean, type guard has no effect ->z : string | number | boolean ->x : string | number | boolean +>z : number | string | boolean +>x : number | string | boolean } } } @@ -209,14 +209,14 @@ module m { >m : typeof m var x: number | string | boolean; ->x : string | number | boolean +>x : number | string | boolean module m2 { >m2 : typeof m2 var b = x; // new scope - number | boolean | string ->b : string | number | boolean ->x : string | number | boolean +>b : number | string | boolean +>x : number | string | boolean var y: string; >y : string @@ -224,7 +224,7 @@ module m { if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string y = x // string; @@ -260,15 +260,15 @@ module m1 { >m1 : typeof m1 var x: number | string | boolean; ->x : string | number | boolean +>x : number | string | boolean module m2.m3 { >m2 : typeof m2 >m3 : typeof m3 var b = x; // new scope - number | boolean | string ->b : string | number | boolean ->x : string | number | boolean +>b : number | string | boolean +>x : number | string | boolean var y: string; >y : string @@ -276,7 +276,7 @@ module m1 { if (typeof x === "string") { >typeof x === "string" : boolean >typeof x : string ->x : string | number | boolean +>x : number | string | boolean >"string" : string y = x // string; diff --git a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt new file mode 100644 index 00000000000..e675daffd6e --- /dev/null +++ b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt @@ -0,0 +1,160 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(127,23): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(131,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,16): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (3 errors) ==== + // In the true branch statement of an �if� statement, + // the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, + // provided the true branch statement contains no assignments to the variable or parameter. + // In the false branch statement of an �if� statement, + // the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, + // provided the false branch statement contains no assignments to the variable or parameter + function foo(x: number | string) { + if (typeof x === "string") { + return x.length; // string + } + else { + return x++; // number + } + } + function foo2(x: number | string) { + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { + x = 10; + return x; // string | number + } + else { + return x; // string | number + } + } + function foo3(x: number | string) { + // x is assigned in the if true branch, the type is not narrowed + if (typeof x === "string") { + x = "Hello"; // even though assigned using same type as narrowed expression + return x; // string | number + } + else { + return x; // string | number + } + } + function foo4(x: number | string) { + // false branch updates the variable - so here it is not number + if (typeof x === "string") { + return x; // string | number + } + else { + x = 10; // even though assigned number - this should result in x to be string | number + return x; // string | number + } + } + function foo5(x: number | string) { + // false branch updates the variable - so here it is not number + if (typeof x === "string") { + return x; // string | number + } + else { + x = "hello"; + return x; // string | number + } + } + function foo6(x: number | string) { + // Modify in both branches + if (typeof x === "string") { + x = 10; + return x; // string | number + } + else { + x = "hello"; + return x; // string | number + } + } + function foo7(x: number | string | boolean) { + if (typeof x === "string") { + return x === "hello"; // string + } + else if (typeof x === "boolean") { + return x; // boolean + } + else { + return x == 10; // number + } + } + function foo8(x: number | string | boolean) { + if (typeof x === "string") { + return x === "hello"; // string + } + else { + var b: number | boolean = x; // number | boolean + if (typeof x === "boolean") { + return x; // boolean + } + else { + return x == 10; // number + } + } + } + function foo9(x: number | string) { + var y = 10; + if (typeof x === "string") { + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + y = x.length; + return x === "hello"; // string + } + else { + return x == 10; // number + } + } + function foo10(x: number | string | boolean) { + // Mixing typeguard narrowing in if statement with conditional expression typeguard + if (typeof x === "string") { + return x === "hello"; // string + } + else { + var y: boolean | string; + var b = x; // number | boolean + return typeof x === "number" + ? x === 10 // number + : x; // x should be boolean + } + } + function foo11(x: number | string | boolean) { + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x deep inside another guard stops narrowing of type too + if (typeof x === "string") { + return x; // string | number | boolean - x changed in else branch + } + else { + var y: number| boolean | string; + var b = x; // number | boolean | string - because below we are changing value of x in if statement + return typeof x === "number" + ? ( + // change value of x + x = 10 && x.toString() // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + ) + : ( + // do not change value + y = x && x.toString() // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + ); + } + } + function foo12(x: number | string | boolean) { + // Mixing typeguard narrowing in if statement with conditional expression typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + if (typeof x === "string") { + return x.toString(); // string | number | boolean - x changed in else branch + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + } + else { + x = 10; + var b = x; // number | boolean | string + return typeof x === "number" + ? x.toString() // number + : x.toString(); // boolean | string + } + } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInIfStatement.symbols b/tests/baselines/reference/typeGuardsInIfStatement.symbols deleted file mode 100644 index d81be08d1a0..00000000000 --- a/tests/baselines/reference/typeGuardsInIfStatement.symbols +++ /dev/null @@ -1,304 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, -// provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, -// provided the false branch statement contains no assignments to the variable or parameter -function foo(x: number | string) { ->foo : Symbol(foo, Decl(typeGuardsInIfStatement.ts, 0, 0)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) - - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) - - return x.length; // string ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) - } - else { - return x++; // number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 6, 13)) - } -} -function foo2(x: number | string) { ->foo2 : Symbol(foo2, Decl(typeGuardsInIfStatement.ts, 13, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) - - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) - - x = 10; ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) - } - else { - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 14, 14)) - } -} -function foo3(x: number | string) { ->foo3 : Symbol(foo3, Decl(typeGuardsInIfStatement.ts, 23, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) - - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) - - x = "Hello"; // even though assigned using same type as narrowed expression ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) - } - else { - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 24, 14)) - } -} -function foo4(x: number | string) { ->foo4 : Symbol(foo4, Decl(typeGuardsInIfStatement.ts, 33, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) - - // false branch updates the variable - so here it is not number - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) - } - else { - x = 10; // even though assigned number - this should result in x to be string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 34, 14)) - } -} -function foo5(x: number | string) { ->foo5 : Symbol(foo5, Decl(typeGuardsInIfStatement.ts, 43, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) - - // false branch updates the variable - so here it is not number - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) - } - else { - x = "hello"; ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 44, 14)) - } -} -function foo6(x: number | string) { ->foo6 : Symbol(foo6, Decl(typeGuardsInIfStatement.ts, 53, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - - // Modify in both branches - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - - x = 10; ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - } - else { - x = "hello"; ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - - return x; // string | number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 54, 14)) - } -} -function foo7(x: number | string | boolean) { ->foo7 : Symbol(foo7, Decl(typeGuardsInIfStatement.ts, 64, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - - return x === "hello"; // string ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - } - else if (typeof x === "boolean") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - - return x; // boolean ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - } - else { - return x == 10; // number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 65, 14)) - } -} -function foo8(x: number | string | boolean) { ->foo8 : Symbol(foo8, Decl(typeGuardsInIfStatement.ts, 75, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - - return x === "hello"; // string ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - } - else { - var b: number | boolean = x; // number | boolean ->b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 81, 11)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - - if (typeof x === "boolean") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - - return x; // boolean ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - } - else { - return x == 10; // number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 76, 14)) - } - } -} -function foo9(x: number | string) { ->foo9 : Symbol(foo9, Decl(typeGuardsInIfStatement.ts, 89, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) - - var y = 10; ->y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 91, 7)) - - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - y = x.length; ->y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 91, 7)) ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) - - return x === "hello"; // string ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) - } - else { - return x == 10; // number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 90, 14)) - } -} -function foo10(x: number | string | boolean) { ->foo10 : Symbol(foo10, Decl(typeGuardsInIfStatement.ts, 100, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - - return x === "hello"; // string ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - } - else { - var y: boolean | string; ->y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 107, 11)) - - var b = x; // number | boolean ->b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 108, 11)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - - return typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - - ? x === 10 // number ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - - : x; // x should be boolean ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 101, 15)) - } -} -function foo11(x: number | string | boolean) { ->foo11 : Symbol(foo11, Decl(typeGuardsInIfStatement.ts, 113, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x deep inside another guard stops narrowing of type too - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) - - return x; // string | number | boolean - x changed in else branch ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) - } - else { - var y: number| boolean | string; ->y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 121, 11)) - - var b = x; // number | boolean | string - because below we are changing value of x in if statement ->b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 122, 11)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) - - return typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) - - ? ( - // change value of x - x = 10 && x.toString() // number | boolean | string ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) - - ) - : ( - // do not change value - y = x && x.toString() // number | boolean | string ->y : Symbol(y, Decl(typeGuardsInIfStatement.ts, 121, 11)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 114, 15)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) - - ); - } -} -function foo12(x: number | string | boolean) { ->foo12 : Symbol(foo12, Decl(typeGuardsInIfStatement.ts, 133, 1)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - if (typeof x === "string") { ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) - - return x.toString(); // string | number | boolean - x changed in else branch ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) - } - else { - x = 10; ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) - - var b = x; // number | boolean | string ->b : Symbol(b, Decl(typeGuardsInIfStatement.ts, 142, 11)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) - - return typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) - - ? x.toString() // number ->x.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) ->toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) - - : x.toString(); // boolean | string ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInIfStatement.ts, 134, 15)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 96, 26)) - } -} diff --git a/tests/baselines/reference/typeGuardsInIfStatement.types b/tests/baselines/reference/typeGuardsInIfStatement.types deleted file mode 100644 index 59a9ff512af..00000000000 --- a/tests/baselines/reference/typeGuardsInIfStatement.types +++ /dev/null @@ -1,405 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, -// provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, -// provided the false branch statement contains no assignments to the variable or parameter -function foo(x: number | string) { ->foo : (x: string | number) => number ->x : string | number - - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - return x.length; // string ->x.length : number ->x : string ->length : number - } - else { - return x++; // number ->x++ : number ->x : number - } -} -function foo2(x: number | string) { ->foo2 : (x: string | number) => string | number ->x : string | number - - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - x = 10; ->x = 10 : number ->x : string | number ->10 : number - - return x; // string | number ->x : string | number - } - else { - return x; // string | number ->x : string | number - } -} -function foo3(x: number | string) { ->foo3 : (x: string | number) => string | number ->x : string | number - - // x is assigned in the if true branch, the type is not narrowed - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - x = "Hello"; // even though assigned using same type as narrowed expression ->x = "Hello" : string ->x : string | number ->"Hello" : string - - return x; // string | number ->x : string | number - } - else { - return x; // string | number ->x : string | number - } -} -function foo4(x: number | string) { ->foo4 : (x: string | number) => string | number ->x : string | number - - // false branch updates the variable - so here it is not number - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - return x; // string | number ->x : string | number - } - else { - x = 10; // even though assigned number - this should result in x to be string | number ->x = 10 : number ->x : string | number ->10 : number - - return x; // string | number ->x : string | number - } -} -function foo5(x: number | string) { ->foo5 : (x: string | number) => string | number ->x : string | number - - // false branch updates the variable - so here it is not number - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - return x; // string | number ->x : string | number - } - else { - x = "hello"; ->x = "hello" : string ->x : string | number ->"hello" : string - - return x; // string | number ->x : string | number - } -} -function foo6(x: number | string) { ->foo6 : (x: string | number) => string | number ->x : string | number - - // Modify in both branches - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - x = 10; ->x = 10 : number ->x : string | number ->10 : number - - return x; // string | number ->x : string | number - } - else { - x = "hello"; ->x = "hello" : string ->x : string | number ->"hello" : string - - return x; // string | number ->x : string | number - } -} -function foo7(x: number | string | boolean) { ->foo7 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - return x === "hello"; // string ->x === "hello" : boolean ->x : string ->"hello" : string - } - else if (typeof x === "boolean") { ->typeof x === "boolean" : boolean ->typeof x : string ->x : number | boolean ->"boolean" : string - - return x; // boolean ->x : boolean - } - else { - return x == 10; // number ->x == 10 : boolean ->x : number ->10 : number - } -} -function foo8(x: number | string | boolean) { ->foo8 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - return x === "hello"; // string ->x === "hello" : boolean ->x : string ->"hello" : string - } - else { - var b: number | boolean = x; // number | boolean ->b : number | boolean ->x : number | boolean - - if (typeof x === "boolean") { ->typeof x === "boolean" : boolean ->typeof x : string ->x : number | boolean ->"boolean" : string - - return x; // boolean ->x : boolean - } - else { - return x == 10; // number ->x == 10 : boolean ->x : number ->10 : number - } - } -} -function foo9(x: number | string) { ->foo9 : (x: string | number) => boolean ->x : string | number - - var y = 10; ->y : number ->10 : number - - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - y = x.length; ->y = x.length : number ->y : number ->x.length : number ->x : string ->length : number - - return x === "hello"; // string ->x === "hello" : boolean ->x : string ->"hello" : string - } - else { - return x == 10; // number ->x == 10 : boolean ->x : number ->10 : number - } -} -function foo10(x: number | string | boolean) { ->foo10 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - return x === "hello"; // string ->x === "hello" : boolean ->x : string ->"hello" : string - } - else { - var y: boolean | string; ->y : string | boolean - - var b = x; // number | boolean ->b : number | boolean ->x : number | boolean - - return typeof x === "number" ->typeof x === "number" ? x === 10 // number : x : boolean ->typeof x === "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - ? x === 10 // number ->x === 10 : boolean ->x : number ->10 : number - - : x; // x should be boolean ->x : boolean - } -} -function foo11(x: number | string | boolean) { ->foo11 : (x: string | number | boolean) => string | number | boolean ->x : string | number | boolean - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x deep inside another guard stops narrowing of type too - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - return x; // string | number | boolean - x changed in else branch ->x : string | number | boolean - } - else { - var y: number| boolean | string; ->y : string | number | boolean - - var b = x; // number | boolean | string - because below we are changing value of x in if statement ->b : string | number | boolean ->x : string | number | boolean - - return typeof x === "number" ->typeof x === "number" ? ( // change value of x x = 10 && x.toString() // number | boolean | string ) : ( // do not change value y = x && x.toString() // number | boolean | string ) : string ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - ? ( ->( // change value of x x = 10 && x.toString() // number | boolean | string ) : string - - // change value of x - x = 10 && x.toString() // number | boolean | string ->x = 10 && x.toString() : string ->x : string | number | boolean ->10 && x.toString() : string ->10 : number ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string - - ) - : ( ->( // do not change value y = x && x.toString() // number | boolean | string ) : string - - // do not change value - y = x && x.toString() // number | boolean | string ->y = x && x.toString() : string ->y : string | number | boolean ->x && x.toString() : string ->x : string | number | boolean ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string - - ); - } -} -function foo12(x: number | string | boolean) { ->foo12 : (x: string | number | boolean) => string ->x : string | number | boolean - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - if (typeof x === "string") { ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - return x.toString(); // string | number | boolean - x changed in else branch ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string - } - else { - x = 10; ->x = 10 : number ->x : string | number | boolean ->10 : number - - var b = x; // number | boolean | string ->b : string | number | boolean ->x : string | number | boolean - - return typeof x === "number" ->typeof x === "number" ? x.toString() // number : x.toString() : string ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - ? x.toString() // number ->x.toString() : string ->x.toString : (radix?: number) => string ->x : number ->toString : (radix?: number) => string - - : x.toString(); // boolean | string ->x.toString() : string ->x.toString : () => string ->x : string | boolean ->toString : () => string - } -} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt new file mode 100644 index 00000000000..f44e433a2c8 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts(43,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts(45,21): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts (2 errors) ==== + // In the right operand of a && operation, + // the type of a variable or parameter is narrowed by any type guard in the left operand when true, + // provided the right operand contains no assignments to the variable or parameter. + function foo(x: number | string) { + return typeof x === "string" && x.length === 10; // string + } + function foo2(x: number | string) { + // modify x in right hand operand + return typeof x === "string" && ((x = 10) && x); // string | number + } + function foo3(x: number | string) { + // modify x in right hand operand with string type itself + return typeof x === "string" && ((x = "hello") && x); // string | number + } + function foo4(x: number | string | boolean) { + return typeof x !== "string" // string | number | boolean + && typeof x !== "number" // number | boolean + && x; // boolean + } + function foo5(x: number | string | boolean) { + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; + return typeof x !== "string" // string | number | boolean + && ((b = x) && (typeof x !== "number" // number | boolean + && x)); // boolean + } + function foo6(x: number | string | boolean) { + // Mixing typeguard narrowing in if statement with conditional expression typeguard + return typeof x !== "string" // string | number | boolean + && (typeof x !== "number" // number | boolean + ? x // boolean + : x === 10) // number + } + function foo7(x: number | string | boolean) { + var y: number| boolean | string; + var z: number| boolean | string; + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x !== "string" + && ((z = x) // string | number | boolean - x changed deeper in conditional expression + && (typeof x === "number" + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + // do not change value + : (y = x && x.toString()))); // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + } + function foo8(x: number | string) { + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x !== "string" + && (x = 10) // change x - number| string + && (typeof x === "number" + ? x // number + : x.length); // string + } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols deleted file mode 100644 index 2a757460234..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.symbols +++ /dev/null @@ -1,143 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts === -// In the right operand of a && operation, -// the type of a variable or parameter is narrowed by any type guard in the left operand when true, -// provided the right operand contains no assignments to the variable or parameter. -function foo(x: number | string) { ->foo : Symbol(foo, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 0, 0)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) - - return typeof x === "string" && x.length === 10; // string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 3, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) -} -function foo2(x: number | string) { ->foo2 : Symbol(foo2, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 5, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) - - // modify x in right hand operand - return typeof x === "string" && ((x = 10) && x); // string | number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 6, 14)) -} -function foo3(x: number | string) { ->foo3 : Symbol(foo3, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 9, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) - - // modify x in right hand operand with string type itself - return typeof x === "string" && ((x = "hello") && x); // string | number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 10, 14)) -} -function foo4(x: number | string | boolean) { ->foo4 : Symbol(foo4, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 13, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) - - return typeof x !== "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) - - && typeof x !== "number" // number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) - - && x; // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 14, 14)) -} -function foo5(x: number | string | boolean) { ->foo5 : Symbol(foo5, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 18, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; ->b : Symbol(b, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 21, 7)) - - return typeof x !== "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) - - && ((b = x) && (typeof x !== "number" // number | boolean ->b : Symbol(b, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 21, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) - - && x)); // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 19, 14)) -} -function foo6(x: number | string | boolean) { ->foo6 : Symbol(foo6, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 25, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - return typeof x !== "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) - - && (typeof x !== "number" // number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) - - ? x // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) - - : x === 10) // number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 26, 14)) -} -function foo7(x: number | string | boolean) { ->foo7 : Symbol(foo7, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 32, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) - - var y: number| boolean | string; ->y : Symbol(y, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 34, 7)) - - var z: number| boolean | string; ->z : Symbol(z, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 35, 7)) - - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x !== "string" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) - - && ((z = x) // string | number | boolean - x changed deeper in conditional expression ->z : Symbol(z, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 35, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) - - && (typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) - - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) - - // do not change value - : (y = x && x.toString()))); // number | boolean | string ->y : Symbol(y, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 34, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 33, 14)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) -} -function foo8(x: number | string) { ->foo8 : Symbol(foo8, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 45, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) - - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x !== "string" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) - - && (x = 10) // change x - number| string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) - - && (typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) - - ? x // number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) - - : x.length); // string ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfAndAndOperator.ts, 46, 14)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) -} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types deleted file mode 100644 index 10b72e3fbd1..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ /dev/null @@ -1,234 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts === -// In the right operand of a && operation, -// the type of a variable or parameter is narrowed by any type guard in the left operand when true, -// provided the right operand contains no assignments to the variable or parameter. -function foo(x: number | string) { ->foo : (x: string | number) => boolean ->x : string | number - - return typeof x === "string" && x.length === 10; // string ->typeof x === "string" && x.length === 10 : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->x.length === 10 : boolean ->x.length : number ->x : string ->length : number ->10 : number -} -function foo2(x: number | string) { ->foo2 : (x: string | number) => string | number ->x : string | number - - // modify x in right hand operand - return typeof x === "string" && ((x = 10) && x); // string | number ->typeof x === "string" && ((x = 10) && x) : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->((x = 10) && x) : string | number ->(x = 10) && x : string | number ->(x = 10) : number ->x = 10 : number ->x : string | number ->10 : number ->x : string | number -} -function foo3(x: number | string) { ->foo3 : (x: string | number) => string | number ->x : string | number - - // modify x in right hand operand with string type itself - return typeof x === "string" && ((x = "hello") && x); // string | number ->typeof x === "string" && ((x = "hello") && x) : string | number ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->((x = "hello") && x) : string | number ->(x = "hello") && x : string | number ->(x = "hello") : string ->x = "hello" : string ->x : string | number ->"hello" : string ->x : string | number -} -function foo4(x: number | string | boolean) { ->foo4 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - return typeof x !== "string" // string | number | boolean ->typeof x !== "string" // string | number | boolean && typeof x !== "number" // number | boolean && x : boolean ->typeof x !== "string" // string | number | boolean && typeof x !== "number" : boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - && typeof x !== "number" // number | boolean ->typeof x !== "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - && x; // boolean ->x : boolean -} -function foo5(x: number | string | boolean) { ->foo5 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; ->b : number | boolean - - return typeof x !== "string" // string | number | boolean ->typeof x !== "string" // string | number | boolean && ((b = x) && (typeof x !== "number" // number | boolean && x)) : boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - && ((b = x) && (typeof x !== "number" // number | boolean ->((b = x) && (typeof x !== "number" // number | boolean && x)) : boolean ->(b = x) && (typeof x !== "number" // number | boolean && x) : boolean ->(b = x) : number | boolean ->b = x : number | boolean ->b : number | boolean ->x : number | boolean ->(typeof x !== "number" // number | boolean && x) : boolean ->typeof x !== "number" // number | boolean && x : boolean ->typeof x !== "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - && x)); // boolean ->x : boolean -} -function foo6(x: number | string | boolean) { ->foo6 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - // Mixing typeguard narrowing in if statement with conditional expression typeguard - return typeof x !== "string" // string | number | boolean ->typeof x !== "string" // string | number | boolean && (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - && (typeof x !== "number" // number | boolean ->(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean ->typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean ->typeof x !== "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - ? x // boolean ->x : boolean - - : x === 10) // number ->x === 10 : boolean ->x : number ->10 : number -} -function foo7(x: number | string | boolean) { ->foo7 : (x: string | number | boolean) => string ->x : string | number | boolean - - var y: number| boolean | string; ->y : string | number | boolean - - var z: number| boolean | string; ->z : string | number | boolean - - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x !== "string" ->typeof x !== "string" && ((z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - && ((z = x) // string | number | boolean - x changed deeper in conditional expression ->((z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string ->(z = x) // string | number | boolean - x changed deeper in conditional expression && (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string ->(z = x) : string | number | boolean ->z = x : string | number | boolean ->z : string | number | boolean ->x : string | number | boolean - - && (typeof x === "number" ->(typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string ->typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()) : string ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string ->(x = 10 && x.toString()) : string ->x = 10 && x.toString() : string ->x : string | number | boolean ->10 && x.toString() : string ->10 : number ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string - - // do not change value - : (y = x && x.toString()))); // number | boolean | string ->(y = x && x.toString()) : string ->y = x && x.toString() : string ->y : string | number | boolean ->x && x.toString() : string ->x : string | number | boolean ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string -} -function foo8(x: number | string) { ->foo8 : (x: string | number) => number ->x : string | number - - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x !== "string" ->typeof x !== "string" && (x = 10) // change x - number| string && (typeof x === "number" ? x // number : x.length) : number ->typeof x !== "string" && (x = 10) : number ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - && (x = 10) // change x - number| string ->(x = 10) : number ->x = 10 : number ->x : string | number ->10 : number - - && (typeof x === "number" ->(typeof x === "number" ? x // number : x.length) : number ->typeof x === "number" ? x // number : x.length : number ->typeof x === "number" : boolean ->typeof x : string ->x : string | number ->"number" : string - - ? x // number ->x : number - - : x.length); // string ->x.length : number ->x : string ->length : number -} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt new file mode 100644 index 00000000000..f34d035fa40 --- /dev/null +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts(43,22): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts(45,21): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts (2 errors) ==== + // In the right operand of a || operation, + // the type of a variable or parameter is narrowed by any type guard in the left operand when false, + // provided the right operand contains no assignments to the variable or parameter. + function foo(x: number | string) { + return typeof x !== "string" || x.length === 10; // string + } + function foo2(x: number | string) { + // modify x in right hand operand + return typeof x !== "string" || ((x = 10) || x); // string | number + } + function foo3(x: number | string) { + // modify x in right hand operand with string type itself + return typeof x !== "string" || ((x = "hello") || x); // string | number + } + function foo4(x: number | string | boolean) { + return typeof x === "string" // string | number | boolean + || typeof x === "number" // number | boolean + || x; // boolean + } + function foo5(x: number | string | boolean) { + // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop + var b: number | boolean; + return typeof x === "string" // string | number | boolean + || ((b = x) || (typeof x === "number" // number | boolean + || x)); // boolean + } + function foo6(x: number | string | boolean) { + // Mixing typeguard + return typeof x === "string" // string | number | boolean + || (typeof x !== "number" // number | boolean + ? x // boolean + : x === 10) // number + } + function foo7(x: number | string | boolean) { + var y: number| boolean | string; + var z: number| boolean | string; + // Mixing typeguard narrowing + // Assigning value to x deep inside another guard stops narrowing of type too + return typeof x === "string" + || ((z = x) // string | number | boolean - x changed deeper in conditional expression + || (typeof x === "number" + // change value of x + ? (x = 10 && x.toString()) // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + // do not change value + : (y = x && x.toString()))); // number | boolean | string + ~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + } + function foo8(x: number | string) { + // Mixing typeguard + // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression + return typeof x === "string" + || (x = 10) // change x - number| string + || (typeof x === "number" + ? x // number + : x.length); // string + } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols deleted file mode 100644 index dd751b7d8dd..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.symbols +++ /dev/null @@ -1,143 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts === -// In the right operand of a || operation, -// the type of a variable or parameter is narrowed by any type guard in the left operand when false, -// provided the right operand contains no assignments to the variable or parameter. -function foo(x: number | string) { ->foo : Symbol(foo, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 0, 0)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) - - return typeof x !== "string" || x.length === 10; // string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 3, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) -} -function foo2(x: number | string) { ->foo2 : Symbol(foo2, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 5, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) - - // modify x in right hand operand - return typeof x !== "string" || ((x = 10) || x); // string | number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 6, 14)) -} -function foo3(x: number | string) { ->foo3 : Symbol(foo3, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 9, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) - - // modify x in right hand operand with string type itself - return typeof x !== "string" || ((x = "hello") || x); // string | number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 10, 14)) -} -function foo4(x: number | string | boolean) { ->foo4 : Symbol(foo4, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 13, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) - - return typeof x === "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) - - || typeof x === "number" // number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) - - || x; // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 14, 14)) -} -function foo5(x: number | string | boolean) { ->foo5 : Symbol(foo5, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 18, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; ->b : Symbol(b, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 21, 7)) - - return typeof x === "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) - - || ((b = x) || (typeof x === "number" // number | boolean ->b : Symbol(b, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 21, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) - - || x)); // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 19, 14)) -} -function foo6(x: number | string | boolean) { ->foo6 : Symbol(foo6, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 25, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) - - // Mixing typeguard - return typeof x === "string" // string | number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) - - || (typeof x !== "number" // number | boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) - - ? x // boolean ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) - - : x === 10) // number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 26, 14)) -} -function foo7(x: number | string | boolean) { ->foo7 : Symbol(foo7, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 32, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) - - var y: number| boolean | string; ->y : Symbol(y, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 34, 7)) - - var z: number| boolean | string; ->z : Symbol(z, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 35, 7)) - - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) - - || ((z = x) // string | number | boolean - x changed deeper in conditional expression ->z : Symbol(z, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 35, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) - - || (typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) - - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) - - // do not change value - : (y = x && x.toString()))); // number | boolean | string ->y : Symbol(y, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 34, 7)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) ->x.toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 33, 14)) ->toString : Symbol(toString, Decl(lib.d.ts, 277, 18), Decl(lib.d.ts, 458, 18), Decl(lib.d.ts, 96, 26)) -} -function foo8(x: number | string) { ->foo8 : Symbol(foo8, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 45, 1)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) - - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x === "string" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) - - || (x = 10) // change x - number| string ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) - - || (typeof x === "number" ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) - - ? x // number ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) - - : x.length); // string ->x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) ->x : Symbol(x, Decl(typeGuardsInRightOperandOfOrOrOperator.ts, 46, 14)) ->length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) -} diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types deleted file mode 100644 index 81160323429..00000000000 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ /dev/null @@ -1,234 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfOrOrOperator.ts === -// In the right operand of a || operation, -// the type of a variable or parameter is narrowed by any type guard in the left operand when false, -// provided the right operand contains no assignments to the variable or parameter. -function foo(x: number | string) { ->foo : (x: string | number) => boolean ->x : string | number - - return typeof x !== "string" || x.length === 10; // string ->typeof x !== "string" || x.length === 10 : boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->x.length === 10 : boolean ->x.length : number ->x : string ->length : number ->10 : number -} -function foo2(x: number | string) { ->foo2 : (x: string | number) => string | number | boolean ->x : string | number - - // modify x in right hand operand - return typeof x !== "string" || ((x = 10) || x); // string | number ->typeof x !== "string" || ((x = 10) || x) : string | number | boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->((x = 10) || x) : string | number ->(x = 10) || x : string | number ->(x = 10) : number ->x = 10 : number ->x : string | number ->10 : number ->x : string | number -} -function foo3(x: number | string) { ->foo3 : (x: string | number) => string | number | boolean ->x : string | number - - // modify x in right hand operand with string type itself - return typeof x !== "string" || ((x = "hello") || x); // string | number ->typeof x !== "string" || ((x = "hello") || x) : string | number | boolean ->typeof x !== "string" : boolean ->typeof x : string ->x : string | number ->"string" : string ->((x = "hello") || x) : string | number ->(x = "hello") || x : string | number ->(x = "hello") : string ->x = "hello" : string ->x : string | number ->"hello" : string ->x : string | number -} -function foo4(x: number | string | boolean) { ->foo4 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - return typeof x === "string" // string | number | boolean ->typeof x === "string" // string | number | boolean || typeof x === "number" // number | boolean || x : boolean ->typeof x === "string" // string | number | boolean || typeof x === "number" : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - || typeof x === "number" // number | boolean ->typeof x === "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - || x; // boolean ->x : boolean -} -function foo5(x: number | string | boolean) { ->foo5 : (x: string | number | boolean) => number | boolean ->x : string | number | boolean - - // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop - var b: number | boolean; ->b : number | boolean - - return typeof x === "string" // string | number | boolean ->typeof x === "string" // string | number | boolean || ((b = x) || (typeof x === "number" // number | boolean || x)) : number | boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - || ((b = x) || (typeof x === "number" // number | boolean ->((b = x) || (typeof x === "number" // number | boolean || x)) : number | boolean ->(b = x) || (typeof x === "number" // number | boolean || x) : number | boolean ->(b = x) : number | boolean ->b = x : number | boolean ->b : number | boolean ->x : number | boolean ->(typeof x === "number" // number | boolean || x) : boolean ->typeof x === "number" // number | boolean || x : boolean ->typeof x === "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - || x)); // boolean ->x : boolean -} -function foo6(x: number | string | boolean) { ->foo6 : (x: string | number | boolean) => boolean ->x : string | number | boolean - - // Mixing typeguard - return typeof x === "string" // string | number | boolean ->typeof x === "string" // string | number | boolean || (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - || (typeof x !== "number" // number | boolean ->(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean ->typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean ->typeof x !== "number" : boolean ->typeof x : string ->x : number | boolean ->"number" : string - - ? x // boolean ->x : boolean - - : x === 10) // number ->x === 10 : boolean ->x : number ->10 : number -} -function foo7(x: number | string | boolean) { ->foo7 : (x: string | number | boolean) => string | number | boolean ->x : string | number | boolean - - var y: number| boolean | string; ->y : string | number | boolean - - var z: number| boolean | string; ->z : string | number | boolean - - // Mixing typeguard narrowing - // Assigning value to x deep inside another guard stops narrowing of type too - return typeof x === "string" ->typeof x === "string" || ((z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string | number | boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number | boolean ->"string" : string - - || ((z = x) // string | number | boolean - x changed deeper in conditional expression ->((z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()))) : string | number | boolean ->(z = x) // string | number | boolean - x changed deeper in conditional expression || (typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string | number | boolean ->(z = x) : string | number | boolean ->z = x : string | number | boolean ->z : string | number | boolean ->x : string | number | boolean - - || (typeof x === "number" ->(typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString())) : string ->typeof x === "number" // change value of x ? (x = 10 && x.toString()) // number | boolean | string // do not change value : (y = x && x.toString()) : string ->typeof x === "number" : boolean ->typeof x : string ->x : string | number | boolean ->"number" : string - - // change value of x - ? (x = 10 && x.toString()) // number | boolean | string ->(x = 10 && x.toString()) : string ->x = 10 && x.toString() : string ->x : string | number | boolean ->10 && x.toString() : string ->10 : number ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string - - // do not change value - : (y = x && x.toString()))); // number | boolean | string ->(y = x && x.toString()) : string ->y = x && x.toString() : string ->y : string | number | boolean ->x && x.toString() : string ->x : string | number | boolean ->x.toString() : string ->x.toString : () => string ->x : string | number | boolean ->toString : () => string -} -function foo8(x: number | string) { ->foo8 : (x: string | number) => number | boolean ->x : string | number - - // Mixing typeguard - // Assigning value to x in outer guard shouldn't stop narrowing in the inner expression - return typeof x === "string" ->typeof x === "string" || (x = 10) // change x - number| string || (typeof x === "number" ? x // number : x.length) : number | boolean ->typeof x === "string" || (x = 10) : number | boolean ->typeof x === "string" : boolean ->typeof x : string ->x : string | number ->"string" : string - - || (x = 10) // change x - number| string ->(x = 10) : number ->x = 10 : number ->x : string | number ->10 : number - - || (typeof x === "number" ->(typeof x === "number" ? x // number : x.length) : number ->typeof x === "number" ? x // number : x.length : number ->typeof x === "number" : boolean ->typeof x : string ->x : string | number ->"number" : string - - ? x // number ->x : number - - : x.length); // string ->x.length : number ->x : string ->length : number -} diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt b/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt index 4e6a8b83ae3..91d6d6998bc 100644 --- a/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt +++ b/tests/baselines/reference/typeGuardsOnClassProperty.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(14,70): error TS2339: Property 'join' does not exist on type 'string | string[]'. -tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(26,44): error TS2339: Property 'toLowerCase' does not exist on type 'string | number'. +tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(26,44): error TS2339: Property 'toLowerCase' does not exist on type 'number | string'. ==== tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts (2 errors) ==== @@ -32,6 +32,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(26,4 if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} ~~~~~~~~~~~ -!!! error TS2339: Property 'toLowerCase' does not exist on type 'string | number'. +!!! error TS2339: Property 'toLowerCase' does not exist on type 'number | string'. var prop1 = o.prop1; if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index 4960940d3ab..2f86b6797d7 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -6,8 +6,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(111,10): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'string | F'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'string | F'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'F | string'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'F | string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. @@ -164,10 +164,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru if (obj11 instanceof F) { // can't type narrowing, construct signature returns any. obj11.foo; ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'string | F'. +!!! error TS2339: Property 'foo' does not exist on type 'F | string'. obj11.bar; ~~~ -!!! error TS2339: Property 'bar' does not exist on type 'string | F'. +!!! error TS2339: Property 'bar' does not exist on type 'F | string'. } var obj12: any; diff --git a/tests/baselines/reference/typeInfer1.errors.txt b/tests/baselines/reference/typeInfer1.errors.txt index cce736e2531..2550bb1fe8d 100644 --- a/tests/baselines/reference/typeInfer1.errors.txt +++ b/tests/baselines/reference/typeInfer1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. - Property 'Write' is missing in type '{ Moo: () => string; }'. + Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. ==== tests/cases/compiler/typeInfer1.ts (1 errors) ==== @@ -16,6 +16,6 @@ tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => strin var yyyyyyyy: ITextWriter2 = { ~~~~~~~~ !!! error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. -!!! error TS2322: Property 'Write' is missing in type '{ Moo: () => string; }'. +!!! error TS2322: Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. Moo: function() { return "cow"; } } \ No newline at end of file diff --git a/tests/baselines/reference/typeMatch2.errors.txt b/tests/baselines/reference/typeMatch2.errors.txt index 4db4828064e..a497551c953 100644 --- a/tests/baselines/reference/typeMatch2.errors.txt +++ b/tests/baselines/reference/typeMatch2.errors.txt @@ -2,8 +2,10 @@ tests/cases/compiler/typeMatch2.ts(3,2): error TS2322: Type '{}' is not assignab Property 'x' is missing in type '{}'. tests/cases/compiler/typeMatch2.ts(4,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. +tests/cases/compiler/typeMatch2.ts(5,2): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. + Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(6,5): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. - Property 'y' is missing in type '{ x: number; z: number; }'. + Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(18,5): error TS2322: Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. Property 'g' is missing in type 'Animal'. @@ -11,11 +13,13 @@ tests/cases/compiler/typeMatch2.ts(22,5): error TS2322: Type '{ f1: number; f2: Types of property 'f2' are incompatible. Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. +tests/cases/compiler/typeMatch2.ts(34,5): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. + Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. -==== tests/cases/compiler/typeMatch2.ts (6 errors) ==== +==== tests/cases/compiler/typeMatch2.ts (8 errors) ==== function f1() { var a = { x: 1, y: 2 }; a = {}; // error @@ -27,10 +31,13 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Property 'y' is missing in type '{ x: number; }'. a = { x: 1, y: 2, z: 3 }; + ~ +!!! error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1, z: 3 }; // error ~ !!! error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. -!!! error TS2322: Property 'y' is missing in type '{ x: number; z: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. } class Animal { private a; } @@ -68,6 +75,9 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is a = { x: 1, y: undefined }; a = { x: 1, y: _any }; a = { x: 1, y: _any, z:1 }; + ~ +!!! error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1 }; // error ~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. diff --git a/tests/baselines/reference/typeParameterAsElementType.types b/tests/baselines/reference/typeParameterAsElementType.types index 10e6787ae31..3b145b7f3cf 100644 --- a/tests/baselines/reference/typeParameterAsElementType.types +++ b/tests/baselines/reference/typeParameterAsElementType.types @@ -8,8 +8,8 @@ function fee() { >T : T var arr = [t, ""]; ->arr : (string | T)[] ->[t, ""] : (string | T)[] +>arr : (T | string)[] +>[t, ""] : (T | string)[] >t : T >"" : string } diff --git a/tests/baselines/reference/underscoreTest1.js b/tests/baselines/reference/underscoreTest1.js index ddd5201b858..687a210e670 100644 --- a/tests/baselines/reference/underscoreTest1.js +++ b/tests/baselines/reference/underscoreTest1.js @@ -385,6 +385,7 @@ module Underscore { evaluate?: RegExp; interpolate?: RegExp; escape?: RegExp; + variable?: string; } export interface Static { diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 128ce83051a..1ba7c97d331 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -9,9 +9,9 @@ declare function alert(x: string): void; >x : Symbol(x, Decl(underscoreTest1_underscoreTests.ts, 3, 23)) _.each([1, 2, 3], (num) => alert(num.toString())); ->_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) +>_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 5, 19)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) >num.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) @@ -19,9 +19,9 @@ _.each([1, 2, 3], (num) => alert(num.toString())); >toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) _.each({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => alert(value.toString())); ->_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) +>_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 6, 8)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 6, 16)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 6, 24)) @@ -33,16 +33,16 @@ _.each({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => alert(valu >toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18)) _.map([1, 2, 3], (num) => num * 3); ->_.map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 399, 90), Decl(underscoreTest1_underscore.ts, 401, 75)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 399, 90), Decl(underscoreTest1_underscore.ts, 401, 75)) +>_.map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 400, 90), Decl(underscoreTest1_underscore.ts, 402, 75)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 400, 90), Decl(underscoreTest1_underscore.ts, 402, 75)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 8, 18)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 8, 18)) _.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); ->_.map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 399, 90), Decl(underscoreTest1_underscore.ts, 401, 75)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 399, 90), Decl(underscoreTest1_underscore.ts, 401, 75)) +>_.map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 400, 90), Decl(underscoreTest1_underscore.ts, 402, 75)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>map : Symbol(Underscore.Static.map, Decl(underscoreTest1_underscore.ts, 400, 90), Decl(underscoreTest1_underscore.ts, 402, 75)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 9, 7)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 9, 15)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 9, 23)) @@ -52,9 +52,9 @@ _.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); >sum : Symbol(sum, Decl(underscoreTest1_underscoreTests.ts, 11, 3)) ->_.reduce : Symbol(Underscore.Static.reduce, Decl(underscoreTest1_underscore.ts, 404, 89), Decl(underscoreTest1_underscore.ts, 406, 90), Decl(underscoreTest1_underscore.ts, 407, 92), Decl(underscoreTest1_underscore.ts, 408, 100)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->reduce : Symbol(Underscore.Static.reduce, Decl(underscoreTest1_underscore.ts, 404, 89), Decl(underscoreTest1_underscore.ts, 406, 90), Decl(underscoreTest1_underscore.ts, 407, 92), Decl(underscoreTest1_underscore.ts, 408, 100)) +>_.reduce : Symbol(Underscore.Static.reduce, Decl(underscoreTest1_underscore.ts, 405, 89), Decl(underscoreTest1_underscore.ts, 407, 90), Decl(underscoreTest1_underscore.ts, 408, 92), Decl(underscoreTest1_underscore.ts, 409, 100)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>reduce : Symbol(Underscore.Static.reduce, Decl(underscoreTest1_underscore.ts, 405, 89), Decl(underscoreTest1_underscore.ts, 407, 90), Decl(underscoreTest1_underscore.ts, 408, 92), Decl(underscoreTest1_underscore.ts, 409, 100)) >memo : Symbol(memo, Decl(underscoreTest1_underscoreTests.ts, 11, 31)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 11, 36)) >memo : Symbol(memo, Decl(underscoreTest1_underscoreTests.ts, 11, 31)) @@ -65,9 +65,9 @@ var list = [[0, 1], [2, 3], [4, 5]]; var flat = _.reduceRight(list, (a, b) => a.concat(b), []); >flat : Symbol(flat, Decl(underscoreTest1_underscoreTests.ts, 14, 3)) ->_.reduceRight : Symbol(Underscore.Static.reduceRight, Decl(underscoreTest1_underscore.ts, 417, 102), Decl(underscoreTest1_underscore.ts, 419, 95), Decl(underscoreTest1_underscore.ts, 420, 97), Decl(underscoreTest1_underscore.ts, 421, 105)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->reduceRight : Symbol(Underscore.Static.reduceRight, Decl(underscoreTest1_underscore.ts, 417, 102), Decl(underscoreTest1_underscore.ts, 419, 95), Decl(underscoreTest1_underscore.ts, 420, 97), Decl(underscoreTest1_underscore.ts, 421, 105)) +>_.reduceRight : Symbol(Underscore.Static.reduceRight, Decl(underscoreTest1_underscore.ts, 418, 102), Decl(underscoreTest1_underscore.ts, 420, 95), Decl(underscoreTest1_underscore.ts, 421, 97), Decl(underscoreTest1_underscore.ts, 422, 105)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>reduceRight : Symbol(Underscore.Static.reduceRight, Decl(underscoreTest1_underscore.ts, 418, 102), Decl(underscoreTest1_underscore.ts, 420, 95), Decl(underscoreTest1_underscore.ts, 421, 97), Decl(underscoreTest1_underscore.ts, 422, 105)) >list : Symbol(list, Decl(underscoreTest1_underscoreTests.ts, 13, 3)) >a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 14, 32)) >b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 14, 34)) @@ -78,17 +78,17 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []); var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >even : Symbol(even, Decl(underscoreTest1_underscoreTests.ts, 16, 3)) ->_.find : Symbol(Underscore.Static.find, Decl(underscoreTest1_underscore.ts, 426, 101), Decl(underscoreTest1_underscore.ts, 428, 77)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->find : Symbol(Underscore.Static.find, Decl(underscoreTest1_underscore.ts, 426, 101), Decl(underscoreTest1_underscore.ts, 428, 77)) +>_.find : Symbol(Underscore.Static.find, Decl(underscoreTest1_underscore.ts, 427, 101), Decl(underscoreTest1_underscore.ts, 429, 77)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>find : Symbol(Underscore.Static.find, Decl(underscoreTest1_underscore.ts, 427, 101), Decl(underscoreTest1_underscore.ts, 429, 77)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 16, 39)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 16, 39)) var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >evens : Symbol(evens, Decl(underscoreTest1_underscoreTests.ts, 18, 3)) ->_.filter : Symbol(Underscore.Static.filter, Decl(underscoreTest1_underscore.ts, 431, 89), Decl(underscoreTest1_underscore.ts, 433, 81)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->filter : Symbol(Underscore.Static.filter, Decl(underscoreTest1_underscore.ts, 431, 89), Decl(underscoreTest1_underscore.ts, 433, 81)) +>_.filter : Symbol(Underscore.Static.filter, Decl(underscoreTest1_underscore.ts, 432, 89), Decl(underscoreTest1_underscore.ts, 434, 81)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>filter : Symbol(Underscore.Static.filter, Decl(underscoreTest1_underscore.ts, 432, 89), Decl(underscoreTest1_underscore.ts, 434, 81)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 18, 42)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 18, 42)) @@ -105,43 +105,43 @@ var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { >year : Symbol(year, Decl(underscoreTest1_underscoreTests.ts, 20, 183)) _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); ->_.where : Symbol(Underscore.Static.where, Decl(underscoreTest1_underscore.ts, 436, 91), Decl(underscoreTest1_underscore.ts, 438, 53)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->where : Symbol(Underscore.Static.where, Decl(underscoreTest1_underscore.ts, 436, 91), Decl(underscoreTest1_underscore.ts, 438, 53)) +>_.where : Symbol(Underscore.Static.where, Decl(underscoreTest1_underscore.ts, 437, 91), Decl(underscoreTest1_underscore.ts, 439, 53)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>where : Symbol(Underscore.Static.where, Decl(underscoreTest1_underscore.ts, 437, 91), Decl(underscoreTest1_underscore.ts, 439, 53)) >listOfPlays : Symbol(listOfPlays, Decl(underscoreTest1_underscoreTests.ts, 20, 3)) >author : Symbol(author, Decl(underscoreTest1_underscoreTests.ts, 21, 22)) >year : Symbol(year, Decl(underscoreTest1_underscoreTests.ts, 21, 45)) var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >odds : Symbol(odds, Decl(underscoreTest1_underscoreTests.ts, 23, 3)) ->_.reject : Symbol(Underscore.Static.reject, Decl(underscoreTest1_underscore.ts, 442, 65), Decl(underscoreTest1_underscore.ts, 444, 81)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->reject : Symbol(Underscore.Static.reject, Decl(underscoreTest1_underscore.ts, 442, 65), Decl(underscoreTest1_underscore.ts, 444, 81)) +>_.reject : Symbol(Underscore.Static.reject, Decl(underscoreTest1_underscore.ts, 443, 65), Decl(underscoreTest1_underscore.ts, 445, 81)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>reject : Symbol(Underscore.Static.reject, Decl(underscoreTest1_underscore.ts, 443, 65), Decl(underscoreTest1_underscore.ts, 445, 81)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 23, 41)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 23, 41)) _.all([true, 1, null, 'yes'], _.identity); ->_.all : Symbol(Underscore.Static.all, Decl(underscoreTest1_underscore.ts, 448, 95), Decl(underscoreTest1_underscore.ts, 449, 83)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->all : Symbol(Underscore.Static.all, Decl(underscoreTest1_underscore.ts, 448, 95), Decl(underscoreTest1_underscore.ts, 449, 83)) ->_.identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 617, 29)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 617, 29)) +>_.all : Symbol(Underscore.Static.all, Decl(underscoreTest1_underscore.ts, 449, 95), Decl(underscoreTest1_underscore.ts, 450, 83)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>all : Symbol(Underscore.Static.all, Decl(underscoreTest1_underscore.ts, 449, 95), Decl(underscoreTest1_underscore.ts, 450, 83)) +>_.identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 618, 29)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 618, 29)) _.any([null, 0, 'yes', false]); ->_.any : Symbol(Underscore.Static.any, Decl(underscoreTest1_underscore.ts, 453, 94), Decl(underscoreTest1_underscore.ts, 454, 83)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->any : Symbol(Underscore.Static.any, Decl(underscoreTest1_underscore.ts, 453, 94), Decl(underscoreTest1_underscore.ts, 454, 83)) +>_.any : Symbol(Underscore.Static.any, Decl(underscoreTest1_underscore.ts, 454, 94), Decl(underscoreTest1_underscore.ts, 455, 83)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>any : Symbol(Underscore.Static.any, Decl(underscoreTest1_underscore.ts, 454, 94), Decl(underscoreTest1_underscore.ts, 455, 83)) _.contains([1, 2, 3], 3); ->_.contains : Symbol(Underscore.Static.contains, Decl(underscoreTest1_underscore.ts, 455, 93), Decl(underscoreTest1_underscore.ts, 457, 50)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->contains : Symbol(Underscore.Static.contains, Decl(underscoreTest1_underscore.ts, 455, 93), Decl(underscoreTest1_underscore.ts, 457, 50)) +>_.contains : Symbol(Underscore.Static.contains, Decl(underscoreTest1_underscore.ts, 456, 93), Decl(underscoreTest1_underscore.ts, 458, 50)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>contains : Symbol(Underscore.Static.contains, Decl(underscoreTest1_underscore.ts, 456, 93), Decl(underscoreTest1_underscore.ts, 458, 50)) _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ->_.invoke : Symbol(Underscore.Static.invoke, Decl(underscoreTest1_underscore.ts, 460, 59), Decl(underscoreTest1_underscore.ts, 462, 71)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->invoke : Symbol(Underscore.Static.invoke, Decl(underscoreTest1_underscore.ts, 460, 59), Decl(underscoreTest1_underscore.ts, 462, 71)) +>_.invoke : Symbol(Underscore.Static.invoke, Decl(underscoreTest1_underscore.ts, 461, 59), Decl(underscoreTest1_underscore.ts, 463, 71)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>invoke : Symbol(Underscore.Static.invoke, Decl(underscoreTest1_underscore.ts, 461, 59), Decl(underscoreTest1_underscore.ts, 463, 71)) var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }]; >stooges : Symbol(stooges, Decl(underscoreTest1_underscoreTests.ts, 33, 3)) @@ -153,15 +153,15 @@ var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'cu >age : Symbol(age, Decl(underscoreTest1_underscoreTests.ts, 33, 85)) _.pluck(stooges, 'name'); ->_.pluck : Symbol(Underscore.Static.pluck, Decl(underscoreTest1_underscore.ts, 463, 81), Decl(underscoreTest1_underscore.ts, 465, 56)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->pluck : Symbol(Underscore.Static.pluck, Decl(underscoreTest1_underscore.ts, 463, 81), Decl(underscoreTest1_underscore.ts, 465, 56)) +>_.pluck : Symbol(Underscore.Static.pluck, Decl(underscoreTest1_underscore.ts, 464, 81), Decl(underscoreTest1_underscore.ts, 466, 56)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>pluck : Symbol(Underscore.Static.pluck, Decl(underscoreTest1_underscore.ts, 464, 81), Decl(underscoreTest1_underscore.ts, 466, 56)) >stooges : Symbol(stooges, Decl(underscoreTest1_underscoreTests.ts, 33, 3)) _.max(stooges, (stooge) => stooge.age); ->_.max : Symbol(Underscore.Static.max, Decl(underscoreTest1_underscore.ts, 466, 66), Decl(underscoreTest1_underscore.ts, 468, 73)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->max : Symbol(Underscore.Static.max, Decl(underscoreTest1_underscore.ts, 466, 66), Decl(underscoreTest1_underscore.ts, 468, 73)) +>_.max : Symbol(Underscore.Static.max, Decl(underscoreTest1_underscore.ts, 467, 66), Decl(underscoreTest1_underscore.ts, 469, 73)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>max : Symbol(Underscore.Static.max, Decl(underscoreTest1_underscore.ts, 467, 66), Decl(underscoreTest1_underscore.ts, 469, 73)) >stooges : Symbol(stooges, Decl(underscoreTest1_underscoreTests.ts, 33, 3)) >stooge : Symbol(stooge, Decl(underscoreTest1_underscoreTests.ts, 36, 16)) >stooge.age : Symbol(age, Decl(underscoreTest1_underscoreTests.ts, 33, 29)) @@ -172,15 +172,15 @@ var numbers = [10, 5, 100, 2, 1000]; >numbers : Symbol(numbers, Decl(underscoreTest1_underscoreTests.ts, 38, 3)) _.min(numbers); ->_.min : Symbol(Underscore.Static.min, Decl(underscoreTest1_underscore.ts, 469, 83), Decl(underscoreTest1_underscore.ts, 471, 73)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->min : Symbol(Underscore.Static.min, Decl(underscoreTest1_underscore.ts, 469, 83), Decl(underscoreTest1_underscore.ts, 471, 73)) +>_.min : Symbol(Underscore.Static.min, Decl(underscoreTest1_underscore.ts, 470, 83), Decl(underscoreTest1_underscore.ts, 472, 73)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>min : Symbol(Underscore.Static.min, Decl(underscoreTest1_underscore.ts, 470, 83), Decl(underscoreTest1_underscore.ts, 472, 73)) >numbers : Symbol(numbers, Decl(underscoreTest1_underscoreTests.ts, 38, 3)) _.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num)); ->_.sortBy : Symbol(Underscore.Static.sortBy, Decl(underscoreTest1_underscore.ts, 472, 83), Decl(underscoreTest1_underscore.ts, 474, 77), Decl(underscoreTest1_underscore.ts, 475, 87), Decl(underscoreTest1_underscore.ts, 476, 56)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->sortBy : Symbol(Underscore.Static.sortBy, Decl(underscoreTest1_underscore.ts, 472, 83), Decl(underscoreTest1_underscore.ts, 474, 77), Decl(underscoreTest1_underscore.ts, 475, 87), Decl(underscoreTest1_underscore.ts, 476, 56)) +>_.sortBy : Symbol(Underscore.Static.sortBy, Decl(underscoreTest1_underscore.ts, 473, 83), Decl(underscoreTest1_underscore.ts, 475, 77), Decl(underscoreTest1_underscore.ts, 476, 87), Decl(underscoreTest1_underscore.ts, 477, 56)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>sortBy : Symbol(Underscore.Static.sortBy, Decl(underscoreTest1_underscore.ts, 473, 83), Decl(underscoreTest1_underscore.ts, 475, 77), Decl(underscoreTest1_underscore.ts, 476, 87), Decl(underscoreTest1_underscore.ts, 477, 56)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 41, 30)) >Math.sin : Symbol(Math.sin, Decl(lib.d.ts, 615, 29)) >Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11)) @@ -191,7 +191,7 @@ _.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num)); // not sure how this is typechecking at all.. Math.floor(e) is number not string..? _([1.3, 2.1, 2.4]).groupBy((e: number, i?: number, list?: number[]) => Math.floor(e)); >_([1.3, 2.1, 2.4]).groupBy : Symbol(Underscore.WrappedArray.groupBy, Decl(underscoreTest1_underscore.ts, 112, 42), Decl(underscoreTest1_underscore.ts, 113, 77)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) >groupBy : Symbol(Underscore.WrappedArray.groupBy, Decl(underscoreTest1_underscore.ts, 112, 42), Decl(underscoreTest1_underscore.ts, 113, 77)) >e : Symbol(e, Decl(underscoreTest1_underscoreTests.ts, 45, 28)) >i : Symbol(i, Decl(underscoreTest1_underscoreTests.ts, 45, 38)) @@ -202,9 +202,9 @@ _([1.3, 2.1, 2.4]).groupBy((e: number, i?: number, list?: number[]) => Math.floo >e : Symbol(e, Decl(underscoreTest1_underscoreTests.ts, 45, 28)) _.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num)); ->_.groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 477, 66), Decl(underscoreTest1_underscore.ts, 479, 91), Decl(underscoreTest1_underscore.ts, 480, 101), Decl(underscoreTest1_underscore.ts, 481, 69)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 477, 66), Decl(underscoreTest1_underscore.ts, 479, 91), Decl(underscoreTest1_underscore.ts, 480, 101), Decl(underscoreTest1_underscore.ts, 481, 69)) +>_.groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 478, 66), Decl(underscoreTest1_underscore.ts, 480, 91), Decl(underscoreTest1_underscore.ts, 481, 101), Decl(underscoreTest1_underscore.ts, 482, 69)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 478, 66), Decl(underscoreTest1_underscore.ts, 480, 91), Decl(underscoreTest1_underscore.ts, 481, 101), Decl(underscoreTest1_underscore.ts, 482, 69)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 46, 28)) >Math.floor : Symbol(Math.floor, Decl(lib.d.ts, 582, 27)) >Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11)) @@ -212,28 +212,28 @@ _.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num)); >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 46, 28)) _.groupBy(['one', 'two', 'three'], 'length'); ->_.groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 477, 66), Decl(underscoreTest1_underscore.ts, 479, 91), Decl(underscoreTest1_underscore.ts, 480, 101), Decl(underscoreTest1_underscore.ts, 481, 69)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 477, 66), Decl(underscoreTest1_underscore.ts, 479, 91), Decl(underscoreTest1_underscore.ts, 480, 101), Decl(underscoreTest1_underscore.ts, 481, 69)) +>_.groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 478, 66), Decl(underscoreTest1_underscore.ts, 480, 91), Decl(underscoreTest1_underscore.ts, 481, 101), Decl(underscoreTest1_underscore.ts, 482, 69)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>groupBy : Symbol(Underscore.Static.groupBy, Decl(underscoreTest1_underscore.ts, 478, 66), Decl(underscoreTest1_underscore.ts, 480, 91), Decl(underscoreTest1_underscore.ts, 481, 101), Decl(underscoreTest1_underscore.ts, 482, 69)) _.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd'); ->_.countBy : Symbol(Underscore.Static.countBy, Decl(underscoreTest1_underscore.ts, 482, 79), Decl(underscoreTest1_underscore.ts, 484, 94), Decl(underscoreTest1_underscore.ts, 485, 104), Decl(underscoreTest1_underscore.ts, 486, 72)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->countBy : Symbol(Underscore.Static.countBy, Decl(underscoreTest1_underscore.ts, 482, 79), Decl(underscoreTest1_underscore.ts, 484, 94), Decl(underscoreTest1_underscore.ts, 485, 104), Decl(underscoreTest1_underscore.ts, 486, 72)) +>_.countBy : Symbol(Underscore.Static.countBy, Decl(underscoreTest1_underscore.ts, 483, 79), Decl(underscoreTest1_underscore.ts, 485, 94), Decl(underscoreTest1_underscore.ts, 486, 104), Decl(underscoreTest1_underscore.ts, 487, 72)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>countBy : Symbol(Underscore.Static.countBy, Decl(underscoreTest1_underscore.ts, 483, 79), Decl(underscoreTest1_underscore.ts, 485, 94), Decl(underscoreTest1_underscore.ts, 486, 104), Decl(underscoreTest1_underscore.ts, 487, 72)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 49, 28)) >num : Symbol(num, Decl(underscoreTest1_underscoreTests.ts, 49, 28)) _.shuffle([1, 2, 3, 4, 5, 6]); ->_.shuffle : Symbol(Underscore.Static.shuffle, Decl(underscoreTest1_underscore.ts, 487, 82), Decl(underscoreTest1_underscore.ts, 489, 35)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->shuffle : Symbol(Underscore.Static.shuffle, Decl(underscoreTest1_underscore.ts, 487, 82), Decl(underscoreTest1_underscore.ts, 489, 35)) +>_.shuffle : Symbol(Underscore.Static.shuffle, Decl(underscoreTest1_underscore.ts, 488, 82), Decl(underscoreTest1_underscore.ts, 490, 35)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>shuffle : Symbol(Underscore.Static.shuffle, Decl(underscoreTest1_underscore.ts, 488, 82), Decl(underscoreTest1_underscore.ts, 490, 35)) // (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); _.size({ one: 1, two: 2, three: 3 }); ->_.size : Symbol(Underscore.Static.size, Decl(underscoreTest1_underscore.ts, 493, 45), Decl(underscoreTest1_underscore.ts, 495, 35)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->size : Symbol(Underscore.Static.size, Decl(underscoreTest1_underscore.ts, 493, 45), Decl(underscoreTest1_underscore.ts, 495, 35)) +>_.size : Symbol(Underscore.Static.size, Decl(underscoreTest1_underscore.ts, 494, 45), Decl(underscoreTest1_underscore.ts, 496, 35)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>size : Symbol(Underscore.Static.size, Decl(underscoreTest1_underscore.ts, 494, 45), Decl(underscoreTest1_underscore.ts, 496, 35)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 55, 8)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 55, 16)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 55, 24)) @@ -241,130 +241,130 @@ _.size({ one: 1, two: 2, three: 3 }); /////////////////////////////////////////////////////////////////////////////////////// _.first([5, 4, 3, 2, 1]); ->_.first : Symbol(Underscore.Static.first, Decl(underscoreTest1_underscore.ts, 496, 45), Decl(underscoreTest1_underscore.ts, 498, 31)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->first : Symbol(Underscore.Static.first, Decl(underscoreTest1_underscore.ts, 496, 45), Decl(underscoreTest1_underscore.ts, 498, 31)) +>_.first : Symbol(Underscore.Static.first, Decl(underscoreTest1_underscore.ts, 497, 45), Decl(underscoreTest1_underscore.ts, 499, 31)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>first : Symbol(Underscore.Static.first, Decl(underscoreTest1_underscore.ts, 497, 45), Decl(underscoreTest1_underscore.ts, 499, 31)) _.initial([5, 4, 3, 2, 1]); ->_.initial : Symbol(Underscore.Static.initial, Decl(underscoreTest1_underscore.ts, 503, 47), Decl(underscoreTest1_underscore.ts, 505, 33)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->initial : Symbol(Underscore.Static.initial, Decl(underscoreTest1_underscore.ts, 503, 47), Decl(underscoreTest1_underscore.ts, 505, 33)) +>_.initial : Symbol(Underscore.Static.initial, Decl(underscoreTest1_underscore.ts, 504, 47), Decl(underscoreTest1_underscore.ts, 506, 33)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>initial : Symbol(Underscore.Static.initial, Decl(underscoreTest1_underscore.ts, 504, 47), Decl(underscoreTest1_underscore.ts, 506, 33)) _.last([5, 4, 3, 2, 1]); ->_.last : Symbol(Underscore.Static.last, Decl(underscoreTest1_underscore.ts, 506, 50), Decl(underscoreTest1_underscore.ts, 508, 30)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->last : Symbol(Underscore.Static.last, Decl(underscoreTest1_underscore.ts, 506, 50), Decl(underscoreTest1_underscore.ts, 508, 30)) +>_.last : Symbol(Underscore.Static.last, Decl(underscoreTest1_underscore.ts, 507, 50), Decl(underscoreTest1_underscore.ts, 509, 30)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>last : Symbol(Underscore.Static.last, Decl(underscoreTest1_underscore.ts, 507, 50), Decl(underscoreTest1_underscore.ts, 509, 30)) _.rest([5, 4, 3, 2, 1]); ->_.rest : Symbol(Underscore.Static.rest, Decl(underscoreTest1_underscore.ts, 509, 47)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->rest : Symbol(Underscore.Static.rest, Decl(underscoreTest1_underscore.ts, 509, 47)) +>_.rest : Symbol(Underscore.Static.rest, Decl(underscoreTest1_underscore.ts, 510, 47)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>rest : Symbol(Underscore.Static.rest, Decl(underscoreTest1_underscore.ts, 510, 47)) _.compact([0, 1, false, 2, '', 3]); ->_.compact : Symbol(Underscore.Static.compact, Decl(underscoreTest1_underscore.ts, 511, 48)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->compact : Symbol(Underscore.Static.compact, Decl(underscoreTest1_underscore.ts, 511, 48)) +>_.compact : Symbol(Underscore.Static.compact, Decl(underscoreTest1_underscore.ts, 512, 48)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>compact : Symbol(Underscore.Static.compact, Decl(underscoreTest1_underscore.ts, 512, 48)) _.flatten([1, 2, 3, 4]); ->_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) +>_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) _.flatten([1, [2]]); ->_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) +>_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) // typescript doesn't like the elements being different _.flatten([1, [2], [3, [[4]]]]); ->_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) +>_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) _.flatten([1, [2], [3, [[4]]]], true); ->_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 513, 35), Decl(underscoreTest1_underscore.ts, 515, 37)) +>_.flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>flatten : Symbol(Underscore.Static.flatten, Decl(underscoreTest1_underscore.ts, 514, 35), Decl(underscoreTest1_underscore.ts, 516, 37)) _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ->_.without : Symbol(Underscore.Static.without, Decl(underscoreTest1_underscore.ts, 516, 57)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->without : Symbol(Underscore.Static.without, Decl(underscoreTest1_underscore.ts, 516, 57)) +>_.without : Symbol(Underscore.Static.without, Decl(underscoreTest1_underscore.ts, 517, 57)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>without : Symbol(Underscore.Static.without, Decl(underscoreTest1_underscore.ts, 517, 57)) _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ->_.union : Symbol(Underscore.Static.union, Decl(underscoreTest1_underscore.ts, 518, 51)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->union : Symbol(Underscore.Static.union, Decl(underscoreTest1_underscore.ts, 518, 51)) +>_.union : Symbol(Underscore.Static.union, Decl(underscoreTest1_underscore.ts, 519, 51)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>union : Symbol(Underscore.Static.union, Decl(underscoreTest1_underscore.ts, 519, 51)) _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ->_.intersection : Symbol(Underscore.Static.intersection, Decl(underscoreTest1_underscore.ts, 520, 40)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->intersection : Symbol(Underscore.Static.intersection, Decl(underscoreTest1_underscore.ts, 520, 40)) +>_.intersection : Symbol(Underscore.Static.intersection, Decl(underscoreTest1_underscore.ts, 521, 40)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>intersection : Symbol(Underscore.Static.intersection, Decl(underscoreTest1_underscore.ts, 521, 40)) _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ->_.difference : Symbol(Underscore.Static.difference, Decl(underscoreTest1_underscore.ts, 522, 47)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->difference : Symbol(Underscore.Static.difference, Decl(underscoreTest1_underscore.ts, 522, 47)) +>_.difference : Symbol(Underscore.Static.difference, Decl(underscoreTest1_underscore.ts, 523, 47)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>difference : Symbol(Underscore.Static.difference, Decl(underscoreTest1_underscore.ts, 523, 47)) _.uniq([1, 2, 1, 3, 1, 4]); ->_.uniq : Symbol(Underscore.Static.uniq, Decl(underscoreTest1_underscore.ts, 524, 56), Decl(underscoreTest1_underscore.ts, 526, 52)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->uniq : Symbol(Underscore.Static.uniq, Decl(underscoreTest1_underscore.ts, 524, 56), Decl(underscoreTest1_underscore.ts, 526, 52)) +>_.uniq : Symbol(Underscore.Static.uniq, Decl(underscoreTest1_underscore.ts, 525, 56), Decl(underscoreTest1_underscore.ts, 527, 52)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>uniq : Symbol(Underscore.Static.uniq, Decl(underscoreTest1_underscore.ts, 525, 56), Decl(underscoreTest1_underscore.ts, 527, 52)) _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ->_.zip : Symbol(Underscore.Static.zip, Decl(underscoreTest1_underscore.ts, 529, 97), Decl(underscoreTest1_underscore.ts, 531, 58), Decl(underscoreTest1_underscore.ts, 532, 76), Decl(underscoreTest1_underscore.ts, 533, 94)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->zip : Symbol(Underscore.Static.zip, Decl(underscoreTest1_underscore.ts, 529, 97), Decl(underscoreTest1_underscore.ts, 531, 58), Decl(underscoreTest1_underscore.ts, 532, 76), Decl(underscoreTest1_underscore.ts, 533, 94)) +>_.zip : Symbol(Underscore.Static.zip, Decl(underscoreTest1_underscore.ts, 530, 97), Decl(underscoreTest1_underscore.ts, 532, 58), Decl(underscoreTest1_underscore.ts, 533, 76), Decl(underscoreTest1_underscore.ts, 534, 94)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>zip : Symbol(Underscore.Static.zip, Decl(underscoreTest1_underscore.ts, 530, 97), Decl(underscoreTest1_underscore.ts, 532, 58), Decl(underscoreTest1_underscore.ts, 533, 76), Decl(underscoreTest1_underscore.ts, 534, 94)) _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ->_.object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 534, 41), Decl(underscoreTest1_underscore.ts, 536, 35)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 534, 41), Decl(underscoreTest1_underscore.ts, 536, 35)) +>_.object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 535, 41), Decl(underscoreTest1_underscore.ts, 537, 35)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 535, 41), Decl(underscoreTest1_underscore.ts, 537, 35)) _.object([['moe', 30], ['larry', 40], ['curly', 50]]); ->_.object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 534, 41), Decl(underscoreTest1_underscore.ts, 536, 35)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 534, 41), Decl(underscoreTest1_underscore.ts, 536, 35)) +>_.object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 535, 41), Decl(underscoreTest1_underscore.ts, 537, 35)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>object : Symbol(Underscore.Static.object, Decl(underscoreTest1_underscore.ts, 535, 41), Decl(underscoreTest1_underscore.ts, 537, 35)) _.indexOf([1, 2, 3], 2); ->_.indexOf : Symbol(Underscore.Static.indexOf, Decl(underscoreTest1_underscore.ts, 537, 51)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->indexOf : Symbol(Underscore.Static.indexOf, Decl(underscoreTest1_underscore.ts, 537, 51)) +>_.indexOf : Symbol(Underscore.Static.indexOf, Decl(underscoreTest1_underscore.ts, 538, 51)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>indexOf : Symbol(Underscore.Static.indexOf, Decl(underscoreTest1_underscore.ts, 538, 51)) _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); ->_.lastIndexOf : Symbol(Underscore.Static.lastIndexOf, Decl(underscoreTest1_underscore.ts, 539, 68)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->lastIndexOf : Symbol(Underscore.Static.lastIndexOf, Decl(underscoreTest1_underscore.ts, 539, 68)) +>_.lastIndexOf : Symbol(Underscore.Static.lastIndexOf, Decl(underscoreTest1_underscore.ts, 540, 68)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>lastIndexOf : Symbol(Underscore.Static.lastIndexOf, Decl(underscoreTest1_underscore.ts, 540, 68)) _.sortedIndex([10, 20, 30, 40, 50], 35); ->_.sortedIndex : Symbol(Underscore.Static.sortedIndex, Decl(underscoreTest1_underscore.ts, 541, 72), Decl(underscoreTest1_underscore.ts, 543, 72)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->sortedIndex : Symbol(Underscore.Static.sortedIndex, Decl(underscoreTest1_underscore.ts, 541, 72), Decl(underscoreTest1_underscore.ts, 543, 72)) +>_.sortedIndex : Symbol(Underscore.Static.sortedIndex, Decl(underscoreTest1_underscore.ts, 542, 72), Decl(underscoreTest1_underscore.ts, 544, 72)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>sortedIndex : Symbol(Underscore.Static.sortedIndex, Decl(underscoreTest1_underscore.ts, 542, 72), Decl(underscoreTest1_underscore.ts, 544, 72)) _.range(10); ->_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) +>_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) _.range(1, 11); ->_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) +>_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) _.range(0, 30, 5); ->_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) +>_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) _.range(0, 30, 5); ->_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) +>_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) _.range(0); ->_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 544, 94), Decl(underscoreTest1_underscore.ts, 546, 38)) +>_.range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>range : Symbol(Underscore.Static.range, Decl(underscoreTest1_underscore.ts, 545, 94), Decl(underscoreTest1_underscore.ts, 547, 38)) /////////////////////////////////////////////////////////////////////////////////////// @@ -377,9 +377,9 @@ var func = function (greeting) { return greeting + ': ' + this.name }; // instead of the newly returned _bind => func type. var func2 = _.bind(func, { name: 'moe' }, 'hi'); >func2 : Symbol(func2, Decl(underscoreTest1_underscoreTests.ts, 93, 3)) ->_.bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 547, 68), Decl(underscoreTest1_underscore.ts, 549, 58)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 547, 68), Decl(underscoreTest1_underscore.ts, 549, 58)) +>_.bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 548, 68), Decl(underscoreTest1_underscore.ts, 550, 58)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 548, 68), Decl(underscoreTest1_underscore.ts, 550, 58)) >func : Symbol(func, Decl(underscoreTest1_underscoreTests.ts, 90, 3)) >name : Symbol(name, Decl(underscoreTest1_underscoreTests.ts, 93, 26)) @@ -402,9 +402,9 @@ var buttonView = { }; _.bindAll(buttonView); ->_.bindAll : Symbol(Underscore.Static.bindAll, Decl(underscoreTest1_underscore.ts, 550, 68)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->bindAll : Symbol(Underscore.Static.bindAll, Decl(underscoreTest1_underscore.ts, 550, 68)) +>_.bindAll : Symbol(Underscore.Static.bindAll, Decl(underscoreTest1_underscore.ts, 551, 68)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>bindAll : Symbol(Underscore.Static.bindAll, Decl(underscoreTest1_underscore.ts, 551, 68)) >buttonView : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 3)) $('#underscore_button').bind('click', buttonView.onClick); @@ -415,9 +415,9 @@ $('#underscore_button').bind('click', buttonView.onClick); var fibonacci = _.memoize(function (n) { >fibonacci : Symbol(fibonacci, Decl(underscoreTest1_underscoreTests.ts, 104, 3)) ->_.memoize : Symbol(Underscore.Static.memoize, Decl(underscoreTest1_underscore.ts, 554, 58)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->memoize : Symbol(Underscore.Static.memoize, Decl(underscoreTest1_underscore.ts, 554, 58)) +>_.memoize : Symbol(Underscore.Static.memoize, Decl(underscoreTest1_underscore.ts, 555, 58)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>memoize : Symbol(Underscore.Static.memoize, Decl(underscoreTest1_underscore.ts, 555, 58)) >n : Symbol(n, Decl(underscoreTest1_underscoreTests.ts, 104, 36)) return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); @@ -432,23 +432,23 @@ var fibonacci = _.memoize(function (n) { var log = _.bind((message?: string, ...rest: string[]) => { }, Date); >log : Symbol(log, Decl(underscoreTest1_underscoreTests.ts, 108, 3)) ->_.bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 547, 68), Decl(underscoreTest1_underscore.ts, 549, 58)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 547, 68), Decl(underscoreTest1_underscore.ts, 549, 58)) +>_.bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 548, 68), Decl(underscoreTest1_underscore.ts, 550, 58)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>bind : Symbol(Underscore.Static.bind, Decl(underscoreTest1_underscore.ts, 548, 68), Decl(underscoreTest1_underscore.ts, 550, 58)) >message : Symbol(message, Decl(underscoreTest1_underscoreTests.ts, 108, 18)) >rest : Symbol(rest, Decl(underscoreTest1_underscoreTests.ts, 108, 35)) >Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) _.delay(log, 1000, 'logged later'); ->_.delay : Symbol(Underscore.Static.delay, Decl(underscoreTest1_underscore.ts, 556, 73)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->delay : Symbol(Underscore.Static.delay, Decl(underscoreTest1_underscore.ts, 556, 73)) +>_.delay : Symbol(Underscore.Static.delay, Decl(underscoreTest1_underscore.ts, 557, 73)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>delay : Symbol(Underscore.Static.delay, Decl(underscoreTest1_underscore.ts, 557, 73)) >log : Symbol(log, Decl(underscoreTest1_underscoreTests.ts, 108, 3)) _.defer(function () { alert('deferred'); }); ->_.defer : Symbol(Underscore.Static.defer, Decl(underscoreTest1_underscore.ts, 558, 68)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->defer : Symbol(Underscore.Static.defer, Decl(underscoreTest1_underscore.ts, 558, 68)) +>_.defer : Symbol(Underscore.Static.defer, Decl(underscoreTest1_underscore.ts, 559, 68)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>defer : Symbol(Underscore.Static.defer, Decl(underscoreTest1_underscore.ts, 559, 68)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) var updatePosition = () => alert('updating position...'); @@ -457,9 +457,9 @@ var updatePosition = () => alert('updating position...'); var throttled = _.throttle(updatePosition, 100); >throttled : Symbol(throttled, Decl(underscoreTest1_underscoreTests.ts, 114, 3)) ->_.throttle : Symbol(Underscore.Static.throttle, Decl(underscoreTest1_underscore.ts, 560, 54)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->throttle : Symbol(Underscore.Static.throttle, Decl(underscoreTest1_underscore.ts, 560, 54)) +>_.throttle : Symbol(Underscore.Static.throttle, Decl(underscoreTest1_underscore.ts, 561, 54)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>throttle : Symbol(Underscore.Static.throttle, Decl(underscoreTest1_underscore.ts, 561, 54)) >updatePosition : Symbol(updatePosition, Decl(underscoreTest1_underscoreTests.ts, 113, 3)) $(null).scroll(throttled); @@ -472,9 +472,9 @@ var calculateLayout = () => alert('calculating layout...'); var lazyLayout = _.debounce(calculateLayout, 300); >lazyLayout : Symbol(lazyLayout, Decl(underscoreTest1_underscoreTests.ts, 118, 3)) ->_.debounce : Symbol(Underscore.Static.debounce, Decl(underscoreTest1_underscore.ts, 562, 63)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->debounce : Symbol(Underscore.Static.debounce, Decl(underscoreTest1_underscore.ts, 562, 63)) +>_.debounce : Symbol(Underscore.Static.debounce, Decl(underscoreTest1_underscore.ts, 563, 63)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>debounce : Symbol(Underscore.Static.debounce, Decl(underscoreTest1_underscore.ts, 563, 63)) >calculateLayout : Symbol(calculateLayout, Decl(underscoreTest1_underscoreTests.ts, 117, 3)) $(null).resize(lazyLayout); @@ -487,9 +487,9 @@ var createApplication = () => alert('creating application...'); var initialize = _.once(createApplication); >initialize : Symbol(initialize, Decl(underscoreTest1_underscoreTests.ts, 122, 3)) ->_.once : Symbol(Underscore.Static.once, Decl(underscoreTest1_underscore.ts, 564, 84)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->once : Symbol(Underscore.Static.once, Decl(underscoreTest1_underscore.ts, 564, 84)) +>_.once : Symbol(Underscore.Static.once, Decl(underscoreTest1_underscore.ts, 565, 84)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>once : Symbol(Underscore.Static.once, Decl(underscoreTest1_underscore.ts, 565, 84)) >createApplication : Symbol(createApplication, Decl(underscoreTest1_underscoreTests.ts, 121, 3)) initialize(); @@ -507,18 +507,18 @@ var render = () => alert("rendering..."); var renderNotes = _.after(notes.length, render); >renderNotes : Symbol(renderNotes, Decl(underscoreTest1_underscoreTests.ts, 128, 3)) ->_.after : Symbol(Underscore.Static.after, Decl(underscoreTest1_underscore.ts, 566, 45)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->after : Symbol(Underscore.Static.after, Decl(underscoreTest1_underscore.ts, 566, 45)) +>_.after : Symbol(Underscore.Static.after, Decl(underscoreTest1_underscore.ts, 567, 45)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>after : Symbol(Underscore.Static.after, Decl(underscoreTest1_underscore.ts, 567, 45)) >notes.length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20)) >notes : Symbol(notes, Decl(underscoreTest1_underscoreTests.ts, 126, 3)) >length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20)) >render : Symbol(render, Decl(underscoreTest1_underscoreTests.ts, 127, 3)) _.each(notes, (note) => note.asyncSave({ success: renderNotes })); ->_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 394, 43), Decl(underscoreTest1_underscore.ts, 396, 77)) +>_.each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>each : Symbol(Underscore.Static.each, Decl(underscoreTest1_underscore.ts, 395, 43), Decl(underscoreTest1_underscore.ts, 397, 77)) >notes : Symbol(notes, Decl(underscoreTest1_underscoreTests.ts, 126, 3)) >note : Symbol(note, Decl(underscoreTest1_underscoreTests.ts, 129, 15)) >note : Symbol(note, Decl(underscoreTest1_underscoreTests.ts, 129, 15)) @@ -532,9 +532,9 @@ var hello = function (name) { return "hello: " + name; }; hello = _.wrap(hello, (func, arg) => { return "before, " + func(arg) + ", after"; }); >hello : Symbol(hello, Decl(underscoreTest1_underscoreTests.ts, 131, 3)) ->_.wrap : Symbol(Underscore.Static.wrap, Decl(underscoreTest1_underscore.ts, 568, 61)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->wrap : Symbol(Underscore.Static.wrap, Decl(underscoreTest1_underscore.ts, 568, 61)) +>_.wrap : Symbol(Underscore.Static.wrap, Decl(underscoreTest1_underscore.ts, 569, 61)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>wrap : Symbol(Underscore.Static.wrap, Decl(underscoreTest1_underscore.ts, 569, 61)) >hello : Symbol(hello, Decl(underscoreTest1_underscoreTests.ts, 131, 3)) >func : Symbol(func, Decl(underscoreTest1_underscoreTests.ts, 132, 23)) >arg : Symbol(arg, Decl(underscoreTest1_underscoreTests.ts, 132, 28)) @@ -556,9 +556,9 @@ var exclaim = function (statement) { return statement + "!"; }; var welcome = _.compose(exclaim, greet); >welcome : Symbol(welcome, Decl(underscoreTest1_underscoreTests.ts, 137, 3)) ->_.compose : Symbol(Underscore.Static.compose, Decl(underscoreTest1_underscore.ts, 570, 88)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->compose : Symbol(Underscore.Static.compose, Decl(underscoreTest1_underscore.ts, 570, 88)) +>_.compose : Symbol(Underscore.Static.compose, Decl(underscoreTest1_underscore.ts, 571, 88)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>compose : Symbol(Underscore.Static.compose, Decl(underscoreTest1_underscore.ts, 571, 88)) >exclaim : Symbol(exclaim, Decl(underscoreTest1_underscoreTests.ts, 136, 3)) >greet : Symbol(greet, Decl(underscoreTest1_underscoreTests.ts, 135, 3)) @@ -568,62 +568,62 @@ welcome('moe'); /////////////////////////////////////////////////////////////////////////////////////// _.keys({ one: 1, two: 2, three: 3 }); ->_.keys : Symbol(Underscore.Static.keys, Decl(underscoreTest1_underscore.ts, 572, 48)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->keys : Symbol(Underscore.Static.keys, Decl(underscoreTest1_underscore.ts, 572, 48)) +>_.keys : Symbol(Underscore.Static.keys, Decl(underscoreTest1_underscore.ts, 573, 48)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>keys : Symbol(Underscore.Static.keys, Decl(underscoreTest1_underscore.ts, 573, 48)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 142, 8)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 142, 16)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 142, 24)) _.values({ one: 1, two: 2, three: 3 }); ->_.values : Symbol(Underscore.Static.values, Decl(underscoreTest1_underscore.ts, 574, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->values : Symbol(Underscore.Static.values, Decl(underscoreTest1_underscore.ts, 574, 36)) +>_.values : Symbol(Underscore.Static.values, Decl(underscoreTest1_underscore.ts, 575, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>values : Symbol(Underscore.Static.values, Decl(underscoreTest1_underscore.ts, 575, 36)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 143, 10)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 143, 18)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 143, 26)) _.pairs({ one: 1, two: 2, three: 3 }); ->_.pairs : Symbol(Underscore.Static.pairs, Decl(underscoreTest1_underscore.ts, 576, 35)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->pairs : Symbol(Underscore.Static.pairs, Decl(underscoreTest1_underscore.ts, 576, 35)) +>_.pairs : Symbol(Underscore.Static.pairs, Decl(underscoreTest1_underscore.ts, 577, 35)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>pairs : Symbol(Underscore.Static.pairs, Decl(underscoreTest1_underscore.ts, 577, 35)) >one : Symbol(one, Decl(underscoreTest1_underscoreTests.ts, 144, 9)) >two : Symbol(two, Decl(underscoreTest1_underscoreTests.ts, 144, 17)) >three : Symbol(three, Decl(underscoreTest1_underscoreTests.ts, 144, 25)) _.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" }); ->_.invert : Symbol(Underscore.Static.invert, Decl(underscoreTest1_underscore.ts, 578, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->invert : Symbol(Underscore.Static.invert, Decl(underscoreTest1_underscore.ts, 578, 36)) +>_.invert : Symbol(Underscore.Static.invert, Decl(underscoreTest1_underscore.ts, 579, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>invert : Symbol(Underscore.Static.invert, Decl(underscoreTest1_underscore.ts, 579, 36)) >Moe : Symbol(Moe, Decl(underscoreTest1_underscoreTests.ts, 145, 10)) >Larry : Symbol(Larry, Decl(underscoreTest1_underscoreTests.ts, 145, 24)) >Curly : Symbol(Curly, Decl(underscoreTest1_underscoreTests.ts, 145, 40)) _.functions(_); ->_.functions : Symbol(Underscore.Static.functions, Decl(underscoreTest1_underscore.ts, 580, 33)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->functions : Symbol(Underscore.Static.functions, Decl(underscoreTest1_underscore.ts, 580, 33)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) +>_.functions : Symbol(Underscore.Static.functions, Decl(underscoreTest1_underscore.ts, 581, 33)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>functions : Symbol(Underscore.Static.functions, Decl(underscoreTest1_underscore.ts, 581, 33)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) _.extend({ name: 'moe' }, { age: 50 }); ->_.extend : Symbol(Underscore.Static.extend, Decl(underscoreTest1_underscore.ts, 583, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->extend : Symbol(Underscore.Static.extend, Decl(underscoreTest1_underscore.ts, 583, 39)) +>_.extend : Symbol(Underscore.Static.extend, Decl(underscoreTest1_underscore.ts, 584, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>extend : Symbol(Underscore.Static.extend, Decl(underscoreTest1_underscore.ts, 584, 39)) >name : Symbol(name, Decl(underscoreTest1_underscoreTests.ts, 147, 10)) >age : Symbol(age, Decl(underscoreTest1_underscoreTests.ts, 147, 27)) _.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); ->_.pick : Symbol(Underscore.Static.pick, Decl(underscoreTest1_underscore.ts, 585, 56)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->pick : Symbol(Underscore.Static.pick, Decl(underscoreTest1_underscore.ts, 585, 56)) +>_.pick : Symbol(Underscore.Static.pick, Decl(underscoreTest1_underscore.ts, 586, 56)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>pick : Symbol(Underscore.Static.pick, Decl(underscoreTest1_underscore.ts, 586, 56)) >name : Symbol(name, Decl(underscoreTest1_underscoreTests.ts, 148, 8)) >age : Symbol(age, Decl(underscoreTest1_underscoreTests.ts, 148, 21)) >userid : Symbol(userid, Decl(underscoreTest1_underscoreTests.ts, 148, 30)) _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'userid'); ->_.omit : Symbol(Underscore.Static.omit, Decl(underscoreTest1_underscore.ts, 587, 49)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->omit : Symbol(Underscore.Static.omit, Decl(underscoreTest1_underscore.ts, 587, 49)) +>_.omit : Symbol(Underscore.Static.omit, Decl(underscoreTest1_underscore.ts, 588, 49)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>omit : Symbol(Underscore.Static.omit, Decl(underscoreTest1_underscore.ts, 588, 49)) >name : Symbol(name, Decl(underscoreTest1_underscoreTests.ts, 149, 8)) >age : Symbol(age, Decl(underscoreTest1_underscoreTests.ts, 149, 21)) >userid : Symbol(userid, Decl(underscoreTest1_underscoreTests.ts, 149, 30)) @@ -633,17 +633,17 @@ var iceCream = { flavor: "chocolate" }; >flavor : Symbol(flavor, Decl(underscoreTest1_underscoreTests.ts, 151, 16)) _.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }); ->_.defaults : Symbol(Underscore.Static.defaults, Decl(underscoreTest1_underscore.ts, 589, 49)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->defaults : Symbol(Underscore.Static.defaults, Decl(underscoreTest1_underscore.ts, 589, 49)) +>_.defaults : Symbol(Underscore.Static.defaults, Decl(underscoreTest1_underscore.ts, 590, 49)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>defaults : Symbol(Underscore.Static.defaults, Decl(underscoreTest1_underscore.ts, 590, 49)) >iceCream : Symbol(iceCream, Decl(underscoreTest1_underscoreTests.ts, 151, 3)) >flavor : Symbol(flavor, Decl(underscoreTest1_underscoreTests.ts, 152, 22)) >sprinkles : Symbol(sprinkles, Decl(underscoreTest1_underscoreTests.ts, 152, 41)) _.clone({ name: 'moe' }); ->_.clone : Symbol(Underscore.Static.clone, Decl(underscoreTest1_underscore.ts, 591, 54)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->clone : Symbol(Underscore.Static.clone, Decl(underscoreTest1_underscore.ts, 591, 54)) +>_.clone : Symbol(Underscore.Static.clone, Decl(underscoreTest1_underscore.ts, 592, 54)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>clone : Symbol(Underscore.Static.clone, Decl(underscoreTest1_underscore.ts, 592, 54)) >name : Symbol(name, Decl(underscoreTest1_underscoreTests.ts, 154, 9)) _.chain([1, 2, 3, 200]) @@ -651,9 +651,9 @@ _.chain([1, 2, 3, 200]) >_.chain([1, 2, 3, 200]) .filter(function (num) { return num % 2 == 0; }) .tap(alert) .map : Symbol(Underscore.ChainedArray.map, Decl(underscoreTest1_underscore.ts, 240, 81)) >_.chain([1, 2, 3, 200]) .filter(function (num) { return num % 2 == 0; }) .tap : Symbol(Underscore.ChainedArray.tap, Decl(underscoreTest1_underscore.ts, 325, 33)) >_.chain([1, 2, 3, 200]) .filter : Symbol(Underscore.ChainedArray.filter, Decl(underscoreTest1_underscore.ts, 254, 80)) ->_.chain : Symbol(Underscore.Static.chain, Decl(underscoreTest1_underscore.ts, 390, 38), Decl(underscoreTest1_underscore.ts, 392, 45), Decl(underscoreTest1_underscore.ts, 393, 60)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->chain : Symbol(Underscore.Static.chain, Decl(underscoreTest1_underscore.ts, 390, 38), Decl(underscoreTest1_underscore.ts, 392, 45), Decl(underscoreTest1_underscore.ts, 393, 60)) +>_.chain : Symbol(Underscore.Static.chain, Decl(underscoreTest1_underscore.ts, 391, 38), Decl(underscoreTest1_underscore.ts, 393, 45), Decl(underscoreTest1_underscore.ts, 394, 60)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>chain : Symbol(Underscore.Static.chain, Decl(underscoreTest1_underscore.ts, 391, 38), Decl(underscoreTest1_underscore.ts, 393, 45), Decl(underscoreTest1_underscore.ts, 394, 60)) .filter(function (num) { return num % 2 == 0; }) >filter : Symbol(Underscore.ChainedArray.filter, Decl(underscoreTest1_underscore.ts, 254, 80)) @@ -674,9 +674,9 @@ _.chain([1, 2, 3, 200]) >value : Symbol(Underscore.ChainedObject.value, Decl(underscoreTest1_underscore.ts, 234, 46)) _.has({ a: 1, b: 2, c: 3 }, "b"); ->_.has : Symbol(Underscore.Static.has, Decl(underscoreTest1_underscore.ts, 595, 63)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->has : Symbol(Underscore.Static.has, Decl(underscoreTest1_underscore.ts, 595, 63)) +>_.has : Symbol(Underscore.Static.has, Decl(underscoreTest1_underscore.ts, 596, 63)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>has : Symbol(Underscore.Static.has, Decl(underscoreTest1_underscore.ts, 596, 63)) >a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 162, 7)) >b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 162, 13)) >c : Symbol(c, Decl(underscoreTest1_underscoreTests.ts, 162, 19)) @@ -696,103 +696,103 @@ moe == clone; >clone : Symbol(clone, Decl(underscoreTest1_underscoreTests.ts, 165, 3)) _.isEqual(moe, clone); ->_.isEqual : Symbol(Underscore.Static.isEqual, Decl(underscoreTest1_underscore.ts, 597, 47)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isEqual : Symbol(Underscore.Static.isEqual, Decl(underscoreTest1_underscore.ts, 597, 47)) +>_.isEqual : Symbol(Underscore.Static.isEqual, Decl(underscoreTest1_underscore.ts, 598, 47)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isEqual : Symbol(Underscore.Static.isEqual, Decl(underscoreTest1_underscore.ts, 598, 47)) >moe : Symbol(moe, Decl(underscoreTest1_underscoreTests.ts, 164, 3)) >clone : Symbol(clone, Decl(underscoreTest1_underscoreTests.ts, 165, 3)) _.isEmpty([1, 2, 3]); ->_.isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 599, 49)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 599, 49)) +>_.isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 600, 49)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 600, 49)) _.isEmpty({}); ->_.isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 599, 49)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 599, 49)) +>_.isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 600, 49)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isEmpty : Symbol(Underscore.Static.isEmpty, Decl(underscoreTest1_underscore.ts, 600, 49)) _.isElement($('body')[0]); ->_.isElement : Symbol(Underscore.Static.isElement, Decl(underscoreTest1_underscore.ts, 601, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isElement : Symbol(Underscore.Static.isElement, Decl(underscoreTest1_underscore.ts, 601, 38)) +>_.isElement : Symbol(Underscore.Static.isElement, Decl(underscoreTest1_underscore.ts, 602, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isElement : Symbol(Underscore.Static.isElement, Decl(underscoreTest1_underscore.ts, 602, 38)) >$ : Symbol($, Decl(underscoreTest1_underscoreTests.ts, 2, 11)) (function () { return _.isArray(arguments); })(); ->_.isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 602, 40)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 602, 40)) +>_.isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 603, 40)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 603, 40)) >arguments : Symbol(arguments) _.isArray([1, 2, 3]); ->_.isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 602, 40)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 602, 40)) +>_.isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 603, 40)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isArray : Symbol(Underscore.Static.isArray, Decl(underscoreTest1_underscore.ts, 603, 40)) _.isObject({}); ->_.isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 603, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 603, 38)) +>_.isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 604, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 604, 38)) _.isObject(1); ->_.isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 603, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 603, 38)) +>_.isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 604, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isObject : Symbol(Underscore.Static.isObject, Decl(underscoreTest1_underscore.ts, 604, 38)) // (() => { return _.isArguments(arguments); })(1, 2, 3); _.isArguments([1, 2, 3]); ->_.isArguments : Symbol(Underscore.Static.isArguments, Decl(underscoreTest1_underscore.ts, 604, 38)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isArguments : Symbol(Underscore.Static.isArguments, Decl(underscoreTest1_underscore.ts, 604, 38)) +>_.isArguments : Symbol(Underscore.Static.isArguments, Decl(underscoreTest1_underscore.ts, 605, 38)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isArguments : Symbol(Underscore.Static.isArguments, Decl(underscoreTest1_underscore.ts, 605, 38)) _.isFunction(alert); ->_.isFunction : Symbol(Underscore.Static.isFunction, Decl(underscoreTest1_underscore.ts, 605, 42)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isFunction : Symbol(Underscore.Static.isFunction, Decl(underscoreTest1_underscore.ts, 605, 42)) +>_.isFunction : Symbol(Underscore.Static.isFunction, Decl(underscoreTest1_underscore.ts, 606, 42)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isFunction : Symbol(Underscore.Static.isFunction, Decl(underscoreTest1_underscore.ts, 606, 42)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) _.isString("moe"); ->_.isString : Symbol(Underscore.Static.isString, Decl(underscoreTest1_underscore.ts, 606, 41)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isString : Symbol(Underscore.Static.isString, Decl(underscoreTest1_underscore.ts, 606, 41)) +>_.isString : Symbol(Underscore.Static.isString, Decl(underscoreTest1_underscore.ts, 607, 41)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isString : Symbol(Underscore.Static.isString, Decl(underscoreTest1_underscore.ts, 607, 41)) _.isNumber(8.4 * 5); ->_.isNumber : Symbol(Underscore.Static.isNumber, Decl(underscoreTest1_underscore.ts, 607, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isNumber : Symbol(Underscore.Static.isNumber, Decl(underscoreTest1_underscore.ts, 607, 39)) +>_.isNumber : Symbol(Underscore.Static.isNumber, Decl(underscoreTest1_underscore.ts, 608, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isNumber : Symbol(Underscore.Static.isNumber, Decl(underscoreTest1_underscore.ts, 608, 39)) _.isFinite(-101); ->_.isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 608, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 608, 39)) +>_.isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 609, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 609, 39)) _.isFinite(-Infinity); ->_.isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 608, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 608, 39)) +>_.isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 609, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isFinite : Symbol(Underscore.Static.isFinite, Decl(underscoreTest1_underscore.ts, 609, 39)) >Infinity : Symbol(Infinity, Decl(lib.d.ts, 22, 11)) _.isBoolean(null); ->_.isBoolean : Symbol(Underscore.Static.isBoolean, Decl(underscoreTest1_underscore.ts, 609, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isBoolean : Symbol(Underscore.Static.isBoolean, Decl(underscoreTest1_underscore.ts, 609, 39)) +>_.isBoolean : Symbol(Underscore.Static.isBoolean, Decl(underscoreTest1_underscore.ts, 610, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isBoolean : Symbol(Underscore.Static.isBoolean, Decl(underscoreTest1_underscore.ts, 610, 39)) _.isDate(new Date()); ->_.isDate : Symbol(Underscore.Static.isDate, Decl(underscoreTest1_underscore.ts, 610, 40)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isDate : Symbol(Underscore.Static.isDate, Decl(underscoreTest1_underscore.ts, 610, 40)) +>_.isDate : Symbol(Underscore.Static.isDate, Decl(underscoreTest1_underscore.ts, 611, 40)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isDate : Symbol(Underscore.Static.isDate, Decl(underscoreTest1_underscore.ts, 611, 40)) >Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) _.isRegExp(/moe/); ->_.isRegExp : Symbol(Underscore.Static.isRegExp, Decl(underscoreTest1_underscore.ts, 611, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isRegExp : Symbol(Underscore.Static.isRegExp, Decl(underscoreTest1_underscore.ts, 611, 37)) +>_.isRegExp : Symbol(Underscore.Static.isRegExp, Decl(underscoreTest1_underscore.ts, 612, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isRegExp : Symbol(Underscore.Static.isRegExp, Decl(underscoreTest1_underscore.ts, 612, 37)) _.isNaN(NaN); ->_.isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 612, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 612, 39)) +>_.isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 613, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 613, 39)) >NaN : Symbol(NaN, Decl(lib.d.ts, 21, 11)) isNaN(undefined); @@ -800,34 +800,34 @@ isNaN(undefined); >undefined : Symbol(undefined) _.isNaN(undefined); ->_.isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 612, 39)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 612, 39)) +>_.isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 613, 39)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isNaN : Symbol(Underscore.Static.isNaN, Decl(underscoreTest1_underscore.ts, 613, 39)) >undefined : Symbol(undefined) _.isNull(null); ->_.isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 613, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 613, 36)) +>_.isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 614, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 614, 36)) _.isNull(undefined); ->_.isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 613, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 613, 36)) +>_.isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 614, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isNull : Symbol(Underscore.Static.isNull, Decl(underscoreTest1_underscore.ts, 614, 36)) >undefined : Symbol(undefined) _.isUndefined((null).missingVariable); ->_.isUndefined : Symbol(Underscore.Static.isUndefined, Decl(underscoreTest1_underscore.ts, 614, 37)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->isUndefined : Symbol(Underscore.Static.isUndefined, Decl(underscoreTest1_underscore.ts, 614, 37)) +>_.isUndefined : Symbol(Underscore.Static.isUndefined, Decl(underscoreTest1_underscore.ts, 615, 37)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>isUndefined : Symbol(Underscore.Static.isUndefined, Decl(underscoreTest1_underscore.ts, 615, 37)) /////////////////////////////////////////////////////////////////////////////////////// var underscore = _.noConflict(); >underscore : Symbol(underscore, Decl(underscoreTest1_underscoreTests.ts, 211, 3)) ->_.noConflict : Symbol(Underscore.Static.noConflict, Decl(underscoreTest1_underscore.ts, 615, 41)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->noConflict : Symbol(Underscore.Static.noConflict, Decl(underscoreTest1_underscore.ts, 615, 41)) +>_.noConflict : Symbol(Underscore.Static.noConflict, Decl(underscoreTest1_underscore.ts, 616, 41)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>noConflict : Symbol(Underscore.Static.noConflict, Decl(underscoreTest1_underscore.ts, 616, 41)) var moe2 = { name: 'moe' }; >moe2 : Symbol(moe2, Decl(underscoreTest1_underscoreTests.ts, 213, 3)) @@ -835,31 +835,31 @@ var moe2 = { name: 'moe' }; moe2 === _.identity(moe); >moe2 : Symbol(moe2, Decl(underscoreTest1_underscoreTests.ts, 213, 3)) ->_.identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 617, 29)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 617, 29)) +>_.identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 618, 29)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>identity : Symbol(Underscore.Static.identity, Decl(underscoreTest1_underscore.ts, 618, 29)) >moe : Symbol(moe, Decl(underscoreTest1_underscoreTests.ts, 164, 3)) var genie; >genie : Symbol(genie, Decl(underscoreTest1_underscoreTests.ts, 216, 3)) _.times(3, function (n) { genie.grantWishNumber(n); }); ->_.times : Symbol(Underscore.Static.times, Decl(underscoreTest1_underscore.ts, 619, 33)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->times : Symbol(Underscore.Static.times, Decl(underscoreTest1_underscore.ts, 619, 33)) +>_.times : Symbol(Underscore.Static.times, Decl(underscoreTest1_underscore.ts, 620, 33)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>times : Symbol(Underscore.Static.times, Decl(underscoreTest1_underscore.ts, 620, 33)) >n : Symbol(n, Decl(underscoreTest1_underscoreTests.ts, 218, 21)) >genie : Symbol(genie, Decl(underscoreTest1_underscoreTests.ts, 216, 3)) >n : Symbol(n, Decl(underscoreTest1_underscoreTests.ts, 218, 21)) _.random(0, 100); ->_.random : Symbol(Underscore.Static.random, Decl(underscoreTest1_underscore.ts, 621, 79), Decl(underscoreTest1_underscore.ts, 623, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->random : Symbol(Underscore.Static.random, Decl(underscoreTest1_underscore.ts, 621, 79), Decl(underscoreTest1_underscore.ts, 623, 36)) +>_.random : Symbol(Underscore.Static.random, Decl(underscoreTest1_underscore.ts, 622, 79), Decl(underscoreTest1_underscore.ts, 624, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>random : Symbol(Underscore.Static.random, Decl(underscoreTest1_underscore.ts, 622, 79), Decl(underscoreTest1_underscore.ts, 624, 36)) _.mixin({ ->_.mixin : Symbol(Underscore.Static.mixin, Decl(underscoreTest1_underscore.ts, 624, 49)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->mixin : Symbol(Underscore.Static.mixin, Decl(underscoreTest1_underscore.ts, 624, 49)) +>_.mixin : Symbol(Underscore.Static.mixin, Decl(underscoreTest1_underscore.ts, 625, 49)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>mixin : Symbol(Underscore.Static.mixin, Decl(underscoreTest1_underscore.ts, 625, 49)) capitalize: function (string) { >capitalize : Symbol(capitalize, Decl(underscoreTest1_underscoreTests.ts, 222, 9)) @@ -871,17 +871,17 @@ _.mixin({ } }); (_("fabio")).capitalize(); ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) _.uniqueId('contact_'); ->_.uniqueId : Symbol(Underscore.Static.uniqueId, Decl(underscoreTest1_underscore.ts, 626, 33), Decl(underscoreTest1_underscore.ts, 628, 27)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->uniqueId : Symbol(Underscore.Static.uniqueId, Decl(underscoreTest1_underscore.ts, 626, 33), Decl(underscoreTest1_underscore.ts, 628, 27)) +>_.uniqueId : Symbol(Underscore.Static.uniqueId, Decl(underscoreTest1_underscore.ts, 627, 33), Decl(underscoreTest1_underscore.ts, 629, 27)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>uniqueId : Symbol(Underscore.Static.uniqueId, Decl(underscoreTest1_underscore.ts, 627, 33), Decl(underscoreTest1_underscore.ts, 629, 27)) _.escape('Curly, Larry & Moe'); ->_.escape : Symbol(Underscore.Static.escape, Decl(underscoreTest1_underscore.ts, 629, 41)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->escape : Symbol(Underscore.Static.escape, Decl(underscoreTest1_underscore.ts, 629, 41)) +>_.escape : Symbol(Underscore.Static.escape, Decl(underscoreTest1_underscore.ts, 630, 41)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>escape : Symbol(Underscore.Static.escape, Decl(underscoreTest1_underscore.ts, 630, 41)) var object = { cheese: 'crumpets', stuff: function () { return 'nonsense'; } }; >object : Symbol(object, Decl(underscoreTest1_underscoreTests.ts, 233, 3)) @@ -889,22 +889,22 @@ var object = { cheese: 'crumpets', stuff: function () { return 'nonsense'; } }; >stuff : Symbol(stuff, Decl(underscoreTest1_underscoreTests.ts, 233, 34)) _.result(object, 'cheese'); ->_.result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 633, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 633, 36)) +>_.result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 634, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 634, 36)) >object : Symbol(object, Decl(underscoreTest1_underscoreTests.ts, 233, 3)) _.result(object, 'stuff'); ->_.result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 633, 36)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 633, 36)) +>_.result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 634, 36)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>result : Symbol(Underscore.Static.result, Decl(underscoreTest1_underscore.ts, 634, 36)) >object : Symbol(object, Decl(underscoreTest1_underscoreTests.ts, 233, 3)) var compiled = _.template("hello: <%= name %>"); >compiled : Symbol(compiled, Decl(underscoreTest1_underscoreTests.ts, 238, 3)) ->_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) +>_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) compiled({ name: 'moe' }); >compiled : Symbol(compiled, Decl(underscoreTest1_underscoreTests.ts, 238, 3)) @@ -914,17 +914,17 @@ var list2 = "<% _.each(people, function(name) { %>
  • <%= name %>
  • <% }); % >list2 : Symbol(list2, Decl(underscoreTest1_underscoreTests.ts, 240, 3)) _.template(list2, { people: ['moe', 'curly', 'larry'] }); ->_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) +>_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) >list2 : Symbol(list2, Decl(underscoreTest1_underscoreTests.ts, 240, 3)) >people : Symbol(people, Decl(underscoreTest1_underscoreTests.ts, 241, 19)) var template = _.template("<%- value %>"); >template : Symbol(template, Decl(underscoreTest1_underscoreTests.ts, 242, 3)) ->_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) ->_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 644, 11)) ->template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 637, 43), Decl(underscoreTest1_underscore.ts, 639, 64)) +>_.template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) +>_ : Symbol(_, Decl(underscoreTest1_underscore.ts, 645, 11)) +>template : Symbol(Underscore.Static.template, Decl(underscoreTest1_underscore.ts, 638, 43), Decl(underscoreTest1_underscore.ts, 640, 64)) template({ value: '