diff --git a/Jakefile.js b/Jakefile.js index a0ec0d880fe..33ad46c8b58 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -361,7 +361,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca /*keepComments*/ true, /*noResolve*/ false, /*stripInternal*/ true, - /*callback*/ function () { + /*callback*/ function () { jake.cpR(servicesFile, nodePackageFile, {silent: true}); prependFile(copyright, standaloneDefinitionsFile); @@ -379,12 +379,12 @@ compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(se var lsslFile = path.join(builtLocalDirectory, "tslssl.js"); compileFile( - lsslFile, - languageServiceLibrarySources, + lsslFile, + languageServiceLibrarySources, [builtLocalDirectory, copyright].concat(languageServiceLibrarySources), - /*prefixes*/ [copyright], - /*useBuiltCompiler*/ true, - /*noOutFile*/ false, + /*prefixes*/ [copyright], + /*useBuiltCompiler*/ true, + /*noOutFile*/ false, /*generateDeclarations*/ true); // Local target to build the language service server library @@ -488,7 +488,7 @@ var refTest262Baseline = path.join(internalTests, "baselines/test262/reference") desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); -function exec(cmd, completeHandler) { +function exec(cmd, completeHandler, errorHandler) { var ex = jake.createExec([cmd], {windowsVerbatimArguments: true}); // Add listeners for output and error ex.addListener("stdout", function(output) { @@ -504,8 +504,12 @@ function exec(cmd, completeHandler) { complete(); }); ex.addListener("error", function(e, status) { - fail("Process exited with code " + status); - }) + if(errorHandler) { + errorHandler(e, status); + } else { + fail("Process exited with code " + status); + } + }); ex.run(); } @@ -715,3 +719,23 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function }); ex.run(); }, { async: true }); + +desc("Updates the sublime plugin's tsserver"); +task("update-sublime", ["local", serverFile], function() { + jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); + jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); +}); + +// if the codebase were free of linter errors we could make jake runtests +// run this task automatically +desc("Runs tslint on the compiler sources"); +task("lint", [], function() { + for(var i in compilerSources) { + var f = compilerSources[i]; + var cmd = 'tslint -f ' + f; + exec(cmd, + function() { console.log('SUCCESS: No linter errors'); }, + function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n'); + }); + } +}, { async: true }); diff --git a/package.json b/package.json index d6a8f538b78..82ab734d6f1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "mocha": "latest", "chai": "latest", "browserify": "latest", - "istanbul": "latest" + "istanbul": "latest", + "tslint": "latest" }, "scripts": { "test": "jake runtests" diff --git a/scripts/errorCheck.ts b/scripts/errorCheck.ts index 77892cb8f0c..a5cb27417f1 100644 --- a/scripts/errorCheck.ts +++ b/scripts/errorCheck.ts @@ -4,84 +4,83 @@ let async = require('async'); let glob = require('glob'); fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => { - if (err) { - throw err; - } - - let messages = JSON.parse(data); - let keys = Object.keys(messages); - console.log('Loaded ' + keys.length + ' errors'); + if (err) { + throw err; + } - for (let k of keys) { - messages[k]['seen'] = false; - } + let messages = JSON.parse(data); + let keys = Object.keys(messages); + console.log('Loaded ' + keys.length + ' errors'); - let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; + for (let k of keys) { + messages[k]['seen'] = false; + } - let baseDir = 'tests/baselines/reference/'; - fs.readdir(baseDir, (err, files) => { - files = files.filter(f => f.indexOf('.errors.txt') > 0); - let tasks: Array<(callback: () => void) => void> = []; - files.forEach(f => tasks.push(done => { - fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { - if (err) throw err; + let errRegex = /\(\d+,\d+\): error TS([^:]+):/g; - let g: string[]; - while (g = errRegex.exec(baseline)) { - var errCode = +g[1]; - let msg = keys.filter(k => messages[k].code === errCode)[0]; - messages[msg]['seen'] = true; - } + let baseDir = 'tests/baselines/reference/'; + fs.readdir(baseDir, (err, files) => { + files = files.filter(f => f.indexOf('.errors.txt') > 0); + let tasks: Array<(callback: () => void) => void> = []; + files.forEach(f => tasks.push(done => { + fs.readFile(baseDir + f, 'utf-8', (err, baseline) => { + if (err) throw err; - done(); - }); - })); + let g: string[]; + while (g = errRegex.exec(baseline)) { + var errCode = +g[1]; + let msg = keys.filter(k => messages[k].code === errCode)[0]; + messages[msg]['seen'] = true; + } - async.parallelLimit(tasks, 25, done => { - console.log('== List of errors not present in baselines =='); - let count = 0; - for (let k of keys) { - if (messages[k]['seen'] !== true) { - console.log(k); - count++; - } - } - console.log(count + ' of ' + keys.length + ' errors are not in baselines'); - }); - }); + done(); + }); + })); + + async.parallelLimit(tasks, 25, done => { + console.log('== List of errors not present in baselines =='); + let count = 0; + for (let k of keys) { + if (messages[k]['seen'] !== true) { + console.log(k); + count++; + } + } + console.log(count + ' of ' + keys.length + ' errors are not in baselines'); + }); + }); }); fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => { - let errorRegexp = /\s(\w+): \{ code/g; - let errorNames: string[] = []; - let errMatch: string[]; - while (errMatch = errorRegexp.exec(data)) { - errorNames.push(errMatch[1]); - } + let errorRegexp = /\s(\w+): \{ code/g; + let errorNames: string[] = []; + let errMatch: string[]; + while (errMatch = errorRegexp.exec(data)) { + errorNames.push(errMatch[1]); + } - let allSrc: string = ''; - glob('./src/**/*.ts', {}, (err, files) => { - console.log('Reading ' + files.length + ' source files'); - for(let file of files) { - if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { - continue; - } + let allSrc: string = ''; + glob('./src/**/*.ts', {}, (err, files) => { + console.log('Reading ' + files.length + ' source files'); + for (let file of files) { + if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) { + continue; + } - let src = fs.readFileSync(file, 'utf-8'); - allSrc = allSrc + src; - } + let src = fs.readFileSync(file, 'utf-8'); + allSrc = allSrc + src; + } - console.log('Consumed ' + allSrc.length + ' characters of source'); + console.log('Consumed ' + allSrc.length + ' characters of source'); - let count = 0; - console.log('== List of errors not used in source ==') - for(let errName of errorNames) { - if (allSrc.indexOf(errName) < 0) { - console.log(errName); - count++; - } - } - console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); - }); + let count = 0; + console.log('== List of errors not used in source =='); + for (let errName of errorNames) { + if (allSrc.indexOf(errName) < 0) { + console.log(errName); + count++; + } + } + console.log(count + ' of ' + errorNames.length + ' errors are not used in source'); + }); }); - diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index e403ed994e5..e839d6d6c9a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -11,7 +11,7 @@ namespace ts { } export function getModuleInstanceState(node: Node): ModuleInstanceState { - // A module is uninstantiated if it contains only + // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) { return ModuleInstanceState.NonInstantiated; @@ -53,7 +53,7 @@ namespace ts { } const enum ContainerFlags { - // The current node is not a container, and no container manipulation should happen before + // The current node is not a container, and no container manipulation should happen before // recursing into it. None = 0, @@ -90,13 +90,13 @@ namespace ts { let lastContainer: Node; // If this file is an external module, then it is automatically in strict-mode according to - // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). let inStrictMode = !!file.externalModuleIndicator; let symbolCount = 0; let Symbol = objectAllocator.getSymbolConstructor(); - let classifiableNames: Map = {}; + let classifiableNames: Map = {}; if (!file.locals) { bind(file); @@ -173,6 +173,14 @@ namespace ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } + /** + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. + * @param symbolTable - The symbol table which node will be added to. + * @param parent - node's parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); @@ -181,15 +189,16 @@ namespace ts { let symbol: Symbol; if (name !== undefined) { + // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't - // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // give the new symbol any flags *yet*. This ensures that it will not conflict + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within - // the same symbol table. If we have a conflict, report the issue on each - // declaration we have for this symbol, and then create a new symbol for this + // the same symbol table. If we have a conflict, report the issue on each + // declaration we have for this symbol, and then create a new symbol for this // declaration. // // If we created a new symbol, either because we didn't have a symbol with this name @@ -202,10 +211,10 @@ namespace ts { symbol = hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); - + if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; - } + classifiableNames[name] = name; + } if (symbol.flags & excludes) { if (node.name) { @@ -250,7 +259,7 @@ namespace ts { // ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set // on it. There are 2 main reasons: // - // 1. We treat locals and exports of the same name as mutually exclusive within a container. + // 1. We treat locals and exports of the same name as mutually exclusive within a container. // That means the binder will issue a Duplicate Identifier error if you mix locals and exports // with the same name in the same container. // TODO: Make this a more specific error and decouple it from the exclusion logic. @@ -273,11 +282,11 @@ namespace ts { } } - // All container nodes are kept on a linked list in declaration order. This list is used by - // the getLocalNameOfContainer function in the type checker to validate that the local name + // All container nodes are kept on a linked list in declaration order. This list is used by + // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node: Node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's chilren, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. let saveParent = parent; @@ -286,16 +295,16 @@ namespace ts { // This node will now be set as the parent of all of its children as we recurse into them. parent = node; - + // Depending on what kind of node this is, we may have to adjust the current container // and block-container. If the current node is a container, then it is automatically // considered the current block-container as well. Also, for containers that we know // may contain locals, we proactively initialize the .locals field. We do this because // it's highly likely that the .locals will be needed to place some child in (for example, // a parameter, or variable declaration). - // + // // However, we do not proactively create the .locals for block-containers because it's - // totally normal and common for block-containers to never actually have a block-scoped + // totally normal and common for block-containers to never actually have a block-scoped // variable in them. We don't want to end up allocating an object for every 'block' we // run into when most of them won't be necessary. // @@ -314,6 +323,7 @@ namespace ts { addToContainerChain(container); } + else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { blockScopeContainer = node; blockScopeContainer.locals = undefined; @@ -335,7 +345,7 @@ namespace ts { case SyntaxKind.TypeLiteral: case SyntaxKind.ObjectLiteralExpression: return ContainerFlags.IsContainer; - + case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -363,7 +373,7 @@ namespace ts { case SyntaxKind.Block: // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' + // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -376,7 +386,7 @@ namespace ts { // the block, then there would be no collision. // // By not creating a new block-scoped-container here, we ensure that both 'var x' - // and 'let x' go into the Function-container's locals, and we do get a collision + // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; } @@ -474,7 +484,7 @@ namespace ts { } function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { - var body = node.kind === SyntaxKind.SourceFile ? node : (node).body; + let body = node.kind === SyntaxKind.SourceFile ? node : (node).body; if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) { for (let stat of (body).statements) { if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) { @@ -526,8 +536,8 @@ namespace ts { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); @@ -628,7 +638,7 @@ namespace ts { } function getStrictModeIdentifierMessage(node: Node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (getContainingClass(node)) { return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; @@ -686,7 +696,7 @@ namespace ts { } function getStrictModeEvalOrArgumentsMessage(node: Node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (getContainingClass(node)) { return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; @@ -750,24 +760,24 @@ namespace ts { function bind(node: Node) { node.parent = parent; - var savedInStrictMode = inStrictMode; + let savedInStrictMode = inStrictMode; if (!savedInStrictMode) { updateStrictMode(node); } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and then potentially add the symbol to an appropriate symbol table. Possible + // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: - // + // // 1) The 'exports' table of the current container's symbol. // 2) The 'members' table of the current container's symbol. // 3) The 'locals' table of the current container. // - // However, not all symbols will end up in any of these tables. 'Anonymous' symbols + // However, not all symbols will end up in any of these tables. 'Anonymous' symbols // (like TypeLiterals for example) will not be put in any table. bindWorker(node); - // Then we recurse into the children of the node to bind them as well. For certain + // Then we recurse into the children of the node to bind them as well. For certain // symbols we do specialized work when we recurse. For example, we'll keep track of // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. @@ -807,7 +817,7 @@ namespace ts { } } } - + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) function isUseStrictPrologueDirective(node: ExpressionStatement): boolean { let nodeText = getTextOfNodeFromSourceText(file.text, node.expression); @@ -882,7 +892,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); + let bindingName = (node).name ? (node).name.text : "__function"; + return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: return bindClassLikeDeclaration(node); @@ -954,15 +965,16 @@ namespace ts { bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); } else { - bindAnonymousDeclaration(node, SymbolFlags.Class, "__class"); + let bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); } let symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', the + // Every class automatically contains a static property member named 'prototype', the // type of which is an instantiation of the class type with type Any supplied as a type - // argument for each type parameter. It is an error to explicitly declare a static + // argument for each type parameter. It is an error to explicitly declare a static // property member with the name 'prototype'. // // Note: we check for this here because this class may be merging into a module. The @@ -988,7 +1000,7 @@ namespace ts { function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name) + checkStrictModeEvalOrArguments(node, node.name); } if (!isBindingPattern(node.name)) { @@ -1027,7 +1039,7 @@ namespace ts { declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); } - // If this is a property-parameter, then also declare the property symbol into the + // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && @@ -1044,4 +1056,4 @@ namespace ts { : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } -} +} diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99ae7cea7b9..dd5e42e0f4c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22,6 +22,17 @@ namespace ts { } export function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + let cancellationToken: CancellationToken; + let Symbol = objectAllocator.getSymbolConstructor(); let Type = objectAllocator.getTypeConstructor(); let Signature = objectAllocator.getSignatureConstructor(); @@ -107,6 +118,8 @@ namespace ts { let globalESSymbolConstructorSymbol: Symbol; + let getGlobalPromiseConstructorSymbol: () => Symbol; + let globalObjectType: ObjectType; let globalFunctionType: ObjectType; let globalArrayType: GenericType; @@ -129,13 +142,22 @@ namespace ts { let getGlobalPropertyDecoratorType: () => ObjectType; let getGlobalMethodDecoratorType: () => ObjectType; let getGlobalTypedPropertyDescriptorType: () => ObjectType; + let getGlobalPromiseType: () => ObjectType; + let tryGetGlobalPromiseType: () => ObjectType; + let getGlobalPromiseLikeType: () => ObjectType; + let getInstantiatedGlobalPromiseLikeType: () => ObjectType; + let getGlobalPromiseConstructorLikeType: () => ObjectType; + let getGlobalThenableType: () => ObjectType; let tupleTypes: Map = {}; let unionTypes: Map = {}; + let intersectionTypes: Map = {}; let stringLiteralTypes: Map = {}; let emitExtends = false; let emitDecorate = false; let emitParam = false; + let emitAwaiter = false; + let emitGenerator = false; let resolutionTargets: Object[] = []; let resolutionResults: boolean[] = []; @@ -144,6 +166,7 @@ namespace ts { let symbolLinks: SymbolLinks[] = []; let nodeLinks: NodeLinks[] = []; let potentialThisCollisions: Node[] = []; + let awaitedTypeStack: number[] = []; let diagnostics = createDiagnosticCollection(); @@ -182,10 +205,10 @@ namespace ts { return checker; - function getEmitResolver(sourceFile?: SourceFile) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile); + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } @@ -300,7 +323,7 @@ namespace ts { function getSymbolLinks(symbol: Symbol): SymbolLinks { if (symbol.flags & SymbolFlags.Transient) return symbol; - var id = getSymbolId(symbol); + let id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); } @@ -383,7 +406,7 @@ namespace ts { let moduleExports = getSymbolOfNode(location).exports; if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { - + // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -503,7 +526,7 @@ namespace ts { } break; case SyntaxKind.Decorator: - // Decorators are resolved at the class declaration. Resolving at the parameter + // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // // function y() {} @@ -558,7 +581,7 @@ namespace ts { } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { - Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0) + Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); // Block-scoped variables cannot be used before their definition let declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); @@ -648,7 +671,7 @@ namespace ts { } function getTargetOfNamespaceImport(node: NamespaceImport): Symbol { - var moduleSpecifier = (node.parent.parent).moduleSpecifier; + let moduleSpecifier = (node.parent.parent).moduleSpecifier; return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); } @@ -703,7 +726,7 @@ namespace ts { function getPropertyOfVariable(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Variable) { - var typeAnnotation = (symbol.valueDeclaration).type; + let typeAnnotation = (symbol.valueDeclaration).type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); } @@ -1327,7 +1350,7 @@ namespace ts { // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file - var anyImportSyntax = getAnyImportSyntax(declaration); + let anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && !(anyImportSyntax.flags & NodeFlags.Export) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { @@ -1566,8 +1589,8 @@ namespace ts { else if (type.flags & TypeFlags.Tuple) { writeTupleType(type); } - else if (type.flags & TypeFlags.Union) { - writeUnionType(type, flags); + else if (type.flags & TypeFlags.UnionOrIntersection) { + writeUnionOrIntersectionType(type, flags); } else if (type.flags & TypeFlags.Anonymous) { writeAnonymousType(type, flags); @@ -1586,16 +1609,16 @@ namespace ts { } } - function writeTypeList(types: Type[], union: boolean) { + function writeTypeList(types: Type[], delimiter: SyntaxKind) { for (let i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== SyntaxKind.CommaToken) { writeSpace(writer); } - writePunctuation(writer, union ? SyntaxKind.BarToken : SyntaxKind.CommaToken); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? TypeFormatFlags.InElementType : TypeFormatFlags.None); + writeType(types[i], delimiter === SyntaxKind.CommaToken ? TypeFormatFlags.None : TypeFormatFlags.InElementType); } } @@ -1653,15 +1676,15 @@ namespace ts { function writeTupleType(type: TupleType) { writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, /*union*/ false); + writeTypeList(type.elementTypes, SyntaxKind.CommaToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } - function writeUnionType(type: UnionType, flags: TypeFormatFlags) { + function writeUnionOrIntersectionType(type: UnionOrIntersectionType, flags: TypeFormatFlags) { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); } - writeTypeList(type.types, /*union*/ true); + writeTypeList(type.types, type.flags & TypeFlags.Union ? SyntaxKind.BarToken : SyntaxKind.AmpersandToken); if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -1738,7 +1761,7 @@ namespace ts { } function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, SyntaxKind.OpenBraceToken); @@ -1927,7 +1950,19 @@ namespace ts { writePunctuation(writer, SyntaxKind.ColonToken); } writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack); + + let returnType: Type; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, SyntaxKind.IsKeyword); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { @@ -2073,10 +2108,11 @@ namespace ts { case SyntaxKind.ArrayType: case SyntaxKind.TupleType: case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible + // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible case SyntaxKind.ImportClause: case SyntaxKind.NamespaceImport: @@ -2108,14 +2144,14 @@ namespace ts { } function collectLinkedAliases(node: Identifier): Node[] { - var exportSymbol: Symbol; + let exportSymbol: Symbol; if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { exportSymbol = getTargetOfExportSpecifier(node.parent); } - var result: Node[] = []; + let result: Node[] = []; if (exportSymbol) { buildVisibleNodeList(exportSymbol.declarations); } @@ -2124,16 +2160,16 @@ namespace ts { function buildVisibleNodeList(declarations: Declaration[]) { forEach(declarations, declaration => { getNodeLinks(declaration).isVisible = true; - var resultNode = getAnyImportSyntax(declaration) || declaration; + let resultNode = getAnyImportSyntax(declaration) || declaration; if (!contains(result, resultNode)) { result.push(resultNode); } if (isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible - var internalModuleReference = (declaration).moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, + let internalModuleReference = (declaration).moduleReference; + let firstIdentifier = getFirstIdentifier(internalModuleReference); + let importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, firstIdentifier); buildVisibleNodeList(importSymbol.declarations); } @@ -2225,8 +2261,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2605,7 +2641,7 @@ namespace ts { // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[]{ + function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { while (true) { node = node.parent; if (!node) { @@ -2624,7 +2660,7 @@ namespace ts { // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] { - var declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); + let declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); return appendOuterTypeParameters(undefined, declaration); } @@ -2691,7 +2727,7 @@ namespace ts { if (baseConstructorType.flags & TypeFlags.ObjectType) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveObjectOrUnionTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -3021,7 +3057,7 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -3087,6 +3123,26 @@ namespace ts { setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1: Type, type2: Type): Type { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + + function resolveIntersectionTypeMembers(type: IntersectionType) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + let callSignatures: Signature[] = emptyArray; + let constructSignatures: Signature[] = emptyArray; + let stringIndexType: Type = undefined; + let numberIndexType: Type = undefined; + for (let t of type.types) { + callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call)); + constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, IndexKind.String)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, IndexKind.Number)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } + function resolveAnonymousTypeMembers(type: ObjectType) { let symbol = type.symbol; let members: SymbolTable; @@ -3131,7 +3187,7 @@ namespace ts { setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type: ObjectType): ResolvedType { + function resolveStructuredTypeMembers(type: ObjectType): ResolvedType { if (!(type).members) { if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { resolveClassOrInterfaceMembers(type); @@ -3145,6 +3201,9 @@ namespace ts { else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); } + else if (type.flags & TypeFlags.Intersection) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -3155,16 +3214,16 @@ namespace ts { // Return properties of an object type or an empty array for other types function getPropertiesOfObjectType(type: Type): Symbol[] { if (type.flags & TypeFlags.ObjectType) { - return resolveObjectOrUnionTypeMembers(type).properties; + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } - // If the given type is an object type and that type has a property by the given name, return - // the symbol for that property. Otherwise return undefined. + // If the given type is an object type and that type has a property by the given name, + // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3174,25 +3233,30 @@ namespace ts { } } - function getPropertiesOfUnionType(type: UnionType): Symbol[] { - let result: Symbol[] = []; - forEach(getPropertiesOfType(type.types[0]), prop => { - let unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { + for (let current of type.types) { + for (let prop of getPropertiesOfType(current)) { + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & TypeFlags.Union) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type: Type): Symbol[] { type = getApparentType(type); - return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & TypeFlags.UnionOrIntersection ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * 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); @@ -3220,45 +3284,54 @@ namespace ts { return type; } - function createUnionProperty(unionType: UnionType, name: string): Symbol { - let types = unionType.types; + function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { + let types = containingType.types; let props: Symbol[]; for (let current of types) { let type = getApparentType(current); if (type !== unknownType) { let prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) { + if (!props) { + props = [prop]; + } + else if (!contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & TypeFlags.Union) { + // A union type requires the property to be present in all constituent types return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } let propTypes: Type[] = []; let declarations: Declaration[] = []; for (let prop of props) { if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); + addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } - let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.UnionProperty, name); - result.unionType = unionType; + let result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name); + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type: UnionType, name: string): Symbol { + function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { let properties = type.resolvedProperties || (type.resolvedProperties = {}); if (hasProperty(properties, name)) { return properties[name]; } - let property = createUnionProperty(type, name); + let property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -3271,7 +3344,7 @@ namespace ts { function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (hasProperty(resolved.members, name)) { let symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -3286,15 +3359,15 @@ namespace ts { } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & TypeFlags.Union) { - return getPropertyOfUnionType(type, name); + if (type.flags & TypeFlags.UnionOrIntersection) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type: Type, kind: SignatureKind): Signature[] { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === SignatureKind.Call ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -3303,13 +3376,13 @@ namespace ts { // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and // maps primitive types and type parameters are to their apparent types. function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } function typeHasConstructSignatures(type: Type): boolean { let apparentType = getApparentType(type); if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); return resolved.constructSignatures.length > 0; } return false; @@ -3317,17 +3390,16 @@ namespace ts { function typeHasCallOrConstructSignatures(type: Type): boolean { let apparentType = getApparentType(type); - if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type: Type, kind: IndexKind): Type { - if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { - let resolved = resolveObjectOrUnionTypeMembers(type); + function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type { + if (type.flags & TypeFlags.StructuredType) { + let resolved = resolveStructuredTypeMembers(type); return kind === IndexKind.String ? resolved.stringIndexType : resolved.numberIndexType; } } @@ -3335,7 +3407,7 @@ namespace ts { // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type: Type, kind: IndexKind): Type { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual @@ -3812,13 +3884,17 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name: string, arity = 0): ObjectType { + return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity); + } + /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace: string, name: string): Type { - var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); - var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); + let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined); + let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -3831,11 +3907,11 @@ namespace ts { */ function createTypedPropertyDescriptorType(propertyType: Type): Type { let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } - + /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -3881,25 +3957,20 @@ namespace ts { return links.resolvedType; } - function addTypeToSortedSet(sortedSet: Type[], type: Type) { - if (type.flags & TypeFlags.Union) { - addTypesToSortedSet(sortedSet, (type).types); + function addTypeToSet(typeSet: Type[], type: Type, typeSetKind: TypeFlags) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, (type).types, typeSetKind); } - else { - let i = 0; - let id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes: Type[], types: Type[]) { + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet: Type[], types: Type[], typeSetKind: TypeFlags) { for (let type of types) { - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } @@ -3941,6 +4012,10 @@ 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 @@ -3949,26 +4024,27 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } - let sortedTypes: Type[] = []; - addTypesToSortedSet(sortedTypes, types); + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Union); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - let id = getTypeListId(sortedTypes); + let id = getTypeListId(typeSet); let type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -4000,6 +4076,40 @@ namespace ts { return links.resolvedType; } + // We do not perform supertype reduction 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 + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types: Type[]): Type { + if (types.length === 0) { + return emptyObjectType; + } + let typeSet: Type[] = []; + addTypesToSet(typeSet, types, TypeFlags.Intersection); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + let id = getTypeListId(typeSet); + let type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + + function getTypeFromIntersectionTypeNode(node: IntersectionTypeNode): Type { + let links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: Node): Type { let links = getNodeLinks(node); if (!links.resolvedType) { @@ -4057,6 +4167,8 @@ namespace ts { return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: return getTypeFromUnionTypeNode(node); + case SyntaxKind.IntersectionType: + return getTypeFromIntersectionTypeNode(node); case SyntaxKind.ParenthesizedType: return getTypeFromTypeNode((node).type); case SyntaxKind.FunctionType: @@ -4140,7 +4252,7 @@ namespace ts { } } return t; - } + }; } function identityMapper(type: Type): Type { @@ -4176,7 +4288,7 @@ namespace ts { parameterName: signature.typePredicate.parameterName, parameterIndex: signature.typePredicate.parameterIndex, type: instantiateType(signature.typePredicate.type, mapper) - } + }; } let result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), @@ -4244,6 +4356,9 @@ namespace ts { if (type.flags & TypeFlags.Union) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); + } } return type; } @@ -4284,7 +4399,7 @@ namespace ts { function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { let result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; @@ -4329,6 +4444,16 @@ namespace ts { return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ function checkTypeRelatedTo( source: Type, target: Type, @@ -4394,37 +4519,10 @@ namespace ts { } } let saveErrorInfo = errorInfo; - if (source.flags & TypeFlags.Union || target.flags & TypeFlags.Union) { - if (relation === identityRelation) { - if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & TypeFlags.Union) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + 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)) { + return result; } } else if (source.flags & TypeFlags.TypeParameter && target.flags & TypeFlags.TypeParameter) { @@ -4432,10 +4530,43 @@ namespace ts { return result; } } - else 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)) { - return result; + else if (relation !== identityRelation) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & TypeFlags.Union) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & TypeFlags.Intersection) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "each" checks on both sides because there may be nested "some" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & TypeFlags.Intersection) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { + return result; + } + } + if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || + source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } @@ -4443,17 +4574,20 @@ namespace ts { // it may hold in a structural comparison. // Report structural errors only if we haven't reported any errors yet let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // identity relation does not use apparent type + // Identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (sourceOrApparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) { + else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.UnionOrIntersection) { // We clear the errors first because the following check often gives a better error than - // the union comparison above if it is applicable. + // the union or intersection comparison above if it is applicable. errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -4473,11 +4607,11 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToUnionType(source: UnionType, target: UnionType): Ternary { + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { - let related = typeRelatedToUnionType(sourceType, target, false); + let related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return Ternary.False; } @@ -4486,7 +4620,7 @@ namespace ts { return result; } - function typeRelatedToUnionType(source: Type, target: UnionType, reportErrors: boolean): Ternary { + function typeRelatedToSomeType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { let targetTypes = target.types; for (let i = 0, len = targetTypes.length; i < len; i++) { let related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -4497,7 +4631,31 @@ namespace ts { return Ternary.False; } - function unionTypeRelatedToType(source: UnionType, target: Type, reportErrors: boolean): Ternary { + function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { + let result = Ternary.True; + let targetTypes = target.types; + for (let targetType of targetTypes) { + let related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return Ternary.False; + } + result &= related; + } + return result; + } + + function someTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { + let sourceTypes = source.types; + for (let i = 0, len = sourceTypes.length; i < len; i++) { + let related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return Ternary.False; + } + + function eachTypeRelatedToType(source: UnionOrIntersectionType, target: Type, reportErrors: boolean): Ternary { let result = Ternary.True; let sourceTypes = source.types; for (let sourceType of sourceTypes) { @@ -4552,13 +4710,12 @@ namespace ts { // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function objectTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (overflow) { return Ternary.False; } let id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; let related = relation[id]; - //let related: RelationComparisonResult = undefined; // relation[id]; if (related !== undefined) { // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate // errors, we can use the cached value. Otherwise, recompute the relation @@ -4627,7 +4784,7 @@ namespace ts { return result; } - function propertiesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } @@ -4636,6 +4793,7 @@ namespace ts { let requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); for (let targetProp of properties) { let sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { @@ -4646,24 +4804,24 @@ namespace ts { } } else if (!(targetProp.flags & SymbolFlags.Prototype)) { - let sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - let targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) { + let sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) { + if (sourcePropFlags & NodeFlags.Private && targetPropFlags & NodeFlags.Private) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourceFlags & NodeFlags.Private ? source : target), - typeToString(sourceFlags & NodeFlags.Private ? target : source)); + typeToString(sourcePropFlags & NodeFlags.Private ? source : target), + typeToString(sourcePropFlags & NodeFlags.Private ? target : source)); } } return Ternary.False; } } - else if (targetFlags & NodeFlags.Protected) { + else if (targetPropFlags & NodeFlags.Protected) { let sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; let sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; let targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -4675,7 +4833,7 @@ namespace ts { return Ternary.False; } } - else if (sourceFlags & NodeFlags.Protected) { + else if (sourcePropFlags & NodeFlags.Protected) { if (reportErrors) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -4710,7 +4868,10 @@ namespace ts { return result; } - function propertiesIdenticalTo(source: ObjectType, target: ObjectType): Ternary { + function propertiesIdenticalTo(source: Type, target: Type): Ternary { + if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) { + return Ternary.False; + } let sourceProperties = getPropertiesOfObjectType(source); let targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -4731,7 +4892,7 @@ namespace ts { return result; } - function signaturesRelatedTo(source: ObjectType, target: ObjectType, kind: SignatureKind, reportErrors: boolean): Ternary { + function signaturesRelatedTo(source: Type, target: Type, kind: SignatureKind, reportErrors: boolean): Ternary { if (relation === identityRelation) { return signaturesIdenticalTo(source, target, kind); } @@ -4817,7 +4978,7 @@ namespace ts { if (source.typePredicate && target.typePredicate) { let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; let hasDifferentTypes: boolean; - if (hasDifferentParameterIndex || + if (hasDifferentParameterIndex || (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { if (reportErrors) { @@ -4827,12 +4988,12 @@ namespace ts { let targetTypeText = typeToString(target.typePredicate.type); if (hasDifferentParameterIndex) { - reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, + reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); } else if (hasDifferentTypes) { - reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, + reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); } @@ -4857,7 +5018,7 @@ namespace ts { return result & isRelatedTo(s, t, reportErrors); } - function signaturesIdenticalTo(source: ObjectType, target: ObjectType, kind: SignatureKind): Ternary { + function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { let sourceSignatures = getSignaturesOfType(source, kind); let targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { @@ -4874,7 +5035,7 @@ namespace ts { return result; } - function stringIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function stringIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.String, source, target); } @@ -4899,7 +5060,7 @@ namespace ts { return Ternary.True; } - function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + function numberIndexTypesRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (relation === identityRelation) { return indexTypesIdenticalTo(IndexKind.Number, source, target); } @@ -4932,7 +5093,7 @@ namespace ts { return Ternary.True; } - function indexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType): Ternary { + function indexTypesIdenticalTo(indexKind: IndexKind, source: Type, target: Type): Ternary { let targetType = getIndexTypeOfType(target, indexKind); let sourceType = getIndexTypeOfType(source, indexKind); if (!sourceType && !targetType) { @@ -5316,11 +5477,11 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & TypeFlags.Union) { - let targetTypes = (target).types; + else if (target.flags & TypeFlags.UnionOrIntersection) { + let targetTypes = (target).types; let typeParameterCount = 0; let typeParameter: TypeParameter; - // First infer to each type in union that isn't a type parameter + // First infer to each type in union or intersection that isn't a type parameter for (let t of targetTypes) { if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) { typeParameter = t; @@ -5330,22 +5491,25 @@ namespace ts { inferFromTypes(source, t); } } - // If union contains a single naked type parameter, make a secondary inference to that type parameter - if (typeParameterCount === 1) { + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & TypeFlags.Union && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & TypeFlags.Union) { - // Source is a union type, infer from each consituent type - let sourceTypes = (source).types; + else if (source.flags & TypeFlags.UnionOrIntersection) { + // Source is a union or intersection type, infer from each consituent type + let sourceTypes = (source).types; for (let sourceType of sourceTypes) { inferFromTypes(sourceType, target); } } else if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) || - (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral))) { + (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members if (isInProcess(source, target)) { return; @@ -5579,9 +5743,11 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: case SyntaxKind.Block: @@ -5848,7 +6014,7 @@ namespace ts { if (!assumeTrue) { if (type.flags & TypeFlags.Union) { return getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, signature.typePredicate.type))); - } + } return type; } return getNarrowedType(type, signature.typePredicate.type); @@ -5898,8 +6064,18 @@ namespace ts { // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) { - error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + let container = getContainingFunction(node); + if (container.kind === SyntaxKind.ArrowFunction) { + if (languageVersion < ScriptTarget.ES6) { + error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + + if (node.parserContextFlags & ParserContextFlags.Await) { + getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments; + getNodeLinks(node).flags |= NodeCheckFlags.LexicalArguments; + } } if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -6077,20 +6253,20 @@ namespace ts { if (container && isClassLike(container.parent)) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } @@ -6210,6 +6386,18 @@ namespace ts { return undefined; } + function isInParameterInitializerBeforeContainingFunction(node: Node) { + while (node.parent && !isFunctionLike(node.parent)) { + if (node.parent.kind === SyntaxKind.Parameter && (node.parent).initializer === node) { + return true; + } + + node = node.parent; + } + + return false; + } + function getContextualReturnType(functionDecl: FunctionLikeDeclaration): Type { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -6298,13 +6486,13 @@ namespace ts { function getTypeOfPropertyOfContextualType(type: Type, name: string) { return applyToContextualType(type, t => { - let prop = getPropertyOfObjectType(t, name); + let prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { - return applyToContextualType(type, t => getIndexTypeOfObjectOrUnionType(t, kind)); + return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind)); } // Return true if the given contextual type is a tuple-like type @@ -6314,7 +6502,7 @@ namespace ts { // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type: Type, kind: IndexKind): boolean { - return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfObjectOrUnionType(t, kind)) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfStructuredType(t, kind)) : getIndexTypeOfStructuredType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of @@ -6397,6 +6585,11 @@ namespace ts { // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node: Expression): Type { + let type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + + function getContextualTypeWorker(node: Expression): Type { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -6446,7 +6639,7 @@ namespace ts { // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type): Signature { - let signatures = getSignaturesOfObjectOrUnionType(type, SignatureKind.Call); + let signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); if (signatures.length === 1) { let signature = signatures[0]; if (!signature.typeParameters) { @@ -6488,7 +6681,7 @@ namespace ts { // The signature set of all constituent type with call signatures should match // So number of signatures allowed is either 0 or 1 if (signatureList && - getSignaturesOfObjectOrUnionType(current, SignatureKind.Call).length > 1) { + getSignaturesOfStructuredType(current, SignatureKind.Call).length > 1) { return undefined; } @@ -6571,7 +6764,7 @@ namespace ts { // c is represented in the tree as a spread element in an array literal. // But c really functions as a rest element, and its purpose is to provide // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error + // instead of calling checkExpression on "...c", which will give an error // if c is not iterable/array-like, we need to act as if we are trying to // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error @@ -6767,7 +6960,7 @@ namespace ts { checkJsxOpeningLikeElement(node.openingElement); // Check children - for(let child of node.children) { + for (let child of node.children) { switch (child.kind) { case SyntaxKind.JsxExpression: checkJsxExpression(child); @@ -6818,7 +7011,7 @@ namespace ts { else if (elementAttributesType && !isTypeAny(elementAttributesType)) { let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error + // If there's no corresponding property with this name, error if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); return unknownType; @@ -6845,7 +7038,7 @@ namespace ts { function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { let type = checkExpression(node.expression); let props = getPropertiesOfType(type); - for(let prop of props) { + for (let prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -6920,14 +7113,17 @@ namespace ts { // Look up the value in the current scope if (node.tagName.kind === SyntaxKind.Identifier) { - valueSymbol = getResolvedSymbol(node.tagName); + let tag = node.tagName; + let sym = getResolvedSymbol(tag); + valueSymbol = sym.exportSymbol || sym; } else { valueSymbol = checkQualifiedName(node.tagName).symbol; } - - if (valueSymbol !== unknownSymbol) { + + if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; + getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; @@ -7039,7 +7235,7 @@ namespace ts { return links.resolvedJsxType = anyType; } - var propsName = getJsxElementPropertiesName(); + let propsName = getJsxElementPropertiesName(); if (propsName === undefined) { // There is no type ElementAttributesProperty, return 'any' return links.resolvedJsxType = anyType; @@ -7049,7 +7245,7 @@ namespace ts { return links.resolvedJsxType = elemInstanceType; } else { - var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + let attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); if (!attributesType) { // There is no property named 'props' on this instance type @@ -7124,17 +7320,18 @@ namespace ts { checkGrammarJsxElement(node); checkJsxPreconditions(node); - let targetAttributesType = getJsxElementAttributesType(node); - - if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) { - if (node.tagName.kind === SyntaxKind.Identifier) { - checkIdentifier(node.tagName); - } - else { - checkQualifiedName(node.tagName); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === JsxEmit.React) { + let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; } } + let targetAttributesType = getJsxElementAttributesType(node); + let nameTable: Map = {}; // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and @@ -7182,46 +7379,95 @@ namespace ts { return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration; } - function getDeclarationFlagsFromSymbol(s: Symbol) { + function getDeclarationFlagsFromSymbol(s: Symbol): NodeFlags { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) { + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { let flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible - if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { - return; + let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + + if (left.kind === SyntaxKind.SuperKeyword) { + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + (node).name : + (node).right; + + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + + if (flags & NodeFlags.Abstract) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + + error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } } + + // Public properties are otherwise accessible. + if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { + return true; + } + // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types let enclosingClassDeclaration = getContainingClass(node); + let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { if (declaringClass !== enclosingClass) { error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } + // Property is known to be protected at this point + // All protected properties of a supertype are accessible in a super access if (left.kind === SyntaxKind.SuperKeyword) { - return; + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & NodeFlags.Static) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; } + return true; } function checkPropertyAccessExpression(node: PropertyAccessExpression) { @@ -7250,21 +7496,11 @@ namespace ts { } return unknownType; } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } @@ -7278,14 +7514,7 @@ namespace ts { if (type !== unknownType && !isTypeAny(type)) { let prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - return false; - } - else { - let modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -7532,7 +7761,7 @@ namespace ts { let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments let isDecorator: boolean; let spreadArgIndex = -1; - + if (node.kind === SyntaxKind.TaggedTemplateExpression) { let tagExpression = node; @@ -7609,7 +7838,7 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature { if (type.flags & TypeFlags.ObjectType) { - let resolved = resolveObjectOrUnionTypeMembers(type); + let resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -7664,7 +7893,7 @@ namespace ts { let paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all @@ -7713,17 +7942,17 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); typeArgumentHeadMessage = headMessage; } - + typeArgumentsAreAssignable = checkTypeAssignableTo( - typeArgument, - constraint, + typeArgument, + constraint, reportErrors ? typeArgNode : undefined, - typeArgumentHeadMessage, + typeArgumentHeadMessage, errorInfo); } } } - + return typeArgumentsAreAssignable; } @@ -7736,8 +7965,8 @@ namespace ts { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) let paramType = getTypeAtPosition(signature, i); let argType = getEffectiveArgumentType(node, i, arg); - - // If the effective argument type is 'undefined', there is no synthetic type + + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors @@ -7753,7 +7982,7 @@ namespace ts { } } } - + return true; } @@ -7790,18 +8019,18 @@ namespace ts { return args; } - + /** * Returns the effective argument count for a node that works like a function invocation. * If 'node' is a Decorator, the number of arguments is derived from the decoration * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument + * If 'node.target' is a class declaration or class expression, the effective argument * count is 1. * If 'node.target' is a parameter declaration, the effective argument count is 3. * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count + * If 'node.target' is a method or accessor declaration, the effective argument count * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. + * us to match a property decorator. * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node: CallLikeExpression, args: Expression[], signature: Signature) { @@ -7813,7 +8042,7 @@ namespace ts { return 1; case SyntaxKind.PropertyDeclaration: - // A property declaration decorator will have two arguments (see + // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; @@ -7822,12 +8051,12 @@ namespace ts { case SyntaxKind.SetAccessor: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If the method decorator signature only accepts a target and a key, we will only + // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; case SyntaxKind.Parameter: - // A parameter declaration decorator will have three arguments (see + // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -7837,68 +8066,68 @@ namespace ts { return args.length; } } - + /** * Returns the effective type of the first argument to a decorator. * If 'node' is a class declaration or class expression, the effective argument type * is the type of the static side of the class. * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, + * of the static or instance side of the class for the parameter's parent method, * depending on whether the method is declared static. * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. */ function getEffectiveDecoratorFirstArgumentType(node: Node): Type { // The first argument to a decorator is its `target`. switch (node.kind) { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - // For a class decorator, the `target` is the type of the class (e.g. the + // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - + case SyntaxKind.Parameter: - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. node = node.parent; if (node.kind === SyntaxKind.Constructor) { let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - - // fall-through - + + // fall-through + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the + // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); - + default: Debug.fail("Unsupported decorator target."); return unknownType; } } - + /** * Returns the effective type for the second argument to a decorator. * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * If 'node.parent' is a constructor, the effective argument type is 'any', as we * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * If 'node.parent' is a member with an identifier, numeric, or string literal name, * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will + * If 'node.parent' is a computed property name, the effective argument type will * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the + * If 'node' is a member with an identifier, numeric, or string literal name, the * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either + * If 'node' is a computed property name, the effective argument type will either * be a symbol type or the string type. * A class decorator does not have a second argument type. */ @@ -7908,25 +8137,25 @@ namespace ts { case SyntaxKind.ClassDeclaration: Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - + case SyntaxKind.Parameter: node = node.parent; if (node.kind === SyntaxKind.Constructor) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } - - // For a non-constructor parameter decorator, the `propertyKey` will be either - // a string or a symbol, based on the name of the parameter's containing method. - - // fall-through - + + // For a non-constructor parameter decorator, the `propertyKey` will be either + // a string or a symbol, based on the name of the parameter's containing method. + + // fall-through + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; + // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. let element = node; @@ -7935,7 +8164,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: return getStringLiteralType(element.name); - + case SyntaxKind.ComputedPropertyName: let nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { @@ -7944,23 +8173,23 @@ namespace ts { else { return stringType; } - + default: Debug.fail("Unsupported property name."); return unknownType; } - + default: Debug.fail("Unsupported decorator target."); return unknownType; } } - + /** * Returns the effective argument type for the third argument to a decorator. * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a + * If 'node' is a method or accessor, the effective argument type is a * `TypedPropertyDescriptor` instantiated with the type of the member. * Class and property decorators do not have a third effective argument. */ @@ -7987,13 +8216,13 @@ namespace ts { // for the type of the member. let propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); - + default: Debug.fail("Unsupported decorator target."); return unknownType; } } - + /** * Returns the effective argument type for the provided argument to a decorator. */ @@ -8011,12 +8240,12 @@ namespace ts { Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - + /** * Gets the effective argument type for an argument in a call expression. */ function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type { - // Decorators provide special arguments, a tagged template expression provides + // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors if (node.kind === SyntaxKind.Decorator) { @@ -8027,12 +8256,12 @@ namespace ts { } // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. + // to signal that the caller needs to check the argument. return undefined; } - + /** - * Gets the effective argument expression for an argument in a call expression. + * Gets the effective argument expression for an argument in a call expression. */ function getEffectiveArgument(node: CallLikeExpression, args: Expression[], argIndex: number) { // For a decorator or the first argument of a tagged template expression we return undefined. @@ -8040,7 +8269,7 @@ namespace ts { (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression)) { return undefined; } - + return args[argIndex]; } @@ -8060,7 +8289,7 @@ namespace ts { return arg; } } - + function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; let isDecorator = node.kind === SyntaxKind.Decorator; @@ -8098,7 +8327,7 @@ namespace ts { // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. // - // For a decorator, no arguments are susceptible to contextual typing due to the fact + // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. let excludeArgument: boolean[]; if (!isDecorator) { @@ -8178,7 +8407,7 @@ namespace ts { } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, (node).typeArguments, [], /*reportErrors*/ true, headMessage) + checkTypeArguments(candidateForTypeArgumentError, (node).typeArguments, [], /*reportErrors*/ true, headMessage); } else { Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -8188,7 +8417,7 @@ namespace ts { let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - + if (headMessage) { diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -8214,7 +8443,7 @@ namespace ts { } return resolveErrorCall(node); - + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { let errorInfo: DiagnosticMessageChain; errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); @@ -8243,7 +8472,7 @@ namespace ts { let typeArgumentTypes: Type[]; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false) + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -8361,7 +8590,7 @@ namespace ts { let expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -8372,8 +8601,18 @@ namespace ts { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); + if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } + // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -8391,7 +8630,7 @@ namespace ts { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -8430,7 +8669,7 @@ namespace ts { return resolveCall(node, callSignatures, candidatesOutArray); } - + /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ @@ -8439,13 +8678,13 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: return Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - + case SyntaxKind.Parameter: return Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - + case SyntaxKind.PropertyDeclaration: return Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - + case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -8462,12 +8701,12 @@ namespace ts { if (apparentType === unknownType) { return resolveErrorCall(node); } - + let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { return resolveUntypedCall(node); } - + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { let errorInfo: DiagnosticMessageChain; @@ -8476,7 +8715,7 @@ namespace ts { diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); return resolveErrorCall(node); } - + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } @@ -8510,6 +8749,11 @@ namespace ts { return links.resolvedSignature; } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ function checkCallExpression(node: CallExpression): Type { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); @@ -8520,6 +8764,7 @@ namespace ts { } if (node.kind === SyntaxKind.NewExpression) { let declaration = signature.declaration; + if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && @@ -8571,14 +8816,35 @@ namespace ts { } } + function createPromiseType(promisedType: Type): Type { + // creates a `Promise` type where `T` is the promisedType argument + let globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + + return emptyObjectType; + } + function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { let contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + + let isAsync = isAsyncFunctionLike(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } } else { let types: Type[]; @@ -8595,12 +8861,23 @@ namespace ts { } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + let promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; + } + else { + return voidType; + } } } - // When yield/return statements are contextually typed we allow the return type to be a union type. // Otherwise we require the yield/return expressions to have a best common supertype. type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); @@ -8622,7 +8899,23 @@ namespace ts { if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + + let widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + let promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body: Block, contextualMapper?: TypeMapper): Type[] { @@ -8647,13 +8940,21 @@ namespace ts { return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper): Type[] { + function checkAndAggregateReturnExpressionTypes(body: Block, contextualMapper?: TypeMapper, isAsync?: boolean): Type[] { let aggregatedTypes: Type[] = []; forEachReturnStatement(body, returnStatement => { let expr = returnStatement.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } + if (!contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -8712,6 +9013,7 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); + // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { @@ -8722,6 +9024,12 @@ namespace ts { if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + let links = getNodeLinks(node); let type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so @@ -8758,8 +9066,20 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + + let returnType = node.type && getTypeFromTypeNode(node.type); + let promisedType: Type; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { @@ -8776,10 +9096,22 @@ namespace ts { checkSourceElement(node.body); } else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. let exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); + if (returnType) { + if (isAsync) { + let awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } + checkFunctionAndClassExpressionBodies(node.body); } } @@ -8886,6 +9218,22 @@ namespace ts { return undefinedType; } + function checkAwaitExpression(node: AwaitExpression): Type { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Await)) { + grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + + let operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { let operandType = checkExpression(node.operand); switch (node.operator) { @@ -8930,8 +9278,8 @@ namespace ts { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { - let types = (type).types; + if (type.flags & TypeFlags.UnionOrIntersection) { + let types = (type).types; for (let current of types) { if (current.flags & kind) { return true; @@ -8942,13 +9290,13 @@ namespace ts { return false; } - // Return true if type has the given flags, or is a union type composed of types that all have those flags. + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.Union) { - let types = (type).types; + if (type.flags & TypeFlags.UnionOrIntersection) { + let types = (type).types; for (let current of types) { if (!(current.flags & kind)) { return false; @@ -9006,8 +9354,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -9272,9 +9620,9 @@ namespace ts { } function isYieldExpressionInClass(node: YieldExpression): boolean { - let current: Node = node + let current: Node = node; let parent = node.parent; - while (parent) { + while (parent) { if (isFunctionLike(parent) && current === (parent).body) { return false; } @@ -9291,8 +9639,14 @@ namespace ts { function checkYieldExpression(node: YieldExpression): Type { // Grammar checking - if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { @@ -9495,6 +9849,8 @@ namespace ts { return checkDeleteExpression(node); case SyntaxKind.VoidExpression: return checkVoidExpression(node); + case SyntaxKind.AwaitExpression: + return checkAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: @@ -9557,7 +9913,7 @@ namespace ts { if (node.questionToken && isBindingPattern(node.name) && func.body) { error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } - + // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. if (node.dotDotDotToken && !isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { @@ -9641,12 +9997,12 @@ namespace ts { if (hasReportedError) { break; } - if (param.name.kind === SyntaxKind.ObjectBindingPattern || + if (param.name.kind === SyntaxKind.ObjectBindingPattern || param.name.kind === SyntaxKind.ArrayBindingPattern) { (function checkBindingPattern(pattern: BindingPattern) { for (let element of pattern.elements) { - if (element.name.kind === SyntaxKind.Identifier && + if (element.name.kind === SyntaxKind.Identifier && (element.name).text === typePredicate.parameterName) { error(typePredicateNode.parameterName, @@ -9775,6 +10131,12 @@ namespace ts { // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (node.flags & NodeFlags.Abstract && node.body) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node: ConstructorDeclaration) { @@ -9959,7 +10321,7 @@ namespace ts { forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node: UnionTypeNode) { + function checkUnionOrIntersectionType(node: UnionOrIntersectionTypeNode) { forEach(node.types, checkSourceElement); } @@ -10009,7 +10371,7 @@ namespace ts { error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) { + function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags { let flags = getCombinedNodeFlags(n); if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) { if (!(flags & NodeFlags.Ambient)) { @@ -10055,6 +10417,9 @@ namespace ts { else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & NodeFlags.Abstract) { + error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -10071,7 +10436,7 @@ namespace ts { } } - let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected; + let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; let someNodeFlags: NodeFlags = 0; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -10121,7 +10486,14 @@ namespace ts { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & NodeFlags.Abstract) { + error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } @@ -10193,7 +10565,9 @@ namespace ts { }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -10304,6 +10678,260 @@ namespace ts { } } + function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) { + if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + + error(location, message); + } + + return unknownType; + } + + return type; + } + + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise: Type): Type { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + + if (promise.flags & TypeFlags.Any) { + return undefined; + } + + if ((promise.flags & TypeFlags.Reference) && (promise).target === tryGetGlobalPromiseType()) { + return (promise).typeArguments[0]; + } + + let globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + + let thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & TypeFlags.Any)) { + return undefined; + } + + let thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + + let onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & TypeFlags.Any) { + return undefined; + } + + let onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + + let valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + + function getTypeOfFirstParameterOfSignature(signature: Signature) { + return getTypeAtPosition(signature, 0); + } + + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type: Type) { + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + } + + function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { + return checkAwaitedTypeWorker(type); + + function checkAwaitedTypeWorker(type: Type): Type { + if (type.flags & TypeFlags.Union) { + let types: Type[] = []; + for (let constituentType of (type).types) { + types.push(checkAwaitedTypeWorker(constituentType)); + } + + return getUnionType(types); + } + else { + let promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error( + location, + Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, + symbolToString(type.symbol)); + } + + return unknownType; + } + + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + let awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { + let globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + + let promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + + let promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + + // Validate the promise constructor type. + let promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + + // Verify there is no local declaration that could collide with the promise constructor. + let promiseName = getEntityNameFromTypeNode(node.type); + let root = getFirstIdentifier(promiseName); + let rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, + root.text, + getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + /** Check a decorator */ function checkDecorator(node: Decorator): void { let signature = getResolvedSignature(node); @@ -10311,8 +10939,8 @@ namespace ts { if (returnType.flags & TypeFlags.Any) { return; } - - let expectedReturnType: Type; + + let expectedReturnType: Type; let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); let errorInfo: DiagnosticMessageChain; switch (node.parent.kind) { @@ -10329,7 +10957,7 @@ namespace ts { Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - + case SyntaxKind.PropertyDeclaration: expectedReturnType = voidType; errorInfo = chainDiagnosticMessages( @@ -10345,19 +10973,19 @@ namespace ts { expectedReturnType = getUnionType([descriptorType, voidType]); break; } - + checkTypeAssignableTo( - returnType, - expectedReturnType, - node, - headMessage, + returnType, + expectedReturnType, + node, + headMessage, errorInfo); } - + /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node: TypeNode) { // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we + // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let root = getFirstIdentifier((node).typeName); @@ -10369,7 +10997,7 @@ namespace ts { } /** - * Checks the type annotation of an accessor declaration or property declaration as + * Checks the type annotation of an accessor declaration or property declaration as * an expression if it is a type reference to a type with a value declaration. */ function checkTypeAnnotationAsExpression(node: AccessorDeclaration | PropertyDeclaration | ParameterDeclaration | MethodDeclaration) { @@ -10391,7 +11019,7 @@ namespace ts { break; } } - + /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ function checkParameterTypeAnnotationsAsExpressions(node: FunctionLikeDeclaration) { // ensure all type annotations with a value declaration are checked as an expression @@ -10411,7 +11039,7 @@ namespace ts { if (!nodeCanBeDecorated(node)) { return; } - + if (!compilerOptions.experimentalDecorators) { error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); } @@ -10420,7 +11048,7 @@ namespace ts { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case SyntaxKind.ClassDeclaration: - var constructor = getFirstConstructorWithBody(node); + let constructor = getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } @@ -10460,6 +11088,14 @@ namespace ts { function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void { checkDecorators(node); checkSignatureDeclaration(node); + let isAsync = isAsyncFunctionLike(node); + if (isAsync) { + if (!compilerOptions.experimentalAsyncFunctions) { + error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning); + } + + emitAwaiter = true; + } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -10494,7 +11130,13 @@ namespace ts { checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + let returnType = getTypeFromTypeNode(node.type); + let promisedType: Type; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { @@ -10671,7 +11313,7 @@ namespace ts { return; } - var symbol = getSymbolOfNode(node); + let symbol = getSymbolOfNode(node); if (symbol.flags & SymbolFlags.FunctionScopedVariable) { let localDeclarationSymbol = resolveName(node, (node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && @@ -10821,27 +11463,23 @@ namespace ts { forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node: Node) { - if (node.modifiers) { - if (inBlockOrObjectLiteralExpression(node)) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) { + // We only disallow modifier on a method declaration if it is a property of object-literal-expression + if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){ + if (isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } } - function inBlockOrObjectLiteralExpression(node: Node) { - while (node) { - if (node.kind === SyntaxKind.Block || node.kind === SyntaxKind.ObjectLiteralExpression) { - return true; - } - - node = node.parent; - } - } - function checkExpressionStatement(node: ExpressionStatement) { // Grammar checking - checkGrammarStatementInAmbientContext(node) + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); } @@ -10881,10 +11519,10 @@ namespace ts { if (node.initializer) { if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { - forEach((node.initializer).declarations, checkVariableDeclaration) + forEach((node.initializer).declarations, checkVariableDeclaration); } else { - checkExpression(node.initializer) + checkExpression(node.initializer); } } @@ -10894,7 +11532,7 @@ namespace ts { } function checkForOfStatement(node: ForOfStatement): void { - checkGrammarForInOrForOfStatement(node) + checkGrammarForInOrForOfStatement(node); // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS @@ -11030,7 +11668,7 @@ namespace ts { return elementType || anyType; } - + /** * We want to treat type as an iterable, and get the type it is an iterable of. The iterable * must have the following structure (annotated with the names of the variables below): @@ -11269,14 +11907,26 @@ namespace ts { } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, /*headMessage*/ undefined); + if (isAsyncFunctionLike(func)) { + let promisedType = getPromisedType(returnType); + let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.expression); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node: WithStatement) { - checkGrammarStatementInAmbientContext(node); + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & ParserContextFlags.Await) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); @@ -11375,7 +12025,7 @@ namespace ts { let identifierName = (catchClause.variableDeclaration.name).text; let locals = catchClause.block.locals; if (locals && hasProperty(locals, identifierName)) { - let localSymbol = locals[identifierName] + let localSymbol = locals[identifierName]; if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } @@ -11521,6 +12171,12 @@ namespace ts { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); + + // Interfaces cannot be merged with non-ambient classes. + if (getSymbolOfNode(node).flags & SymbolFlags.Interface && !isInAmbientContext(node)) { + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + } + forEach(node.members, checkSourceElement); } @@ -11556,6 +12212,7 @@ namespace ts { checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type @@ -11630,45 +12287,67 @@ namespace ts { } let derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + + Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { - let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { - // either base or derived property is private - not override, skip it - continue; - } + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration - if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - - let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { - if (derived.flags & SymbolFlags.Accessor) { - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } + // derived overrides base. + let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { + // either base or derived property is private - not override, skip it + continue; + } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + + if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + + let errorMessage: DiagnosticMessage; + if (base.flags & SymbolFlags.Method) { + if (derived.flags & SymbolFlags.Accessor) { + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + Debug.assert((derived.flags & SymbolFlags.Property) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & SymbolFlags.Property) { + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } } } } @@ -11770,6 +12449,16 @@ namespace ts { checkIndexConstraints(type); } } + + // Interfaces cannot merge with non-ambient classes. + if (symbol && symbol.declarations) { + for (let declaration of symbol.declarations) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) { + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -11777,6 +12466,7 @@ namespace ts { } checkTypeReferenceNode(heritageElement); }); + forEach(node.members, checkSourceElement); if (produceDiagnostics) { @@ -11916,7 +12606,7 @@ namespace ts { } // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName - var current = expression; + let current = expression; while (current) { if (current.kind === SyntaxKind.Identifier) { break; @@ -12089,7 +12779,7 @@ namespace ts { } } - // if the module merges with a class declaration in the same lexical scope, + // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); if (mergedClass && @@ -12355,8 +13045,24 @@ namespace ts { } function checkSourceElement(node: Node): void { - if (!node) return; - switch (node.kind) { + if (!node) { + return; + } + + let kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + + switch (kind) { case SyntaxKind.TypeParameter: return checkTypeParameter(node); case SyntaxKind.Parameter: @@ -12392,7 +13098,8 @@ namespace ts { case SyntaxKind.TupleType: return checkTupleType(node); case SyntaxKind.UnionType: - return checkUnionType(node); + case SyntaxKind.IntersectionType: + return checkUnionOrIntersectionType(node); case SyntaxKind.ParenthesizedType: return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: @@ -12522,12 +13229,14 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.SpreadElementExpression: + case SyntaxKind.YieldExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: case SyntaxKind.VariableStatement: @@ -12617,11 +13326,32 @@ namespace ts { links.flags |= NodeCheckFlags.EmitParam; } + if (emitAwaiter) { + links.flags |= NodeCheckFlags.EmitAwaiter; + } + + if (emitGenerator || (emitAwaiter && languageVersion < ScriptTarget.ES6)) { + links.flags |= NodeCheckFlags.EmitGenerator; + } + links.flags |= NodeCheckFlags.TypeChecked; } } - function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] { + function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + + function getDiagnosticsWorker(sourceFile: SourceFile): Diagnostic[] { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -12688,18 +13418,25 @@ namespace ts { copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember); break; case SyntaxKind.ClassExpression: - if ((location).name) { + let className = (location).name; + if (className) { copySymbol(location.symbol, meaning); } - // Fall through + // fall through; this fall-through is necessary because we would like to handle + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: + // If we didn't come from static member of class or interface, + // add the type parameters into the symbol table + // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. + // Note: that the memberFlags come from previous iteration. if (!(memberFlags & NodeFlags.Static)) { copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type); } break; case SyntaxKind.FunctionExpression: - if ((location).name) { + let funcName = (location).name; + if (funcName) { copySymbol(location.symbol, meaning); } break; @@ -12712,11 +13449,20 @@ namespace ts { copySymbols(globals, meaning); } - // Returns 'true' if we should stop processing symbols. + /** + * Copy the given symbol into symbol tables if the symbol has the given meaning + * and it doesn't already existed in the symbol table + * @param key a key for storing in symbol table; if undefined, use symbol.name + * @param symbol the symbol to be added into symbol table + * @param meaning meaning of symbol to filter by before adding to symbol table + */ function copySymbol(symbol: Symbol, meaning: SymbolFlags): void { if (symbol.flags & meaning) { let id = symbol.name; - if (!isReservedMemberName(id) && !hasProperty(symbols, id)) { + // We will copy all symbol regardless of its reserved name because + // symbolsToArray will check whether the key is a reserved name and + // it will not copy symbol with reserved name to the array + if (!hasProperty(symbols, id)) { symbols[id] = symbol; } } @@ -12725,9 +13471,8 @@ namespace ts { function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { for (let id in source) { - if (hasProperty(source, id)) { - copySymbol(source[id], meaning); - } + let symbol = source[id]; + copySymbol(symbol, meaning); } } } @@ -12908,8 +13653,8 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + // Fall through - // fall through case SyntaxKind.NumericLiteral: // index access if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { @@ -12998,16 +13743,16 @@ namespace ts { } /** - * Gets either the static or instance type of a class element, based on + * Gets either the static or instance type of a class element, based on * whether the element is declared as "static". */ function getParentTypeOfClassElement(node: ClassElement) { let classSymbol = getSymbolOfNode(node.parent); - return node.flags & NodeFlags.Static + return node.flags & NodeFlags.Static ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } - + // Return the list of properties of the given type, augmented with properties from Function // if the type has call or construct signatures function getAugmentedPropertiesOfType(type: Type): Symbol[] { @@ -13024,10 +13769,10 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (symbol.flags & SymbolFlags.UnionProperty) { + if (symbol.flags & SymbolFlags.SyntheticProperty) { let symbols: Symbol[] = []; let name = symbol.name; - forEach(getSymbolLinks(symbol).unionType.types, t => { + forEach(getSymbolLinks(symbol).containingType.types, t => { symbols.push(getPropertyOfType(t, name)); }); return symbols; @@ -13097,7 +13842,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -13140,7 +13885,7 @@ namespace ts { return false; } - var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); + let isValue = isAliasResolvedToValue(getSymbolOfNode(node)); return isValue && node.moduleReference && !nodeIsMissing(node.moduleReference); } @@ -13281,7 +14026,7 @@ namespace ts { } function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { - var type = getTypeOfExpression(expr); + let type = getTypeOfExpression(expr); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } @@ -13398,6 +14143,13 @@ namespace ts { getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); getGlobalTypedPropertyDescriptorType = memoize(() => getGlobalType("TypedPropertyDescriptor", /*arity*/ 1)); + getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); + tryGetGlobalPromiseType = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Type, /*diagnostic*/ undefined) && getGlobalPromiseType()); + getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); + getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise")); + getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); + getGlobalThenableType = memoize(createThenableType); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. @@ -13425,6 +14177,28 @@ namespace ts { anyArrayType = createArrayType(anyType); } + function createInstantiatedPromiseLikeType(): ObjectType { + let promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + + return emptyObjectType; + } + + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + let thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + + let thenableType = createObjectType(TypeFlags.Anonymous); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } + // GRAMMAR CHECKING function checkGrammarDecorators(node: Node): boolean { if (!node.decorators) { @@ -13462,10 +14236,15 @@ namespace ts { case SyntaxKind.ExportAssignment: case SyntaxKind.Parameter: break; + case SyntaxKind.FunctionDeclaration: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== SyntaxKind.AsyncKeyword) && + node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + break; case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.VariableStatement: - case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: if (node.modifiers && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); @@ -13485,7 +14264,7 @@ namespace ts { return; } - let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node; + let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node; let flags = 0; for (let modifier of node.modifiers) { switch (modifier.kind) { @@ -13511,9 +14290,20 @@ namespace ts { else if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & NodeFlags.Abstract) { + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= modifierToFlag(modifier.kind); break; @@ -13521,12 +14311,18 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= NodeFlags.Static; lastStatic = modifier; break; @@ -13538,6 +14334,12 @@ namespace ts { else if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } @@ -13551,6 +14353,9 @@ namespace ts { if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } @@ -13561,7 +14366,43 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= NodeFlags.Ambient; - lastDeclare = modifier + lastDeclare = modifier; + break; + + case SyntaxKind.AbstractKeyword: + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== SyntaxKind.ClassDeclaration) { + if (node.kind !== SyntaxKind.MethodDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { + return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & NodeFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + + flags |= NodeFlags.Abstract; + break; + + case SyntaxKind.AsyncKeyword: + if (flags & NodeFlags.Async) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & NodeFlags.Ambient || isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= NodeFlags.Async; + lastAsync = modifier; break; } } @@ -13570,19 +14411,48 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & NodeFlags.Protected) { return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & NodeFlags.Private) { return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & NodeFlags.Async) { + return grammarErrorOnNode(lastAsync, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((node).name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & NodeFlags.Async) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + + function checkGrammarAsyncModifier(node: Node, asyncModifier: Node): boolean { + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnNode(asyncModifier, Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + if (!(node).asteriskToken) { + return false; + } + break; + } + + return grammarErrorOnNode(asyncModifier, Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { @@ -13725,10 +14595,10 @@ namespace ts { checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node: CallExpression, arguments: NodeArray): boolean { - if (arguments) { + function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray): boolean { + if (args) { let sourceFile = getSourceFileOfNode(node); - for (let arg of arguments) { + for (let arg of args) { if (arg.kind === SyntaxKind.OmittedExpression) { return grammarErrorAtPos(sourceFile, arg.pos, 0, Diagnostics.Argument_expression_expected); } @@ -13736,9 +14606,9 @@ namespace ts { } } - function checkGrammarArguments(node: CallExpression, arguments: NodeArray): boolean { - return checkGrammarForDisallowedTrailingComma(arguments) || - checkGrammarForOmittedArgument(node, arguments); + function checkGrammarArguments(node: CallExpression, args: NodeArray): boolean { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); } function checkGrammarHeritageClause(node: HeritageClause): boolean { @@ -13749,7 +14619,7 @@ namespace ts { if (types && types.length === 0) { let listType = tokenToString(node.token); let sourceFile = getSourceFileOfNode(node); - return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType) + return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType); } } @@ -13761,7 +14631,7 @@ namespace ts { for (let heritageClause of node.heritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); } if (seenImplementsClause) { @@ -14024,7 +14894,7 @@ namespace ts { } function checkGrammarMethod(node: MethodDeclaration) { - if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarForGenerator(node)) { return true; @@ -14122,13 +14992,13 @@ namespace ts { ? Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message) + return grammarErrorOnNode(node, message); } else { let message = node.kind === SyntaxKind.BreakStatement ? Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message) + return grammarErrorOnNode(node, message); } } @@ -14407,7 +15277,7 @@ namespace ts { // Find containing block which is either Block, ModuleBlock, SourceFile let links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && isFunctionLike(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) + return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 35c5bc14c84..ba7d8ca9ce3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -5,7 +5,7 @@ namespace ts { /* @internal */ - export var optionDeclarations: CommandLineOption[] = [ + export let optionDeclarations: CommandLineOption[] = [ { name: "charset", type: "string", @@ -203,6 +203,11 @@ namespace ts { type: "boolean", description: Diagnostics.Watch_input_files, }, + { + name: "experimentalAsyncFunctions", + type: "boolean", + description: Diagnostics.Enables_experimental_support_for_ES7_async_functions + }, { name: "experimentalDecorators", type: "boolean", @@ -217,11 +222,11 @@ namespace ts { ]; export function parseCommandLine(commandLine: string[]): ParsedCommandLine { - var options: CompilerOptions = {}; - var fileNames: string[] = []; - var errors: Diagnostic[] = []; - var shortOptionNames: Map = {}; - var optionNameMap: Map = {}; + let options: CompilerOptions = {}; + let fileNames: string[] = []; + let errors: Diagnostic[] = []; + let shortOptionNames: Map = {}; + let optionNameMap: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; @@ -237,9 +242,9 @@ namespace ts { }; function parseStrings(args: string[]) { - var i = 0; + let i = 0; while (i < args.length) { - var s = args[i++]; + let s = args[i++]; if (s.charCodeAt(0) === CharacterCodes.at) { parseResponseFile(s.slice(1)); } @@ -252,7 +257,7 @@ namespace ts { } if (hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; + let opt = optionNameMap[s]; // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). if (!args[i] && opt.type !== "boolean") { @@ -271,8 +276,8 @@ namespace ts { break; // If not a primitive, the possible types are specified in what is effectively a map of options. default: - var map = >opt.type; - var key = (args[i++] || "").toLowerCase(); + let map = >opt.type; + let key = (args[i++] || "").toLowerCase(); if (hasProperty(map, key)) { options[opt.name] = map[key]; } @@ -292,19 +297,19 @@ namespace ts { } function parseResponseFile(fileName: string) { - var text = sys.readFile(fileName); + let text = sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); return; } - var args: string[] = []; - var pos = 0; + let args: string[] = []; + let pos = 0; while (true) { while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++; if (pos >= text.length) break; - var start = pos; + let start = pos; if (text.charCodeAt(start) === CharacterCodes.doubleQuote) { pos++; while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++; @@ -330,8 +335,9 @@ namespace ts { * @param fileName The path to the config file */ export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } { + let text = ''; try { - var text = sys.readFile(fileName); + text = sys.readFile(fileName); } catch (e) { return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -357,10 +363,10 @@ namespace ts { * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir + * file to. e.g. outDir */ export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine { - var errors: Diagnostic[] = []; + let errors: Diagnostic[] = []; return { options: getCompilerOptions(), @@ -369,22 +375,22 @@ namespace ts { }; function getCompilerOptions(): CompilerOptions { - var options: CompilerOptions = {}; - var optionNameMap: Map = {}; + let options: CompilerOptions = {}; + let optionNameMap: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name] = option; }); - var jsonOptions = json["compilerOptions"]; + let jsonOptions = json["compilerOptions"]; if (jsonOptions) { - for (var id in jsonOptions) { + for (let id in jsonOptions) { if (hasProperty(optionNameMap, id)) { - var opt = optionNameMap[id]; - var optType = opt.type; - var value = jsonOptions[id]; - var expectedType = typeof optType === "string" ? optType : "string"; + let opt = optionNameMap[id]; + let optType = opt.type; + let value = jsonOptions[id]; + let expectedType = typeof optType === "string" ? optType : "string"; if (typeof value === expectedType) { if (typeof optType !== "string") { - var key = value.toLowerCase(); + let key = value.toLowerCase(); if (hasProperty(optType, key)) { value = optType[key]; } @@ -419,7 +425,7 @@ namespace ts { } else { let exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); + let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (let i = 0; i < sysFiles.length; i++) { let name = sysFiles[i]; if (fileExtensionIs(name, ".d.ts")) { @@ -430,7 +436,7 @@ namespace ts { } else if (fileExtensionIs(name, ".ts")) { if (!contains(sysFiles, name + "x")) { - fileNames.push(name) + fileNames.push(name); } } else { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7b35c5e0d65..ec171d4aee2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2,17 +2,19 @@ /* @internal */ namespace ts { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ export const enum Ternary { False = 0, Maybe = 1, - True = -1 + True = -1 } export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { @@ -23,7 +25,7 @@ namespace ts { contains, remove, forEachValue: forEachValueInMap - } + }; function set(fileName: string, value: T) { files[normalizeKey(fileName)] = value; @@ -59,6 +61,11 @@ namespace ts { export interface StringSet extends Map { } + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { for (let i = 0, len = array.length; i < len; i++) { @@ -163,7 +170,7 @@ namespace ts { to.push(v); } } - } + } export function rangeEquals(array1: T[], array2: T[], pos: number, end: number) { while (pos < end) { @@ -365,7 +372,7 @@ namespace ts { } let text = getLocaleSpecificMessage(message.key); - + if (arguments.length > 4) { text = formatStringFromArgs(text, arguments, 4); } @@ -535,7 +542,7 @@ namespace ts { else { // A part may be an empty string (which is 'falsy') if the path had consecutive slashes, // e.g. "path//file.ts". Drop these before re-joining the parts. - if(part) { + if (part) { normalized.push(part); } } @@ -593,20 +600,20 @@ namespace ts { function getNormalizedPathComponentsOfUrl(url: string) { // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ + // In this example the root is: http://www.website.com/ // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] let urlLength = url.length; // Initial root length is http:// part let rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { - // Consume all immediate slashes in the protocol + // Consume all immediate slashes in the protocol // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// if (url.charCodeAt(rootLength) === CharacterCodes.slash) { rootLength++; } else { - // non slash character means we continue proceeding to next component of root search + // non slash character means we continue proceeding to next component of root search break; } } @@ -619,15 +626,15 @@ namespace ts { // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) let indexOfNextSlash = url.indexOf(directorySeparator, rootLength); if (indexOfNextSlash !== -1) { - // Found the "/" after the website.com so the root is length of http://www.website.com/ + // Found the "/" after the website.com so the root is length of http://www.website.com/ // and get components afetr the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } else { - // Can't find the host assume the rest of the string as component + // Can't find the host assume the rest of the string as component // but make sure we append "/" to it as root is not joined using "/" - // eg. if url passed in was http://website.com we want to use root as [http://website.com/] + // eg. if url passed in was http://website.com we want to use root as [http://website.com/] // so that other path manipulations will be correct and it can be merged with relative paths correctly return [url + directorySeparator]; } @@ -757,8 +764,8 @@ namespace ts { } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined, }; @@ -767,7 +774,7 @@ namespace ts { getSymbolConstructor: () => Symbol, getTypeConstructor: () => Type, getSignatureConstructor: () => Signature - } + }; export const enum AssertionLevel { None = 0, @@ -798,4 +805,4 @@ namespace ts { Debug.assert(false, message); } } -} +} diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 54d0d6ff854..6c0803f8761 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -130,7 +130,7 @@ namespace ts { moduleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), referencePathsOutput, - } + }; function hasInternalAnnotation(range: CommentRange) { let text = currentSourceFile.text; @@ -188,7 +188,7 @@ namespace ts { if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) { moduleElementEmitInfo = forEach(asynchronousSubModuleDeclarationEmitInfo, declEmitInfo => declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined); } - + // If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration // then we don't need to write it at this point. We will write it when we actually see its declaration // Eg. @@ -198,7 +198,7 @@ namespace ts { // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { if (moduleElementEmitInfo.node.kind === SyntaxKind.ImportDeclaration) { - // we have to create asynchronous output only after we have collected complete information + // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; } @@ -340,6 +340,8 @@ namespace ts { return emitTupleType(type); case SyntaxKind.UnionType: return emitUnionType(type); + case SyntaxKind.IntersectionType: + return emitIntersectionType(type); case SyntaxKind.ParenthesizedType: return emitParenType(type); case SyntaxKind.FunctionType: @@ -351,6 +353,21 @@ namespace ts { return emitEntityName(type); case SyntaxKind.QualifiedName: return emitEntityName(type); + case SyntaxKind.TypePredicate: + return emitTypePredicate(type); + } + + function writeEntityName(entityName: EntityName | Expression) { + if (entityName.kind === SyntaxKind.Identifier) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + let left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; + let right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } } function emitEntityName(entityName: EntityName | PropertyAccessExpression) { @@ -360,19 +377,6 @@ namespace ts { handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); - - function writeEntityName(entityName: EntityName | Expression) { - if (entityName.kind === SyntaxKind.Identifier) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - let left = entityName.kind === SyntaxKind.QualifiedName ? (entityName).left : (entityName).expression; - let right = entityName.kind === SyntaxKind.QualifiedName ? (entityName).right : (entityName).name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } } function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { @@ -396,6 +400,12 @@ namespace ts { } } + function emitTypePredicate(type: TypePredicateNode) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } + function emitTypeQuery(type: TypeQueryNode) { write("typeof "); emitEntityName(type.exprName); @@ -416,6 +426,10 @@ namespace ts { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type: IntersectionTypeNode) { + emitSeparatedList(type.types, " & ", emitType); + } + function emitParenType(type: ParenthesizedTypeNode) { write("("); emitType(type.type); @@ -588,10 +602,13 @@ namespace ts { if (node.flags & NodeFlags.Static) { write("static "); } + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } } function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { - // note usage of writer. methods instead of aliases created, just to make sure we are using + // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); if (node.flags & NodeFlags.Export) { @@ -633,7 +650,7 @@ namespace ts { function writeImportDeclaration(node: ImportDeclaration) { if (!node.importClause && !(node.flags & NodeFlags.Export)) { - // do not write non-exported import declarations that don't have import clauses + // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); @@ -755,7 +772,7 @@ namespace ts { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (isConst(node)) { - write("const ") + write("const "); } write("enum "); writeTextOfNode(currentSourceFile, node.name); @@ -912,6 +929,10 @@ namespace ts { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } + write("class "); writeTextOfNode(currentSourceFile, node.name); let prevEnclosingDeclaration = enclosingDeclaration; @@ -1330,7 +1351,7 @@ namespace ts { return { diagnosticMessage, - errorNode: node.name || node, + errorNode: node.name || node }; } } @@ -1504,7 +1525,7 @@ namespace ts { } } } - } + } } function emitNode(node: Node) { @@ -1552,7 +1573,7 @@ namespace ts { ? referencedFile.fileName // Declaration file, use declaration file name : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file + : removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file declFileName = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizeSlashes(jsFilePath)), @@ -1564,7 +1585,7 @@ namespace ts { referencePathsOutput += "/// " + newLine; } } - + /* @internal */ export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) { let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile); @@ -1591,4 +1612,4 @@ namespace ts { return declarationOutput; } } -} \ No newline at end of file +} diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index ec9c444e9e9..a17f8857590 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -29,7 +29,12 @@ namespace ts { Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -38,12 +43,18 @@ namespace ts { A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -179,12 +190,20 @@ namespace ts { An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, + Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, + with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, + Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -220,10 +239,10 @@ namespace ts { this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -382,6 +401,19 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, + The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, + yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, + await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -538,6 +570,8 @@ namespace ts { Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, + Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, + Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f0c02e7f34e..94be4f53c97 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -103,10 +103,30 @@ "category": "Error", "code": 1039 }, + "'{0}' modifier cannot be used in an ambient context.": { + "category": "Error", + "code": 1040 + }, + "'{0}' modifier cannot be used with a class declaration.": { + "category": "Error", + "code": 1041 + }, + "'{0}' modifier cannot be used here.": { + "category": "Error", + "code": 1042 + }, + "'{0}' modifier cannot appear on a data property.": { + "category": "Error", + "code": 1043 + }, "'{0}' modifier cannot appear on a module element.": { "category": "Error", "code": 1044 }, + "A '{0}' modifier cannot be used with an interface declaration.": { + "category": "Error", + "code": 1045 + }, "A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "category": "Error", "code": 1046 @@ -139,14 +159,38 @@ "category": "Error", "code": 1054 }, + "Type '{0}' is not a valid async function return type.": { + "category": "Error", + "code": 1055 + }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 1056 }, + "An async function or method must have a valid awaitable return type.": { + "category": "Error", + "code": 1057 + }, + "Operand for 'await' does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1058 + }, + "Return expression in async function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1059 + }, + "Expression body for async arrow function does not have a valid callable 'then' member.": { + "category": "Error", + "code": 1060 + }, "Enum member must have initializer.": { "category": "Error", "code": 1061 }, + "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": { + "category": "Error", + "code": 1062 + }, "An export assignment cannot be used in a namespace.": { "category": "Error", "code": 1063 @@ -159,7 +203,7 @@ "category": "Error", "code": 1068 }, - "A 'declare' modifier cannot be used with an import declaration.": { + "A '{0}' modifier cannot be used with an import declaration.": { "category": "Error", "code": 1079 }, @@ -703,8 +747,24 @@ "category": "Error", "code": 1235 }, + "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": { + "category": "Error", + "code": 1236 + }, + "'with' statements are not allowed in an async function block.": { + "category": "Error", + "code": 1300 + }, + "'await' expression is only allowed within an async function.": { + "category": "Error", + "code": 1308 + }, + "Async functions are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1311 + }, "The return type of a property decorator function must be either 'void' or 'any'.": { "category": "Error", "code": 1236 @@ -729,7 +789,22 @@ "category": "Error", "code": 1241 }, - + "'abstract' modifier can only appear on a class or method declaration.": { + "category": "Error", + "code": 1242 + }, + "'{0}' modifier cannot be used with '{1}' modifier.": { + "category": "Error", + "code": 1243 + }, + "Abstract methods can only appear within an abstract class.": { + "category": "Error", + "code": 1244 + }, + "Method '{0}' cannot have an implementation because it is marked abstract.": { + "category": "Error", + "code": 1245 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -870,11 +945,11 @@ "category": "Error", "code": 2336 }, - "Super calls are not permitted outside constructors or in nested functions inside constructors": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "category": "Error", "code": 2337 }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class": { + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "category": "Error", "code": 2338 }, @@ -882,7 +957,7 @@ "category": "Error", "code": 2339 }, - "Only public and protected methods of the base class are accessible via the 'super' keyword": { + "Only public and protected methods of the base class are accessible via the 'super' keyword.": { "category": "Error", "code": 2340 }, @@ -1518,7 +1593,58 @@ "category": "Error", "code": 2510 }, - + "Cannot create an instance of the abstract class '{0}'.": { + "category": "Error", + "code": 2511 + }, + "Overload signatures must all be abstract or not abstract.": { + "category": "Error", + "code": 2512 + }, + "Abstract method '{0}' in class '{1}' cannot be accessed via super expression.": { + "category": "Error", + "code": 2513 + }, + "Classes containing abstract methods must be marked abstract.": { + "category": "Error", + "code": 2514 + }, + "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": { + "category": "Error", + "code": 2515 + }, + "All declarations of an abstract method must be consecutive.": { + "category": "Error", + "code": 2516 + }, + "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": { + "category": "Error", + "code":2517 + }, + "Only an ambient class can be merged with an interface.": { + "category": "Error", + "code": 2518 + }, + "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { + "category": "Error", + "code": 2520 + }, + "Expression resolves to variable declaration '{0}' that compiler uses to support async functions.": { + "category": "Error", + "code": 2521 + }, + "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": { + "category": "Error", + "code": 2522 + }, + "'yield' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2523 + }, + "'await' expressions cannot be used in a parameter initializer.": { + "category": "Error", + "code": 2524 + }, "JSX element attributes type '{0}' must be an object type.": { "category": "Error", "code": 2600 @@ -1559,7 +1685,6 @@ "category": "Error", "code": 2650 }, - "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2145,6 +2270,14 @@ "category": "Message", "code": 6066 }, + "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": { + "category": "Message", + "code": 6067 + }, + "Enables experimental support for ES7 async functions.": { + "category": "Message", + "code": 6068 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a89963dee84..4a43cf714b8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -47,6 +47,20 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } };`; + const awaiterHelper = ` +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +};`; let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; @@ -132,6 +146,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let extendsEmitted = false; let decorateEmitted = false; let paramEmitted = false; + let awaiterEmitted = false; let tempFlags = 0; let tempVariables: Identifier[]; let tempParameters: Identifier[]; @@ -167,10 +182,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { /** Called to before starting the lexical scopes as in function/class in the emitted code because of node * @param scopeDeclaration node that starts the lexical scope * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ - let scopeEmitStart = function (scopeDeclaration: Node, scopeName?: string) { } + let scopeEmitStart = function(scopeDeclaration: Node, scopeName?: string) { }; /** Called after coming out of the scope */ - let scopeEmitEnd = function () { } + let scopeEmitEnd = function() { }; /** Sourcemap data that will get encoded */ let sourceMapData: SourceMapData; @@ -212,7 +227,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags: TempFlags): string { if (flags && !(tempFlags & flags)) { - var name = flags === TempFlags._i ? "_i" : "_n" + let name = flags === TempFlags._i ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; return name; @@ -882,13 +897,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } - + // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (node.parent) { return getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } - + // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { @@ -918,14 +933,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" let isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail; text = text.substring(1, text.length - (isLast ? 1 : 2)); - + // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -966,7 +981,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - + // Now we emit the expressions if (node.template.kind === SyntaxKind.TemplateExpression) { forEach((node.template).templateSpans, templateSpan => { @@ -1029,7 +1044,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // with the head will force the result up to this point to be a string. // Emitting a '+ ""' has no semantic effect for middles and tails. if (templateSpan.literal.text.length !== 0) { - write(" + ") + write(" + "); emitLiteral(templateSpan.literal); } } @@ -1343,7 +1358,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } else if (node.kind === SyntaxKind.ComputedPropertyName) { // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure + // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: // // class C { @@ -1449,6 +1464,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitExpressionIdentifier(node: Identifier) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalArguments) { + write("_arguments"); + return; + } + let container = resolver.getReferencedExportContainer(node); if (container) { if (container.kind === SyntaxKind.SourceFile) { @@ -1532,7 +1552,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("super"); } else { - var flags = resolver.getNodeCheckFlags(node); + let flags = resolver.getNodeCheckFlags(node); if (flags & NodeCheckFlags.SuperInstance) { write("_super.prototype"); } @@ -1589,6 +1609,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } } + function emitAwaitExpression(node: AwaitExpression) { + let needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(tokenToString(SyntaxKind.YieldKeyword)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + + function needsParenthesisForAwaitExpressionAsYield(node: AwaitExpression) { + if (node.parent.kind === SyntaxKind.BinaryExpression && !isAssignmentOperator((node.parent).operatorToken.kind)) { + return true; + } + else if (node.parent.kind === SyntaxKind.ConditionalExpression && (node.parent).condition === node) { + return true; + } + + return false; + } + function needsParenthesisForPropertyAccessOrInvocation(node: Expression) { switch (node.kind) { case SyntaxKind.Identifier: @@ -1644,7 +1688,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { group++; } if (group > 1) { - if(useConcat) { + if (useConcat) { write(")"); } } @@ -1679,7 +1723,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("{"); if (numElements > 0) { - var properties = node.properties; + let properties = node.properties; // If we are not doing a downlevel transformation for object literals, // then try to preserve the original shape of the object literal. @@ -1727,7 +1771,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // Write out the first non-computed properties // (or all properties if none of them are computed), // then emit the rest through indexing on the temp variable. - emit(tempVar) + emit(tempVar); write(" = "); emitObjectLiteralBody(node, firstComputedPropertyIndex); @@ -1736,7 +1780,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let property = properties[i]; - emitStart(property) + emitStart(property); if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. let accessors = getAllAccessorDeclarations(node.properties, property); @@ -1752,7 +1796,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(", {"); increaseIndent(); if (accessors.getAccessor) { - writeLine() + writeLine(); emitLeadingComments(accessors.getAccessor); write("get: "); emitStart(accessors.getAccessor); @@ -1977,8 +2021,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return false; } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean { let realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); @@ -2006,8 +2050,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.expression); let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - - // 1 .toString is a valid property access, emit a space after the literal + + // 1 .toString is a valid property access, emit a space after the literal let shouldEmitSpace: boolean; if (!indentedBeforeDot && node.expression.kind === SyntaxKind.NumericLiteral) { let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); @@ -2015,7 +2059,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } if (shouldEmitSpace) { - write(" ."); + write(" ."); } else { write("."); @@ -2379,14 +2423,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } - /* + /* * Checks if given node is a source file level declaration (not nested in module/function). * If 'isExported' is true - then declaration must also be exported. * This function is used in two cases: - * - check if node is a exported source file level value to determine + * - check if node is a exported source file level value to determine * if we should also export the value after its it changed - * - check if node is a source level declaration to emit it differently, - * i.e non-exported variable statement 'var x = 1' is hoisted so + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so * we we emit variable statement 'var' should be dropped. */ function isSourceFileLevelDeclarationInSystemJsModule(node: Node, isExported: boolean): boolean { @@ -2397,7 +2441,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let current: Node = node; while (current) { if (current.kind === SyntaxKind.SourceFile) { - return !isExported || ((getCombinedNodeFlags(node) & NodeFlags.Export) !== 0) + return !isExported || ((getCombinedNodeFlags(node) & NodeFlags.Export) !== 0); } else if (isFunctionLike(current) || current.kind === SyntaxKind.ModuleBlock) { return false; @@ -2455,7 +2499,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { decreaseIndentIf(indentedBeforeColon, indentedAfterColon); } - // Helper function to decrease the indent if we previously indented. Allows multiple + // Helper function to decrease the indent if we previously indented. Allows multiple // previous indent values to be considered at a time. This also allows caller to just // call this once, passing in all their appropriate indent values, instead of needing // to call this helper function multiple times. @@ -2582,7 +2626,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (startPos !== undefined) { emitToken(tokenKind, startPos); - write(" ") + write(" "); } else { switch (tokenKind) { @@ -2697,13 +2741,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - + let endPos = emitToken(SyntaxKind.ForKeyword, node.pos); write(" "); endPos = emitToken(SyntaxKind.OpenParenToken, endPos); - + // Do not emit the LHS let declaration yet, because it might contain destructuring. - + // Do not call recordTempDeclaration because we are declaring the temps // right here. Recording means they will be declared later. // In the case where the user wrote an identifier as the RHS, like this: @@ -2719,7 +2763,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // the LHS will be emitted inside the body. emitStart(node.expression); write("var "); - + // _i = 0 emitNodeWithoutSourceMap(counter); write(" = 0"); @@ -2736,7 +2780,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } write("; "); - + // _i < _a.length; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); @@ -2747,19 +2791,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitEnd(node.initializer); write("; "); - + // _i++) emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); emitToken(SyntaxKind.CloseParenToken, node.expression.end); - + // Body write(" {"); writeLine(); increaseIndent(); - + // Initialize LHS // let v = _a[_i]; let rhsIterationValue = createElementAccessExpression(rhsReference, counter); @@ -2845,7 +2889,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.expression); endPos = emitToken(SyntaxKind.CloseParenToken, node.expression.end); write(" "); - emitCaseBlock(node.caseBlock, endPos) + emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node: CaseBlock, startPos: number): void { @@ -2947,7 +2991,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function emitModuleMemberName(node: Declaration) { emitStart(node.name); if (getCombinedNodeFlags(node) & NodeFlags.Export) { - var container = getContainingModule(node); + let container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); @@ -2986,7 +3030,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } write(`", `); emitDeclarationName(node); - write(")") + write(")"); } else { if (node.flags & NodeFlags.Default) { @@ -3017,7 +3061,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitNodeWithoutSourceMap(specifier.name); write(`", `); emitExpressionIdentifier(name); - write(")") + write(")"); emitEnd(specifier.name); } else { @@ -3307,7 +3351,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitOptional(" = ", initializer); if (exportChanged) { - write(")") + write(")"); } } } @@ -3607,9 +3651,150 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emit(node.parameters[0]); return; } + emitSignatureParameters(node); } + function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) { + let promiseConstructor = getEntityNameFromTypeNode(node.type); + let isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + let hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + let args: string; + + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + if (!isArrowFunction) { + write(" {"); + increaseIndent(); + writeLine(); + write("return"); + } + + write(" __awaiter(this"); + if (hasLexicalArguments) { + write(", arguments"); + } + else { + write(", void 0"); + } + + if (promiseConstructor) { + write(", "); + emitNodeWithoutSourceMap(promiseConstructor); + } + else { + write(", Promise"); + } + + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + + function emitFunctionBody(node: FunctionLikeDeclaration) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === SyntaxKind.Block) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } + function emitSignatureAndBody(node: FunctionLikeDeclaration) { let saveTempFlags = tempFlags; let saveTempVariables = tempVariables; @@ -3627,16 +3812,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitSignatureParameters(node); } - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else if (node.body.kind === SyntaxKind.Block) { - emitBlockFunctionBody(node, node.body); + let isAsync = isAsyncFunctionLike(node); + if (isAsync && languageVersion === ScriptTarget.ES6) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } if (!isES6ExportedDeclaration(node)) { @@ -3656,12 +3837,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function emitExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES6 || node.flags & NodeFlags.Async) { emitDownLevelExpressionFunctionBody(node, body); return; } - // For es6 and higher we can emit the expression as is. However, in the case + // For es6 and higher we can emit the expression as is. However, in the case // where the expression might end up looking like a block when emitted, we'll // also wrap it in parentheses first. For example if you have: a => {} // then we need to generate: a => ({}) @@ -3933,8 +4114,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitOnlyPinnedOrTripleSlashComments(member); } else if (member.kind === SyntaxKind.MethodDeclaration || - member.kind === SyntaxKind.GetAccessor || - member.kind === SyntaxKind.SetAccessor) { + member.kind === SyntaxKind.GetAccessor || + member.kind === SyntaxKind.SetAccessor) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -4068,7 +4249,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { - var statements: Node[] = (ctor.body).statements; + let statements: Node[] = (ctor.body).statements; if (superCall) { statements = statements.slice(1); } @@ -4178,9 +4359,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: + // to specialize the emit a bit. for a class expression of the form: // - // class C { static a = 1; static b = 2; ... } + // class C { static a = 1; static b = 2; ... } // // We'll emit: // @@ -4197,7 +4378,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("("); increaseIndent(); emit(tempVariable); - write(" = ") + write(" = "); } write("class"); @@ -4208,7 +4389,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitDeclarationName(node); } - var baseTypeNode = getClassExtendsHeritageClauseElement(node); + let baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { write(" extends "); emit(baseTypeNode.expression); @@ -4226,7 +4407,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { scopeEmitEnd(); // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - + // For a decorated class, we need to assign its name (if it has one). This is because we emit // the class as a class expression to avoid the double-binding of the identifier: // @@ -4471,7 +4652,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", + // Object.defineProperty(C.prototype, "method", // __decorate([ // dec, // __param(0, dec2), @@ -4479,10 +4660,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // __metadata("design:paramtypes", [Object]), // __metadata("design:returntype", void 0) // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // + // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", + // Object.defineProperty(C.prototype, "accessor", // __decorate([ // dec // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); @@ -4572,7 +4753,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function shouldEmitTypeMetadata(node: Declaration): boolean { // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { case SyntaxKind.MethodDeclaration: @@ -4587,7 +4768,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function shouldEmitReturnTypeMetadata(node: Declaration): boolean { // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { case SyntaxKind.MethodDeclaration: @@ -4598,7 +4779,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function shouldEmitParamTypesMetadata(node: Declaration): boolean { // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { case SyntaxKind.ClassDeclaration: @@ -5330,7 +5511,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLine(); emitStart(node); write("export default "); - var expression = node.expression; + let expression = node.expression; emit(expression); if (expression.kind !== SyntaxKind.FunctionDeclaration && expression.kind !== SyntaxKind.ClassDeclaration) { @@ -5460,7 +5641,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // do not create variable declaration for exports and imports that lack import clause let skipNode = importNode.kind === SyntaxKind.ExportDeclaration || - (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause) + (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause); if (skipNode) { continue; @@ -5578,14 +5759,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("}"); decreaseIndent(); writeLine(); - write("}") + write("}"); return exportStarFunction; } function writeExportedName(node: Identifier | Declaration): void { // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export + // they are local to module and never overwritten (explicitly skipped) by star export if (node.kind !== SyntaxKind.Identifier && node.flags & NodeFlags.Default) { return; } @@ -5611,7 +5792,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } function processTopLevelVariableAndFunctionDeclarations(node: SourceFile): (Identifier | Declaration)[] { - // per ES6 spec: + // per ES6 spec: // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method // - var declarations are initialized to undefined - 14.a.ii // - function/generator declarations are instantiated - 16.a.iv @@ -5666,7 +5847,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { exportedDeclarations.push(local); } } - write(";") + write(";"); } if (hoistedFunctionDeclarations) { @@ -5766,7 +5947,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // hoist variable if // - it is not block scoped // - it is top level block scoped - // if block scoped variables are nested in some another block then + // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === 0 || getEnclosingBlockScopeContainer(node).kind === SyntaxKind.SourceFile; @@ -5815,8 +5996,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // } emitVariableDeclarationsForImports(); writeLine(); - var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); - let exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations) + let exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); + let exportStarFunction = emitLocalStorageForExportedNamesIfNecessary(exportedDeclarations); writeLine(); write("return {"); increaseIndent(); @@ -5893,7 +6074,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // export {a, b as c} for (let element of (namedBindings).elements) { emitExportMemberAssignments(element.name || element.propertyName); - writeLine() + writeLine(); } } } @@ -5932,7 +6113,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { break; } - write("}") + write("}"); decreaseIndent(); } write("],"); @@ -5958,7 +6139,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } decreaseIndent(); writeLine(); - write("}") // execute + write("}"); // execute } function emitSystemModule(node: SourceFile, startIndex: number): void { @@ -5966,10 +6147,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. - // 'exports' returns its 'value' argument so in most cases expressions + // 'exports' returns its 'value' argument so in most cases expressions // that mutate exported values can be rewritten as: - // expr -> exports('name', expr). - // The only exception in this rule is postfix unary operators, + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, // see comment to 'emitPostfixUnaryExpression' for more details Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers @@ -5979,7 +6160,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { if (node.moduleName) { write(`"${node.moduleName}", `); } - write("[") + write("["); for (let i = 0; i < externalImports.length; ++i) { let text = getExternalModuleNameText(externalImports[i]); if (i !== 0) { @@ -6010,13 +6191,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - let aliasedModuleNames: string[] = []; // names of modules with corresponding parameter in the - // factory function. - let unaliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in - // factory function. - let importAliasNames: string[] = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. + // names of modules with corresponding parameter in the factory function + let aliasedModuleNames: string[] = []; + // names of modules with no corresponding parameters in factory function + let unaliasedModuleNames: string[] = []; + let importAliasNames: string[] = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. // Fill in amd-dependency tags for (let amdDependency of node.amdDependencies) { @@ -6123,7 +6304,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(/*newLine*/ true); - // Emit exportDefault if it exists will happen as part + // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -6264,7 +6445,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitDetachedComments(node); // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { @@ -6287,6 +6468,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { writeLines(paramHelper); paramEmitted = true; } + + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (isExternalModule(node) || compilerOptions.isolatedModules) { @@ -6366,7 +6552,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return shouldEmitEnumDeclaration(node); } - // If this is the expression body of an arrow function that we're down-leveling, + // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. @@ -6469,6 +6655,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return emitTypeOfExpression(node); case SyntaxKind.VoidExpression: return emitVoidExpression(node); + case SyntaxKind.AwaitExpression: + return emitAwaitExpression(node); case SyntaxKind.PrefixUnaryExpression: return emitPrefixUnaryExpression(node); case SyntaxKind.PostfixUnaryExpression: @@ -6629,7 +6817,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function emitTrailingComments(node: Node) { // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b43345bcbf5..fecff11b1b4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -115,7 +115,8 @@ namespace ts { case SyntaxKind.TupleType: return visitNodes(cbNodes, (node).elementTypes); case SyntaxKind.UnionType: - return visitNodes(cbNodes, (node).types); + case SyntaxKind.IntersectionType: + return visitNodes(cbNodes, (node).types); case SyntaxKind.ParenthesizedType: return visitNode(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: @@ -156,6 +157,8 @@ namespace ts { case SyntaxKind.YieldExpression: return visitNode(cbNode, (node).asteriskToken) || visitNode(cbNode, (node).expression); + case SyntaxKind.AwaitExpression: + return visitNode(cbNode, (node).expression); case SyntaxKind.PostfixUnaryExpression: return visitNode(cbNode, (node).operand); case SyntaxKind.BinaryExpression: @@ -407,7 +410,7 @@ namespace ts { export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile { return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); } - + /* @internal */ export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) { return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); @@ -582,7 +585,7 @@ namespace ts { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for + // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. if (isJavaScript(fileName)) { @@ -679,20 +682,28 @@ namespace ts { setContextFlag(val, ParserContextFlags.Yield); } - function setGeneratorParameterContext(val: boolean) { - setContextFlag(val, ParserContextFlags.GeneratorParameter); - } - function setDecoratorContext(val: boolean) { setContextFlag(val, ParserContextFlags.Decorator); } - function doOutsideOfContext(flags: ParserContextFlags, func: () => T): T { - let currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + function setAwaitContext(val: boolean) { + setContextFlag(val, ParserContextFlags.Await); + } + + function doOutsideOfContext(context: ParserContextFlags, func: () => T): T { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + let contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); let result = func(); - setContextFlag(true, currentContextFlags); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); return result; } @@ -700,80 +711,81 @@ namespace ts { return func(); } - function allowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - setDisallowInContext(false); + function doInsideOfContext(context: ParserContextFlags, func: () => T): T { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + let contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); let result = func(); - setDisallowInContext(true); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); return result; } - // no need to do anything special if 'in' is already allowed. + // no need to do anything special as we are already in all of the requested contexts return func(); } + function allowInAnd(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.DisallowIn, func); + } + function disallowInAnd(func: () => T): T { - if (contextFlags & ParserContextFlags.DisallowIn) { - // no need to do anything special if 'in' is already disallowed. - return func(); - } - - setDisallowInContext(true); - let result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(ParserContextFlags.DisallowIn, func); } function doInYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - // no need to do anything special if we're already in the [Yield] context. - return func(); - } - - setYieldContext(true); - let result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(ParserContextFlags.Yield, func); } function doOutsideOfYieldContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Yield) { - setYieldContext(false); - let result = func(); - setYieldContext(true); - return result; - } - - // no need to do anything special if we're not in the [Yield] context. - return func(); + return doOutsideOfContext(ParserContextFlags.Yield, func); } function doInDecoratorContext(func: () => T): T { - if (contextFlags & ParserContextFlags.Decorator) { - // no need to do anything special if we're already in the [Decorator] context. - return func(); - } + return doInsideOfContext(ParserContextFlags.Decorator, func); + } - setDecoratorContext(true); - let result = func(); - setDecoratorContext(false); - return result; + function doInAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Await, func); + } + + function doOutsideOfAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Await, func); + } + + function doInYieldAndAwaitContext(func: () => T): T { + return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + + function doOutsideOfYieldAndAwaitContext(func: () => T): T { + return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func); + } + + function inContext(flags: ParserContextFlags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & ParserContextFlags.Yield) !== 0; - } - - function inGeneratorParameterContext() { - return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; + return inContext(ParserContextFlags.Yield); } function inDisallowInContext() { - return (contextFlags & ParserContextFlags.DisallowIn) !== 0; + return inContext(ParserContextFlags.DisallowIn); } function inDecoratorContext() { - return (contextFlags & ParserContextFlags.Decorator) !== 0; + return inContext(ParserContextFlags.Decorator); + } + + function inAwaitContext() { + return inContext(ParserContextFlags.Await); } function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { @@ -831,7 +843,7 @@ namespace ts { function scanJsxIdentifier(): SyntaxKind { return token = scanner.scanJsxIdentifier(); } - + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -892,6 +904,12 @@ namespace ts { return false; } + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === SyntaxKind.AwaitKeyword && inAwaitContext()) { + return false; + } + return token > SyntaxKind.LastReservedWord; } @@ -1066,29 +1084,16 @@ namespace ts { } function parseComputedPropertyName(): ComputedPropertyName { - // PropertyName[Yield,GeneratorParameter] : - // LiteralPropertyName - // [+GeneratorParameter] ComputedPropertyName - // [~GeneratorParameter] ComputedPropertyName[?Yield] - // - // ComputedPropertyName[Yield] : - // [ AssignmentExpression[In, ?Yield] ] - // + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] let node = createNode(SyntaxKind.ComputedPropertyName); parseExpected(SyntaxKind.OpenBracketToken); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - let yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } - node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); @@ -1224,7 +1229,7 @@ namespace ts { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // - // extends {} { + // extends {} { // extends {}, // extends {} extends // extends {} implements @@ -1241,6 +1246,11 @@ namespace ts { return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function isHeritageClauseExtendsOrImplementsKeyword(): boolean { if (token === SyntaxKind.ImplementsKeyword || token === SyntaxKind.ExtendsKeyword) { @@ -1834,7 +1844,7 @@ namespace ts { do { templateSpans.push(parseTemplateSpan()); } - while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle) + while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; @@ -1849,7 +1859,7 @@ namespace ts { let literal: LiteralExpression; if (token === SyntaxKind.CloseBraceToken) { - reScanTemplateToken() + reScanTemplateToken(); literal = parseLiteralNode(); } else { @@ -1978,11 +1988,10 @@ namespace ts { setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + node.name = parseIdentifierOrPattern(); if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifier(token)) { // in cases like @@ -1998,7 +2007,7 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in @@ -2011,18 +2020,24 @@ namespace ts { return finishNode(node); } + function parseBindingElementInitializer(inParameter: boolean) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } + function parseParameterInitializer() { return parseInitializer(/*inParameter*/ true); } function fillSignature( - returnToken: SyntaxKind, - yieldAndGeneratorParameterContext: boolean, - requireCompleteParameterList: boolean, - signature: SignatureDeclaration): void { + returnToken: SyntaxKind, + yieldContext: boolean, + awaitContext: boolean, + requireCompleteParameterList: boolean, + signature: SignatureDeclaration): void { + let returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); @@ -2033,36 +2048,31 @@ namespace ts { } } - // Note: after careful analysis of the grammar, it does not appear to be possible to - // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling - // this FormalParameters production either always sets both to true, or always sets - // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext: boolean, requireCompleteParameterList: boolean) { - // FormalParameters[Yield,GeneratorParameter] : - // ... + function parseParameterList(yieldContext: boolean, awaitContext: boolean, requireCompleteParameterList: boolean) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] // - // FormalParameter[Yield,GeneratorParameter] : - // BindingElement[?Yield, ?GeneratorParameter] + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] // - // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 - // SingleNameBinding[?Yield, ?GeneratorParameter] - // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt - // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt // - // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(SyntaxKind.OpenParenToken)) { let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); + let savedAwaitContext = inAwaitContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); let result = parseDelimitedList(ParsingContext.Parameters, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); + setAwaitContext(savedAwaitContext); if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return @@ -2095,7 +2105,7 @@ namespace ts { if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -2170,7 +2180,7 @@ namespace ts { node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node) + return finishNode(node); } function parsePropertyOrMethodSignature(): Declaration { @@ -2184,8 +2194,8 @@ namespace ts { method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [GeneratorParameter] - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, method); + // [Yield] nor [Await] + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } @@ -2324,7 +2334,7 @@ namespace ts { if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(SyntaxKind.EqualsGreaterThanToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } @@ -2397,22 +2407,30 @@ namespace ts { return type; } - function parseUnionTypeOrHigher(): TypeNode { - let type = parseArrayTypeOrHigher(); - if (token === SyntaxKind.BarToken) { + function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { + let type = parseConstituentType(); + if (token === operator) { let types = >[type]; types.pos = type.pos; - while (parseOptional(SyntaxKind.BarToken)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - let node = createNode(SyntaxKind.UnionType, type.pos); + let node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken); + } + + function parseUnionTypeOrHigher(): TypeNode { + return parseUnionOrIntersectionType(SyntaxKind.UnionType, parseIntersectionTypeOrHigher, SyntaxKind.BarToken); + } + function isStartOfFunctionType(): boolean { if (token === SyntaxKind.LessThanToken) { return true; @@ -2454,18 +2472,7 @@ namespace ts { function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - let savedYieldContext = inYieldContext(); - let savedGeneratorParameterContext = inGeneratorParameterContext(); - - setYieldContext(false); - setGeneratorParameterContext(false); - - let result = parseTypeWorker(); - - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - - return result; + return doOutsideOfContext(ParserContextFlags.TypeExcludesFlags, parseTypeWorker); } function parseTypeWorker(): TypeNode { @@ -2525,10 +2532,11 @@ namespace ts { case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: case SyntaxKind.LessThanToken: + case SyntaxKind.AwaitKeyword: case SyntaxKind.YieldKeyword: - // Yield always starts an expression. Either it is an identifier (in which case + // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in - // a generator, or in strict mode (or both)) and it started a yield expression. + // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. return true; default: // Error tolerance. If we see the start of some binary operator, we consider @@ -2552,6 +2560,10 @@ namespace ts { isStartOfExpression(); } + function allowInAndParseExpression(): Expression { + return allowInAnd(parseExpression); + } + function parseExpression(): Expression { // Expression[in]: // AssignmentExpression[in] @@ -2725,14 +2737,13 @@ namespace ts { node.parameters.end = parameter.end; node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression(): Expression { let triState = isParenthesizedArrowFunctionExpression(); - if (triState === Tristate.False) { // It's definitely not a parenthesized arrow function expression. return undefined; @@ -2751,12 +2762,14 @@ namespace ts { return undefined; } + let isAsync = !!(arrowFunction.flags & NodeFlags.Async); + // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. - var lastToken = token; + let lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) - ? parseArrowFunctionExpressionBody() + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -2767,7 +2780,7 @@ namespace ts { // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression(): Tristate { - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { + if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken || token === SyntaxKind.AsyncKeyword) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } @@ -2782,6 +2795,16 @@ namespace ts { } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === SyntaxKind.AsyncKeyword) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return Tristate.False; + } + if (token !== SyntaxKind.OpenParenToken && token !== SyntaxKind.LessThanToken) { + return Tristate.False; + } + } + let first = token; let second = nextToken(); @@ -2869,7 +2892,7 @@ namespace ts { if (isArrowFunctionInJsx) { return Tristate.True; } - + return Tristate.False; } @@ -2884,6 +2907,9 @@ namespace ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); + setModifiers(node, parseModifiersForArrowFunction()); + let isAsync = !!(node.flags & NodeFlags.Async); + // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -2891,7 +2917,7 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -2914,9 +2940,9 @@ namespace ts { return node; } - function parseArrowFunctionExpressionBody(): Block | Expression { + function parseArrowFunctionExpressionBody(isAsync: boolean): Block | Expression { if (token === SyntaxKind.OpenBraceToken) { - return parseFunctionBlock(/*allowYield*/ false, /*ignoreMissingOpenBrace*/ false); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } if (token !== SyntaxKind.SemicolonToken && @@ -2938,10 +2964,12 @@ namespace ts { // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(/*allowYield*/ false, /*ignoreMissingOpenBrace*/ true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } - return parseAssignmentExpressionOrHigher(); + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand: Expression): Expression { @@ -3106,7 +3134,31 @@ namespace ts { return finishNode(node); } + function isAwaitExpression(): boolean { + if (token === SyntaxKind.AwaitKeyword) { + if (inAwaitContext()) { + return true; + } + + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + + return false; + } + + function parseAwaitExpression() { + var node = createNode(SyntaxKind.AwaitExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher(): UnaryExpression { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } + switch (token) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -3125,7 +3177,7 @@ namespace ts { if (sourceFile.languageVariant !== LanguageVariant.JSX) { return parseTypeAssertion(); } - if(lookAhead(nextTokenIsIdentifier)) { + if (lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(); } // Fall through @@ -3255,7 +3307,7 @@ namespace ts { node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - + function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement { let opening = parseJsxOpeningOrSelfClosingElement(); if (opening.kind === SyntaxKind.JsxOpeningElement) { @@ -3297,7 +3349,7 @@ namespace ts { let saveParsingContext = parsingContext; parsingContext |= 1 << ParsingContext.JsxChildren; - while(true) { + while (true) { token = scanner.reScanJsxToken(); if (token === SyntaxKind.LessThanSlashToken) { break; @@ -3315,7 +3367,7 @@ namespace ts { return result; } - + function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement { let fullStart = scanner.getStartPos(); @@ -3340,10 +3392,10 @@ namespace ts { return finishNode(node); } - + function parseJsxElementName(): EntityName { scanJsxIdentifier(); - let elementName: EntityName = parseIdentifier(); + let elementName: EntityName = parseIdentifierName(); while (parseOptional(SyntaxKind.DotToken)) { scanJsxIdentifier(); let node = createNode(SyntaxKind.QualifiedName, elementName.pos); @@ -3425,7 +3477,7 @@ namespace ts { continue; } - // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName + // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) { let indexedAccess = createNode(SyntaxKind.ElementAccessExpression, expression.pos); indexedAccess.expression = expression; @@ -3547,7 +3599,7 @@ namespace ts { case SyntaxKind.CommaToken: // foo, case SyntaxKind.OpenBraceToken: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this - // as an invocation expression. Instead, we want to parse out the expression + // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. default: @@ -3574,6 +3626,15 @@ namespace ts { return parseArrayLiteralExpression(); case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(); + case SyntaxKind.AsyncKeyword: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } + + return parseFunctionExpression(); case SyntaxKind.ClassKeyword: return parseClassExpression(); case SyntaxKind.FunctionKeyword: @@ -3689,23 +3750,36 @@ namespace ts { } function parseFunctionExpression(): FunctionExpression { - // GeneratorExpression : - // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // // FunctionExpression: - // function BindingIdentifieropt(FormalParameters) { FunctionBody } + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } let saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } + let node = createNode(SyntaxKind.FunctionExpression); + setModifiers(node, parseModifiers()); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!node.asteriskToken, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlock(/*allowYield*/ !!node.asteriskToken, /* ignoreMissingOpenBrace */ false); + + let isGenerator = !!node.asteriskToken; + let isAsync = !!(node.flags & NodeFlags.Async); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); + if (saveDecoratorContext) { setDecoratorContext(true); } + return finishNode(node); } @@ -3738,11 +3812,14 @@ namespace ts { return finishNode(node); } - function parseFunctionBlock(allowYield: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { let savedYieldContext = inYieldContext(); setYieldContext(allowYield); - // We may be in a [Decorator] context when parsing a function expression or + let savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + + // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. let saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { @@ -3756,6 +3833,7 @@ namespace ts { } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } @@ -4004,6 +4082,11 @@ namespace ts { return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === SyntaxKind.FunctionKeyword && !scanner.hasPrecedingLineBreak(); + } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); @@ -4047,6 +4130,7 @@ namespace ts { case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case SyntaxKind.AsyncKeyword: case SyntaxKind.DeclareKeyword: nextToken(); // ASI takes effect for this modifier. @@ -4066,10 +4150,12 @@ namespace ts { return true; } continue; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.AbstractKeyword: nextToken(); continue; default: @@ -4115,6 +4201,7 @@ namespace ts { case SyntaxKind.ImportKeyword: return isStartOfDeclaration(); + case SyntaxKind.AsyncKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.ModuleKeyword: @@ -4142,7 +4229,7 @@ namespace ts { } function isLetDeclaration() { - // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { // or [. return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } @@ -4193,7 +4280,7 @@ namespace ts { return parseDebuggerStatement(); case SyntaxKind.AtToken: return parseDeclaration(); - + case SyntaxKind.AsyncKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.TypeKeyword: case SyntaxKind.ModuleKeyword: @@ -4206,6 +4293,7 @@ namespace ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PublicKeyword: + case SyntaxKind.AbstractKeyword: case SyntaxKind.StaticKeyword: if (isStartOfDeclaration()) { return parseDeclaration(); @@ -4247,7 +4335,7 @@ namespace ts { default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration - // would follow. For recovery and error reporting purposes, return an incomplete declaration. + // would follow. For recovery and error reporting purposes, return an incomplete declaration. let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; @@ -4262,13 +4350,13 @@ namespace ts { return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === SyntaxKind.StringLiteral); } - function parseFunctionBlockOrSemicolon(isGenerator: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseFunctionBlockOrSemicolon(isGenerator: boolean, isAsync: boolean, diagnosticMessage?: DiagnosticMessage): Block { if (token !== SyntaxKind.OpenBraceToken && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS @@ -4280,7 +4368,7 @@ namespace ts { let node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -4297,7 +4385,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } @@ -4403,8 +4491,10 @@ namespace ts { parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!node.asteriskToken, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, Diagnostics.or_expected); + let isGenerator = !!node.asteriskToken; + let isAsync = !!(node.flags & NodeFlags.Async); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected); return finishNode(node); } @@ -4413,8 +4503,8 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, Diagnostics.or_expected); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); return finishNode(node); } @@ -4425,8 +4515,10 @@ namespace ts { method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ !!asteriskToken, /*requireCompleteParameterList*/ false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + let isGenerator = !!asteriskToken; + let isAsync = !!(method.flags & NodeFlags.Async); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } @@ -4458,7 +4550,7 @@ namespace ts { function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassElement { let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); let name = parsePropertyName(); - + // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. let questionToken = parseOptionalToken(SyntaxKind.QuestionToken); @@ -4479,8 +4571,8 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext*/ false, /*requireCompleteParameterList*/ false, node); - node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false); + fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } @@ -4602,6 +4694,7 @@ namespace ts { modifiers = []; modifiers.pos = modifierStart; } + flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } @@ -4612,6 +4705,24 @@ namespace ts { return modifiers; } + function parseModifiersForArrowFunction(): ModifiersArray { + let flags = 0; + let modifiers: ModifiersArray; + if (token === SyntaxKind.AsyncKeyword) { + let modifierStart = scanner.getStartPos(); + let modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + + return modifiers; + } + function parseClassElement(): ClassElement { if (token === SyntaxKind.SemicolonToken) { let result = createNode(SyntaxKind.SemicolonClassElement); @@ -4670,7 +4781,7 @@ namespace ts { } function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration { - var node = createNode(kind, fullStart); + let node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); @@ -4679,13 +4790,9 @@ namespace ts { node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); if (parseExpected(SyntaxKind.OpenBraceToken)) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -4696,14 +4803,11 @@ namespace ts { } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(ParsingContext.HeritageClauses, parseHeritageClause); } return undefined; @@ -4904,7 +5008,7 @@ namespace ts { } function parseImportClause(identifier: Identifier, fullStart: number) { - //ImportClause: + // ImportClause: // ImportedDefaultBinding // NameSpaceImport // NamedImports @@ -5197,7 +5301,7 @@ namespace ts { /* @internal */ export function parseJSDocTypeExpression(start: number, length: number): JSDocTypeExpression { scanner.setText(sourceText, start, length); - + // Prime the first token for us to start processing. token = nextToken(); @@ -5212,15 +5316,15 @@ namespace ts { } function parseJSDocTopLevelType(): JSDocType { - var type = parseJSDocType(); + let type = parseJSDocType(); if (token === SyntaxKind.BarToken) { - var unionType = createNode(SyntaxKind.JSDocUnionType, type.pos); + let unionType = createNode(SyntaxKind.JSDocUnionType, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === SyntaxKind.EqualsToken) { - var optionalType = createNode(SyntaxKind.JSDocOptionalType, type.pos); + let optionalType = createNode(SyntaxKind.JSDocOptionalType, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -5534,9 +5638,9 @@ namespace ts { let tags: NodeArray; let pos: number; - - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The + + // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I + // considered using an actual Scanner, but this would complicate things. The // scanner would need to know it was in a Doc Comment. Otherwise, it would then // produce comments *inside* the doc comment. In the end it was just easier to // write a simple scanner rather than go that route. @@ -5551,13 +5655,13 @@ namespace ts { let canParseTag = true; let seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { + for (pos = start + "/**".length; pos < end; ) { let ch = content.charCodeAt(pos); pos++; if (ch === CharacterCodes.at && canParseTag) { parseTag(); - + // Once we parse out a tag, we cannot keep parsing out tags on this line. canParseTag = false; continue; @@ -5823,7 +5927,7 @@ namespace ts { if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true) + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once @@ -5887,7 +5991,7 @@ namespace ts { // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - let result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true) + let result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } @@ -5902,8 +6006,9 @@ namespace ts { return; function visitNode(node: IncrementalNode) { + let text = ''; if (aggressiveChecks && shouldCheckNode(node)) { - var text = oldText.substring(node.pos, node.end); + text = oldText.substring(node.pos, node.end); } // Ditch any existing LS children we may have created. This way we can avoid @@ -6253,17 +6358,17 @@ namespace ts { interface IncrementalElement extends TextRange { parent?: Node; - intersectsChange: boolean + intersectsChange: boolean; length?: number; _children: Node[]; } export interface IncrementalNode extends Node, IncrementalElement { - hasBeenIncrementallyParsed: boolean + hasBeenIncrementallyParsed: boolean; } interface IncrementalNodeArray extends NodeArray, IncrementalElement { - length: number + length: number; } // Allows finding nodes in the source file at a certain position in an efficient manner. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 09bd6fbdd28..5ce4846b43b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -11,12 +11,12 @@ namespace ts { export const version = "1.5.3"; export function findConfigFile(searchPath: string): string { - var fileName = "tsconfig.json"; + let fileName = "tsconfig.json"; while (true) { if (sys.fileExists(fileName)) { return fileName; } - var parentPath = getDirectoryPath(searchPath); + let parentPath = getDirectoryPath(searchPath); if (parentPath === searchPath) { break; } @@ -35,7 +35,7 @@ namespace ts { // otherwise use toLowerCase as a canonical form. return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - + // returned by CScript sys environment let unsupportedFileEncodingErrorCode = -2147024809; @@ -79,7 +79,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { try { - var start = new Date().getTime(); + let start = new Date().getTime(); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); sys.writeFile(fileName, data, writeByteOrderMark); ioWriteTime += new Date().getTime() - start; @@ -104,14 +104,14 @@ namespace ts { }; } - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] { - let diagnostics = program.getOptionsDiagnostics().concat( - program.getSyntacticDiagnostics(sourceFile), - program.getGlobalDiagnostics(), - program.getSemanticDiagnostics(sourceFile)); + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] { + let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat( + program.getSyntacticDiagnostics(sourceFile, cancellationToken), + program.getGlobalDiagnostics(cancellationToken), + program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return sortAndDeduplicateDiagnostics(diagnostics); @@ -233,10 +233,15 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult { + function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { + return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); + } + + function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } @@ -265,55 +270,88 @@ namespace ts { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] { + function getDiagnosticsHelper( + sourceFile: SourceFile, + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[], + cancellationToken: CancellationToken): Diagnostic[] { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } let allDiagnostics: Diagnostic[] = []; forEach(program.getSourceFiles(), sourceFile => { - addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - let typeChecker = getDiagnosticsProducingTypeChecker(); + function runWithCancellationToken(func: () => T): T { + try { + return func(); + } + catch (e) { + if (e instanceof OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } - Debug.assert(!!sourceFile.bindDiagnostics); - let bindDiagnostics = sourceFile.bindDiagnostics; - let checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { - if (!isDeclarationFile(sourceFile)) { - let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - // Don't actually write any files since we're just getting diagnostics. - var writeFile: WriteFileCallback = () => { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + throw e; } } + function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return runWithCancellationToken(() => { + let typeChecker = getDiagnosticsProducingTypeChecker(); + + Debug.assert(!!sourceFile.bindDiagnostics); + let bindDiagnostics = sourceFile.bindDiagnostics; + let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return runWithCancellationToken(() => { + if (!isDeclarationFile(sourceFile)) { + let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + let writeFile: WriteFileCallback = () => { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + } + }); + } + function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); @@ -358,7 +396,7 @@ namespace ts { } } else { - var nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); + let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = Diagnostics.File_0_not_found; @@ -458,7 +496,7 @@ namespace ts { let moduleNameText = (moduleNameExpr).text; if (moduleNameText) { let searchPath = basePath; - let searchName: string; + let searchName: string; while (true) { searchName = normalizePath(combinePaths(searchPath, moduleNameText)); if (forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, moduleNameExpr))) { @@ -475,7 +513,7 @@ namespace ts { } else if (node.kind === SyntaxKind.ModuleDeclaration && (node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. + // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted @@ -487,7 +525,7 @@ namespace ts { let moduleName = nameLiteral.text; if (moduleName) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. let searchName = normalizePath(combinePaths(basePath, moduleName)); forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral)); @@ -626,7 +664,7 @@ namespace ts { } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet + // We cannot use createDiagnosticFromNode because nodes do not have parents yet let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } @@ -653,7 +691,7 @@ namespace ts { } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly + // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path commonSourceDirectory += directorySeparator; @@ -669,11 +707,16 @@ namespace ts { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); } } - + if (options.emitDecoratorMetadata && !options.experimentalDecorators) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + + if (options.experimentalAsyncFunctions && + options.target !== ScriptTarget.ES6) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 1cae922f082..d52f96c912b 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -32,19 +32,20 @@ namespace ts { setScriptTarget(scriptTarget: ScriptTarget): void; setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; - // Invokes the provided callback then unconditionally restores the scanner to the state it + // Invokes the provided callback then unconditionally restores the scanner to the state it // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. lookAhead(callback: () => T): T; // Invokes the provided callback. If the callback returns something falsy, then it restores - // the scanner to the state it was in immediately prior to invoking the callback. If the + // the scanner to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the scanner state is not rolled back. The result // of invoking the callback is returned from this function. tryScan(callback: () => T): T; } let textToToken: Map = { + "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, "boolean": SyntaxKind.BooleanKeyword, @@ -106,6 +107,8 @@ namespace ts { "while": SyntaxKind.WhileKeyword, "with": SyntaxKind.WithKeyword, "yield": SyntaxKind.YieldKeyword, + "async": SyntaxKind.AsyncKeyword, + "await": SyntaxKind.AwaitKeyword, "of": SyntaxKind.OfKeyword, "{": SyntaxKind.OpenBraceToken, "}": SyntaxKind.CloseBraceToken, @@ -272,7 +275,7 @@ namespace ts { return textToToken[s]; } - /* @internal */ + /* @internal */ export function computeLineStarts(text: string): number[] { let result: number[] = new Array(); let pos = 0; @@ -304,22 +307,22 @@ namespace ts { return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); } - /* @internal */ + /* @internal */ export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number { Debug.assert(line >= 0 && line < lineStarts.length); return lineStarts[line] + character; } - /* @internal */ + /* @internal */ export function getLineStarts(sourceFile: SourceFile): number[] { return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); } - /* @internal */ + /* @internal */ export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) { let lineNumber = binarySearch(lineStarts, position); if (lineNumber < 0) { - // If the actual position was not found, + // If the actual position was not found, // the binary search returns the negative value of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 // then the search will return -2 @@ -352,125 +355,125 @@ namespace ts { ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark; - } + } - export function isLineBreak(ch: number): boolean { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. + export function isLineBreak(ch: number): boolean { + // ES5 7.3: + // The ECMAScript line terminator characters are listed in Table 3. + // Table 3: Line Terminator Characters + // Code Unit Value Name Formal Name + // \u000A Line Feed + // \u000D Carriage Return + // \u2028 Line separator + // \u2029 Paragraph separator + // Only the characters in Table 3 are treated as line terminators. Other new line or line + // breaking characters are treated as white space but not as line terminators. - return ch === CharacterCodes.lineFeed || - ch === CharacterCodes.carriageReturn || - ch === CharacterCodes.lineSeparator || - ch === CharacterCodes.paragraphSeparator; - } + return ch === CharacterCodes.lineFeed || + ch === CharacterCodes.carriageReturn || + ch === CharacterCodes.lineSeparator || + ch === CharacterCodes.paragraphSeparator; + } - function isDigit(ch: number): boolean { - return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; - } + function isDigit(ch: number): boolean { + return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; + } - /* @internal */ - export function isOctalDigit(ch: number): boolean { - return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; - } + /* @internal */ + export function isOctalDigit(ch: number): boolean { + return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; + } - export function couldStartTrivia(text: string, pos: number): boolean { - // Keep in sync with skipTrivia - let ch = text.charCodeAt(pos); - switch (ch) { - case CharacterCodes.carriageReturn: - case CharacterCodes.lineFeed: - case CharacterCodes.tab: - case CharacterCodes.verticalTab: - case CharacterCodes.formFeed: - case CharacterCodes.space: - case CharacterCodes.slash: - // starts of normal trivia - case CharacterCodes.lessThan: - case CharacterCodes.equals: - case CharacterCodes.greaterThan: - // Starts of conflict marker trivia - return true; - default: - return ch > CharacterCodes.maxAsciiCharacter; - } - } + export function couldStartTrivia(text: string, pos: number): boolean { + // Keep in sync with skipTrivia + let ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + case CharacterCodes.lineFeed: + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + case CharacterCodes.slash: + // starts of normal trivia + case CharacterCodes.lessThan: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + // Starts of conflict marker trivia + return true; + default: + return ch > CharacterCodes.maxAsciiCharacter; + } + } - /* @internal */ - export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { - // Keep in sync with couldStartTrivia - while (true) { - let ch = text.charCodeAt(pos); - switch (ch) { - case CharacterCodes.carriageReturn: - if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { - pos++; - } - case CharacterCodes.lineFeed: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case CharacterCodes.tab: - case CharacterCodes.verticalTab: - case CharacterCodes.formFeed: - case CharacterCodes.space: - pos++; - continue; - case CharacterCodes.slash: - if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; + /* @internal */ + export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number { + // Keep in sync with couldStartTrivia + while (true) { + let ch = text.charCodeAt(pos); + switch (ch) { + case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { + pos++; + } + case CharacterCodes.lineFeed: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + pos++; + continue; + case CharacterCodes.slash: + if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; - case CharacterCodes.lessThan: - case CharacterCodes.equals: - case CharacterCodes.greaterThan: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; + case CharacterCodes.lessThan: + case CharacterCodes.equals: + case CharacterCodes.greaterThan: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; - default: - if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } + default: + if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } - // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + // All conflict markers consist of the same character repeated seven times. If it is + // a <<<<<<< or >>>>>>> marker then it is also followd by a space. let mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text: string, pos: number) { @@ -525,12 +528,12 @@ namespace ts { return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and + // Extract comments from the given source text starting at the given position. If trailing is + // false, whitespace is skipped until the first line break and comments between that location + // and the next token are returned.If trailing is true, comments occurring between the given + // position and the next line break are returned.The return value is an array containing a + // TextRange for each comment. Single-line comment ranges include the beginning '//' characters + // but not the ending line break. Multi - line comment ranges include the beginning '/* and // ending '*/' characters.The return value is undefined if no comments were found. function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; @@ -626,9 +629,9 @@ namespace ts { ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } - - /* @internal */ - // Creates a scanner over a (possibly unspecified) range of a piece of text. + + /* @internal */ + // Creates a scanner over a (possibly unspecified) range of a piece of text. export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant = LanguageVariant.Standard, @@ -637,16 +640,16 @@ namespace ts { start?: number, length?: number): Scanner { // Current position (end position of text of current token) - let pos: number; + let pos: number; // end of text - let end: number; + let end: number; // Start position of whitespace before current token - let startPos: number; + let startPos: number; // Start position of text of current token - let tokenPos: number; + let tokenPos: number; let token: SyntaxKind; let tokenValue: string; @@ -732,7 +735,7 @@ namespace ts { } return +(text.substring(start, pos)); } - + /** * Scans the given number of hexadecimal digits in the text, * returning -1 if the given number is unavailable. @@ -740,7 +743,7 @@ namespace ts { function scanExactNumberOfHexDigits(count: number): number { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } - + /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. @@ -818,7 +821,7 @@ namespace ts { pos++; let start = pos; - let contents = "" + let contents = ""; let resultingToken: SyntaxKind; while (true) { @@ -913,13 +916,13 @@ namespace ts { pos++; return scanExtendedUnicodeEscape(); } - + // '\uDDDD' - return scanHexadecimalEscape(/*numDigits*/ 4) - + return scanHexadecimalEscape(/*numDigits*/ 4); + case CharacterCodes.x: // '\xDD' - return scanHexadecimalEscape(/*numDigits*/ 2) + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". @@ -931,31 +934,31 @@ namespace ts { case CharacterCodes.lineFeed: case CharacterCodes.lineSeparator: case CharacterCodes.paragraphSeparator: - return "" + return ""; default: return String.fromCharCode(ch); } } - + function scanHexadecimalEscape(numDigits: number): string { let escapedValue = scanExactNumberOfHexDigits(numDigits); - + if (escapedValue >= 0) { return String.fromCharCode(escapedValue); } else { error(Diagnostics.Hexadecimal_digit_expected); - return "" + return ""; } } - + function scanExtendedUnicodeEscape(): string { let escapedValue = scanMinimumNumberOfHexDigits(1); let isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { - error(Diagnostics.Hexadecimal_digit_expected) + error(Diagnostics.Hexadecimal_digit_expected); isInvalidExtendedEscape = true; } else if (escapedValue > 0x10FFFF) { @@ -982,18 +985,18 @@ namespace ts { return utf16EncodeAsString(escapedValue); } - + // Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. function utf16EncodeAsString(codePoint: number): string { Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - + if (codePoint <= 65535) { return String.fromCharCode(codePoint); } - + let codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; let codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; - + return String.fromCharCode(codeUnit1, codeUnit2); } @@ -1055,7 +1058,7 @@ namespace ts { let value = 0; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - let numberOfDigits = 0; + let numberOfDigits = 0; while (true) { let ch = text.charCodeAt(pos); let valueOfCh = ch - CharacterCodes._0; @@ -1129,7 +1132,7 @@ namespace ts { tokenValue = scanString(); return token = SyntaxKind.StringLiteral; case CharacterCodes.backtick: - return token = scanTemplateAndSetTokenValue() + return token = scanTemplateAndSetTokenValue(); case CharacterCodes.percent: if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.PercentEqualsToken; @@ -1441,14 +1444,14 @@ namespace ts { // regex. Report error and return what we have so far. if (p >= end) { tokenIsUnterminated = true; - error(Diagnostics.Unterminated_regular_expression_literal) + error(Diagnostics.Unterminated_regular_expression_literal); break; } let ch = text.charCodeAt(p); if (isLineBreak(ch)) { tokenIsUnterminated = true; - error(Diagnostics.Unterminated_regular_expression_literal) + error(Diagnostics.Unterminated_regular_expression_literal); break; } @@ -1540,7 +1543,7 @@ namespace ts { let ch = text.charCodeAt(pos); if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { pos++; - } + } else { break; } @@ -1549,7 +1552,7 @@ namespace ts { } return token; } - + function speculationHelper(callback: () => T, isLookahead: boolean): T { let savePos = pos; let saveStartPos = startPos; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a47d6959ba8..443c1c4789c 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -41,16 +41,16 @@ namespace ts { function getWScriptSystem(): System { - var fso = new ActiveXObject("Scripting.FileSystemObject"); + let fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); + let fileStream = new ActiveXObject("ADODB.Stream"); fileStream.Type = 2 /*text*/; - var binaryStream = new ActiveXObject("ADODB.Stream"); + let binaryStream = new ActiveXObject("ADODB.Stream"); binaryStream.Type = 1 /*binary*/; - var args: string[] = []; - for (var i = 0; i < WScript.Arguments.length; i++) { + let args: string[] = []; + for (let i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); } @@ -68,7 +68,7 @@ namespace ts { // Load file and read the first two bytes into a string with no interpretation fileStream.Charset = "x-ansi"; fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; + let bom = fileStream.ReadText(2) || ""; // Position must be at 0 before encoding can be changed fileStream.Position = 0; // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 @@ -114,28 +114,28 @@ namespace ts { } function getNames(collection: any): string[]{ - var result: string[] = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + let result: string[] = []; + for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { result.push(e.item().Name); } return result.sort(); } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { - var result: string[] = []; + let result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); visitDirectory(path); return result; function visitDirectory(path: string) { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); + let folder = fso.GetFolder(path || "."); + let files = getNames(folder.files); for (let current of files) { let name = combinePaths(path, current); if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) { result.push(name); } } - var subfolders = getNames(folder.subfolders); + let subfolders = getNames(folder.subfolders); for (let current of subfolders) { let name = combinePaths(path, current); if (!contains(exclude, getCanonicalPath(name))) { @@ -197,14 +197,14 @@ namespace ts { if (!_fs.existsSync(fileName)) { return undefined; } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; + let buffer = _fs.readFileSync(fileName); + let len = buffer.length; if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; + for (let i = 0; i < len; i += 2) { + let temp = buffer[i]; buffer[i] = buffer[i + 1]; buffer[i + 1] = temp; } @@ -236,17 +236,17 @@ namespace ts { } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { - var result: string[] = []; + let result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); visitDirectory(path); return result; function visitDirectory(path: string) { - var files = _fs.readdirSync(path || ".").sort(); - var directories: string[] = []; + let files = _fs.readdirSync(path || ".").sort(); + let directories: string[] = []; for (let current of files) { - var name = combinePaths(path, current); + let name = combinePaths(path, current); if (!contains(exclude, getCanonicalPath(name))) { - var stat = _fs.statSync(name); + let stat = _fs.statSync(name); if (stat.isFile()) { if (!extension || fileExtensionIs(name, extension)) { result.push(name); @@ -331,4 +331,4 @@ namespace ts { return undefined; // Unsupported host } })(); -} \ No newline at end of file +} diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2a01774fbca..a657cc8c314 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -11,15 +11,15 @@ namespace ts { * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); return false; } - var language = matchResult[1]; - var territory = matchResult[3]; + let language = matchResult[1]; + let territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. if (!trySetLanguageAndTerritory(language, territory, errors) && @@ -33,10 +33,10 @@ namespace ts { } function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean { - var compilerFilePath = normalizePath(sys.getExecutingFilePath()); - var containingDirectoryPath = getDirectoryPath(compilerFilePath); + let compilerFilePath = normalizePath(sys.getExecutingFilePath()); + let containingDirectoryPath = getDirectoryPath(compilerFilePath); - var filePath = combinePaths(containingDirectoryPath, language); + let filePath = combinePaths(containingDirectoryPath, language); if (territory) { filePath = filePath + "-" + territory; @@ -49,8 +49,9 @@ namespace ts { } // TODO: Add codePage support for readFile? + let fileContents = ''; try { - var fileContents = sys.readFile(filePath); + fileContents = sys.readFile(filePath); } catch (e) { errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath)); @@ -68,7 +69,7 @@ namespace ts { } function countLines(program: Program): number { - var count = 0; + let count = 0; forEach(program.getSourceFiles(), file => { count += getLineStarts(file).length; }); @@ -76,27 +77,27 @@ namespace ts { } function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string { - var diagnostic = createCompilerDiagnostic.apply(undefined, arguments); + let diagnostic = createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } function reportDiagnostic(diagnostic: Diagnostic) { - var output = ""; - + let output = ""; + if (diagnostic.file) { - var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } - var category = DiagnosticCategory[diagnostic.category].toLowerCase(); + let category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; sys.write(output); } function reportDiagnostics(diagnostics: Diagnostic[]) { - for (var i = 0; i < diagnostics.length; i++) { + for (let i = 0; i < diagnostics.length; i++) { reportDiagnostic(diagnostics[i]); } } @@ -133,15 +134,15 @@ namespace ts { } export function executeCommandLine(args: string[]): void { - var commandLine = parseCommandLine(args); - var configFileName: string; // Configuration file name (if any) - var configFileWatcher: FileWatcher; // Configuration file watcher - var cachedProgram: Program; // Program cached from last compilation - var rootFileNames: string[]; // Root fileNames for compilation - var compilerOptions: CompilerOptions; // Compiler options for compilation - var compilerHost: CompilerHost; // Compiler host - var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host - var timerHandle: number; // Handle for 0.25s wait timer + let commandLine = parseCommandLine(args); + let configFileName: string; // Configuration file name (if any) + let configFileWatcher: FileWatcher; // Configuration file watcher + let cachedProgram: Program; // Program cached from last compilation + let rootFileNames: string[]; // Root fileNames for compilation + let compilerOptions: CompilerOptions; // Compiler options for compilation + let compilerHost: CompilerHost; // Compiler host + let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host + let timerHandle: number; // Handle for 0.25s wait timer if (commandLine.options.locale) { if (!isJSONSupported()) { @@ -181,7 +182,7 @@ namespace ts { } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { - var searchPath = normalizePath(sys.getCurrentDirectory()); + let searchPath = normalizePath(sys.getCurrentDirectory()); configFileName = findConfigFile(searchPath); } @@ -247,14 +248,14 @@ namespace ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { // Return existing SourceFile object if one is available if (cachedProgram) { - var sourceFile = cachedProgram.getSourceFile(fileName); + let sourceFile = cachedProgram.getSourceFile(fileName); // A modified source file has no watcher and should not be reused if (sourceFile && sourceFile.fileWatcher) { return sourceFile; } } // Use default host function - var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); + let sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { // Attach a file watcher sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile)); @@ -265,7 +266,7 @@ namespace ts { // Change cached program to the given program function setCachedProgram(program: Program) { if (cachedProgram) { - var newSourceFiles = program ? program.getSourceFiles() : undefined; + let newSourceFiles = program ? program.getSourceFiles() : undefined; forEach(cachedProgram.getSourceFiles(), sourceFile => { if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) { if (sourceFile.fileWatcher) { @@ -316,8 +317,8 @@ namespace ts { checkTime = 0; emitTime = 0; - var program = createProgram(fileNames, compilerOptions, compilerHost); - var exitStatus = compileProgram(); + let program = createProgram(fileNames, compilerOptions, compilerHost); + let exitStatus = compileProgram(); if (compilerOptions.listFiles) { forEach(program.getSourceFiles(), file => { @@ -326,7 +327,7 @@ namespace ts { } if (compilerOptions.diagnostics) { - var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; + let memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); reportCountStatistic("Nodes", program.getNodeCount()); @@ -354,18 +355,18 @@ namespace ts { return { program, exitStatus }; function compileProgram(): ExitStatus { - // First get any syntactic errors. - var diagnostics = program.getSyntacticDiagnostics(); + // First get any syntactic errors. + let diagnostics = program.getSyntacticDiagnostics(); reportDiagnostics(diagnostics); - // If we didn't have any syntactic errors, then also try getting the global and + // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. if (diagnostics.length === 0) { - var diagnostics = program.getGlobalDiagnostics(); + let diagnostics = program.getGlobalDiagnostics(); reportDiagnostics(diagnostics); if (diagnostics.length === 0) { - var diagnostics = program.getSemanticDiagnostics(); + let diagnostics = program.getSemanticDiagnostics(); reportDiagnostics(diagnostics); } } @@ -378,7 +379,7 @@ namespace ts { } // Otherwise, emit and report any errors we ran into. - var emitOutput = program.emit(); + let emitOutput = program.emit(); reportDiagnostics(emitOutput.diagnostics); // If the emitter didn't emit anything, then pass that value along. @@ -401,22 +402,22 @@ namespace ts { } function printHelp() { - var output = ""; + let output = ""; // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); + let syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; + let examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length; + let marginLength = Math.max(syntaxLength, examplesLength); // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); + let syntax = makePadding(marginLength - syntaxLength); syntax += "tsc [" + getDiagnosticText(Diagnostics.options) + "] [" + getDiagnosticText(Diagnostics.file) + " ...]"; output += getDiagnosticText(Diagnostics.Syntax_Colon_0, syntax); output += sys.newLine + sys.newLine; // Build up the list of examples. - var padding = makePadding(marginLength); + let padding = makePadding(marginLength); output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; output += padding + "tsc --out file.js file.ts" + sys.newLine; output += padding + "tsc @args.txt" + sys.newLine; @@ -425,17 +426,17 @@ namespace ts { output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine; // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") - var optsList = filter(optionDeclarations.slice(), v => !v.experimental); + let optsList = filter(optionDeclarations.slice(), v => !v.experimental); optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); // We want our descriptions to align at the same column in our output, // so we keep track of the longest option usage string. - var marginLength = 0; - var usageColumn: string[] = []; // Things like "-d, --declaration" go in here. - var descriptionColumn: string[] = []; + marginLength = 0; + let usageColumn: string[] = []; // Things like "-d, --declaration" go in here. + let descriptionColumn: string[] = []; - for (var i = 0; i < optsList.length; i++) { - var option = optsList[i]; + for (let i = 0; i < optsList.length; i++) { + let option = optsList[i]; // If an option lacks a description, // it is not officially supported. @@ -443,7 +444,7 @@ namespace ts { continue; } - var usageText = " "; + let usageText = " "; if (option.shortName) { usageText += "-" + option.shortName; usageText += getParamType(option); @@ -461,15 +462,15 @@ namespace ts { } // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">"; + let usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">"; usageColumn.push(usageText); descriptionColumn.push(getDiagnosticText(Diagnostics.Insert_command_line_options_and_files_from_a_file)); marginLength = Math.max(usageText.length, marginLength); // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; + for (let i = 0; i < usageColumn.length; i++) { + let usage = usageColumn[i]; + let description = descriptionColumn[i]; output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638c4ef3c83..e0f16a00c2b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -140,8 +140,11 @@ namespace ts { StaticKeyword, YieldKeyword, // Contextual keywords + AbstractKeyword, AsKeyword, AnyKeyword, + AsyncKeyword, + AwaitKeyword, BooleanKeyword, ConstructorKeyword, DeclareKeyword, @@ -188,6 +191,7 @@ namespace ts { ArrayType, TupleType, UnionType, + IntersectionType, ParenthesizedType, // Binding patterns ObjectBindingPattern, @@ -208,6 +212,7 @@ namespace ts { DeleteExpression, TypeOfExpression, VoidExpression, + AwaitExpression, PrefixUnaryExpression, PostfixUnaryExpression, BinaryExpression, @@ -268,7 +273,7 @@ namespace ts { // Module references ExternalModuleReference, - //JSX + // JSX JsxElement, JsxSelfClosingElement, JsxOpeningElement, @@ -356,17 +361,19 @@ namespace ts { Private = 0x00000020, // Property/Method Protected = 0x00000040, // Property/Method Static = 0x00000080, // Property/Method - Default = 0x00000100, // Function/Class (export default declaration) - MultiLine = 0x00000200, // Multi-line array or object literal - Synthetic = 0x00000400, // Synthetic node (for full fidelity) - DeclarationFile = 0x00000800, // Node is a .d.ts file - Let = 0x00001000, // Variable declaration - Const = 0x00002000, // Variable declaration - OctalLiteral = 0x00004000, // Octal numeric literal - Namespace = 0x00008000, // Namespace declaration - ExportContext = 0x00010000, // Export context (initialized by binding) + Abstract = 0x00000100, // Class/Method/ConstructSignature + Async = 0x00000200, // Property/Method/Function + Default = 0x00000400, // Function/Class (export default declaration) + MultiLine = 0x00000800, // Multi-line array or object literal + Synthetic = 0x00001000, // Synthetic node (for full fidelity) + DeclarationFile = 0x00002000, // Node is a .d.ts file + Let = 0x00004000, // Variable declaration + Const = 0x00008000, // Variable declaration + OctalLiteral = 0x00010000, // Octal numeric literal + Namespace = 0x00020000, // Namespace declaration + ExportContext = 0x00040000, // Export context (initialized by binding) - Modifier = Export | Ambient | Public | Private | Protected | Static | Default, + Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } @@ -376,37 +383,40 @@ namespace ts { None = 0, // If this node was parsed in a context where 'in-expressions' are not allowed. - DisallowIn = 1 << 1, + DisallowIn = 1 << 0, // If this node was parsed in the 'yield' context created when parsing a generator. - Yield = 1 << 2, - - // If this node was parsed in the parameters of a generator. - GeneratorParameter = 1 << 3, + Yield = 1 << 1, // If this node was parsed as part of a decorator - Decorator = 1 << 4, + Decorator = 1 << 2, + + // If this node was parsed in the 'await' context created when parsing an async function. + Await = 1 << 3, // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ThisNodeHasError = 1 << 5, + ThisNodeHasError = 1 << 4, // This node was parsed in a JavaScript file and can be processed differently. For example // its type can be specified usign a JSDoc comment. - JavaScriptFile = 1 << 6, + JavaScriptFile = 1 << 5, // Context flags set directly by the parser. - ParserGeneratedFlags = DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, + ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await, + + // Exclude these flags when parsing a Type + TypeExcludesFlags = Yield | Await, // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ThisNodeOrAnySubNodesHasError = 1 << 7, + ThisNodeOrAnySubNodesHasError = 1 << 6, // Used to know if we've computed data from children and cached it in this node. - HasAggregatedChildData = 1 << 8 + HasAggregatedChildData = 1 << 7 } export const enum JsxFlags { @@ -658,10 +668,14 @@ namespace ts { elementTypes: NodeArray; } - export interface UnionTypeNode extends TypeNode { + export interface UnionOrIntersectionTypeNode extends TypeNode { types: NodeArray; } + export interface UnionTypeNode extends UnionOrIntersectionTypeNode { } + + export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { } + export interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -726,6 +740,10 @@ namespace ts { expression: UnaryExpression; } + export interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } + export interface YieldExpression extends Expression { asteriskToken?: Node; expression?: Expression; @@ -1037,7 +1055,7 @@ namespace ts { } export interface ModuleBlock extends Node, Statement { - statements: NodeArray + statements: NodeArray; } export interface ImportEqualsDeclaration extends Declaration, Statement { @@ -1153,7 +1171,7 @@ namespace ts { export interface JSDocTypeReference extends JSDocType { name: EntityName; - typeArguments: NodeArray + typeArguments: NodeArray; } export interface JSDocOptionalType extends JSDocType { @@ -1178,8 +1196,8 @@ namespace ts { } export interface JSDocRecordMember extends PropertyDeclaration { - name: Identifier | LiteralExpression, - type?: JSDocType + name: Identifier | LiteralExpression; + type?: JSDocType; } export interface JSDocComment extends Node { @@ -1272,6 +1290,15 @@ namespace ts { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } + export class OperationCanceledException { } + + export interface CancellationToken { + isCancellationRequested(): boolean; + + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } + export interface Program extends ScriptReferenceHost { /** * Get a list of files in the program @@ -1288,15 +1315,15 @@ namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; - getOptionsDiagnostics(): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - /** + /** * Gets a type checker that can be used to semantically analyze source fils in the program. */ getTypeChecker(): TypeChecker; @@ -1317,15 +1344,15 @@ namespace ts { export interface SourceMapSpan { /** Line number in the .js file. */ - emittedLine: number; + emittedLine: number; /** Column number in the .js file. */ - emittedColumn: number; + emittedColumn: number; /** Line number in the .ts file. */ - sourceLine: number; + sourceLine: number; /** Column number in the .ts file. */ - sourceColumn: number; + sourceColumn: number; /** Optional name (index into names array) associated with this span. */ - nameIndex?: number; + nameIndex?: number; /** .ts file (index into sources array) associated with this span */ sourceIndex: number; } @@ -1405,9 +1432,9 @@ namespace ts { getJsxIntrinsicTagNames(): Symbol[]; // Should not be called directly. Should only be accessed through the Program instance. - /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /* @internal */ getGlobalDiagnostics(): Diagnostic[]; - /* @internal */ getEmitResolver(sourceFile?: SourceFile): EmitResolver; + /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; /* @internal */ getNodeCount(): number; /* @internal */ getIdentifierCount(): number; @@ -1479,7 +1506,7 @@ namespace ts { NotAccessible, CannotBeNamed } - + export interface TypePredicate { parameterName: string; parameterIndex: number; @@ -1499,7 +1526,7 @@ namespace ts { /* @internal */ export interface SymbolAccessiblityResult extends SymbolVisibilityResult { - errorModuleName?: string // If the symbol is not visible from module, module's name + errorModuleName?: string; // If the symbol is not visible from module, module's name } /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator @@ -1579,7 +1606,7 @@ namespace ts { Merged = 0x02000000, // Merged symbol (created during program binding) Transient = 0x04000000, // Transient symbol (created during type check) Prototype = 0x08000000, // Prototype property (no source representation) - UnionProperty = 0x10000000, // Property in union type + SyntheticProperty = 0x10000000, // Property in union or intersection type Optional = 0x20000000, // Optional property ExportStar = 0x40000000, // Export * declaration @@ -1603,8 +1630,8 @@ namespace ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts + InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), @@ -1629,7 +1656,7 @@ namespace ts { Export = ExportNamespace | ExportType | ExportValue, /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during + // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module, } @@ -1649,7 +1676,7 @@ namespace ts { /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums } - /* @internal */ + /* @internal */ export interface SymbolLinks { target?: Symbol; // Resolved (non-alias) target of an alias type?: Type; // Type of value symbol @@ -1658,40 +1685,45 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value - unionType?: UnionType; // Containing union type for union property + containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration } - /* @internal */ + /* @internal */ export interface TransientSymbol extends Symbol, SymbolLinks { } export interface SymbolTable { [index: string]: Symbol; } - /* @internal */ + /* @internal */ export const enum NodeCheckFlags { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body EmitExtends = 0x00000008, // Emit __extends - SuperInstance = 0x00000010, // Instance 'super' reference - SuperStatic = 0x00000020, // Static 'super' reference - ContextChecked = 0x00000040, // Contextual types have been assigned + EmitDecorate = 0x00000010, // Emit __decorate + EmitParam = 0x00000020, // Emit __param helper for decorators + EmitAwaiter = 0x00000040, // Emit __awaiter + EmitGenerator = 0x00000080, // Emit __generator + SuperInstance = 0x00000100, // Instance 'super' reference + SuperStatic = 0x00000200, // Static 'super' reference + ContextChecked = 0x00000400, // Contextual types have been assigned + LexicalArguments = 0x00000800, + CaptureArguments = 0x00001000, // Lexical 'arguments' used in body (for async functions) // Values for enum members have been computed, and any errors have been reported for them. - EnumValuesComputed = 0x00000080, - BlockScopedBindingInLoop = 0x00000100, - EmitDecorate = 0x00000200, // Emit __decorate - EmitParam = 0x00000400, // Emit __param helper for decorators - LexicalModuleMergesWithClass = 0x00000800, // Instantiated lexical module declaration is merged with a previous class declaration. + EnumValuesComputed = 0x00002000, + BlockScopedBindingInLoop = 0x00004000, + LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. } - /* @internal */ + /* @internal */ export interface NodeLinks { resolvedType?: Type; // Cached type of type node + resolvedAwaitedType?: Type; // Cached awaited type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result flags?: NodeCheckFlags; // Set of flags specific to Node @@ -1722,27 +1754,30 @@ namespace ts { Interface = 0x00000800, // Interface Reference = 0x00001000, // Generic type reference Tuple = 0x00002000, // Tuple - Union = 0x00004000, // Union - Anonymous = 0x00008000, // Anonymous - Instantiated = 0x00010000, // Instantiated anonymous type + Union = 0x00004000, // Union (T | U) + Intersection = 0x00008000, // Intersection (T & U) + Anonymous = 0x00010000, // Anonymous + Instantiated = 0x00020000, // Instantiated anonymous type /* @internal */ - FromSignature = 0x00020000, // Created for signature assignment check - ObjectLiteral = 0x00040000, // Originates in an object literal + FromSignature = 0x00040000, // Created for signature assignment check + ObjectLiteral = 0x00080000, // Originates in an object literal /* @internal */ - ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type + ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type /* @internal */ - ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type - ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6 + ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type + ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6 - /* @internal */ + /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, - /* @internal */ + /* @internal */ Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum, StringLike = String | StringLiteral, NumberLike = Number | Enum, ObjectType = Class | Interface | Reference | Tuple | Anonymous, - /* @internal */ - RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral + UnionOrIntersection = Union | Intersection, + StructuredType = ObjectType | Union | Intersection, + /* @internal */ + RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral } // Properties common to all types @@ -1752,7 +1787,7 @@ namespace ts { symbol?: Symbol; // Symbol associated with type (if any) } - /* @internal */ + /* @internal */ // Intrinsic types (TypeFlags.Intrinsic) export interface IntrinsicType extends Type { intrinsicName: string; // Name of intrinsic type @@ -1800,7 +1835,7 @@ namespace ts { baseArrayType: TypeReference; // Array where T is best common type of element types } - export interface UnionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ reducedType: Type; // Reduced union type (all subtypes removed) @@ -1808,9 +1843,13 @@ namespace ts { resolvedProperties: SymbolTable; // Cache of resolved properties } + export interface UnionType extends UnionOrIntersectionType { } + + export interface IntersectionType extends UnionOrIntersectionType { } + /* @internal */ - // Resolved object or union type - export interface ResolvedType extends ObjectType, UnionType { + // Resolved object, union, or intersection type + export interface ResolvedType extends ObjectType, UnionOrIntersectionType { members: SymbolTable; // Properties by name properties: Symbol[]; // Properties callSignatures: Signature[]; // Call signatures of type @@ -1963,6 +2002,7 @@ namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; + experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; @@ -2166,14 +2206,9 @@ namespace ts { verticalTab = 0x0B, // \v } - export interface CancellationToken { - isCancellationRequested(): boolean; - } - export interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getDefaultLibFileName(options: CompilerOptions): string; - getCancellationToken? (): CancellationToken; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ee6ab9999ed..5174589cdcf 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3,9 +3,9 @@ /* @internal */ namespace ts { export interface ReferencePathMatchResult { - fileReference?: FileReference - diagnosticMessage?: DiagnosticMessage - isNoDefaultLib?: boolean + fileReference?: FileReference; + diagnosticMessage?: DiagnosticMessage; + isNoDefaultLib?: boolean; } export interface SynthesizedNode extends Node { @@ -16,9 +16,11 @@ namespace ts { export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration { let declarations = symbol.declarations; - for (let declaration of declarations) { - if (declaration.kind === kind) { - return declaration; + if (declarations) { + for (let declaration of declarations) { + if (declaration.kind === kind) { + return declaration; + } } } @@ -70,7 +72,7 @@ namespace ts { } export function releaseStringWriter(writer: StringSymbolWriter) { - writer.clear() + writer.clear(); stringWriters.push(writer); } @@ -81,7 +83,7 @@ namespace ts { // Returns true if this node contains a parse error anywhere underneath it. export function containsParseError(node: Node): boolean { aggregateChildData(node); - return (node.parserContextFlags & ParserContextFlags.ThisNodeOrAnySubNodesHasError) !== 0 + return (node.parserContextFlags & ParserContextFlags.ThisNodeOrAnySubNodesHasError) !== 0; } function aggregateChildData(node: Node): void { @@ -92,7 +94,7 @@ namespace ts { let thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) || forEachChild(node, containsParseError); - // If so, mark ourselves accordingly. + // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { node.parserContextFlags |= ParserContextFlags.ThisNodeOrAnySubNodesHasError; } @@ -129,13 +131,13 @@ namespace ts { // Returns true if this node is missing from the actual source code. 'missing' is different // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // in the tree), it is definitel missing. HOwever, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't // get anything in the source code that it expects at that location. For example: // // let a: ; // - // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source + // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. @@ -144,7 +146,7 @@ namespace ts { return true; } - return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken; + return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken; } export function nodeIsPresent(node: Node) { @@ -166,7 +168,7 @@ namespace ts { return getTokenPosOfNode(node, sourceFile); } - return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { @@ -211,7 +213,7 @@ namespace ts { isCatchClauseVariableDeclaration(declaration); } - // Gets the nearest enclosing block scope container that has the provided node + // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { let current = node.parent; @@ -307,7 +309,7 @@ namespace ts { } if (errorNode === undefined) { - // If we don't have a better node, then just set the error on the first token of + // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } @@ -339,10 +341,10 @@ namespace ts { return node; } - // Returns the node flags for this node and all relevant parent nodes. This is done so that + // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't - // stored on the variable declaration directly, but on the containing variable statement + // stored on the variable declaration directly, but on the containing variable statement // (if it has one). Similarly, flags for let/const are store on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. @@ -406,7 +408,7 @@ namespace ts { } } - export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/ + export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; export function isTypeNode(node: Node): boolean { if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { @@ -662,7 +664,7 @@ namespace ts { node = node.parent; break; case SyntaxKind.Decorator: - // Decorators are always applied outside of the body of a class or method. + // Decorators are always applied outside of the body of a class or method. if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. @@ -717,7 +719,7 @@ namespace ts { node = node.parent; break; case SyntaxKind.Decorator: - // Decorators are always applied outside of the body of a class or method. + // Decorators are always applied outside of the body of a class or method. if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. @@ -747,11 +749,27 @@ namespace ts { } } + export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression { + if (node) { + switch (node.kind) { + case SyntaxKind.TypeReference: + return (node).typeName; + case SyntaxKind.ExpressionWithTypeArguments: + return (node).expression; + case SyntaxKind.Identifier: + case SyntaxKind.QualifiedName: + return (node); + } + } + + return undefined; + } + export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; } - + // Will either be a CallExpression, NewExpression, or Decorator. return (node).expression; } @@ -933,7 +951,7 @@ namespace ts { } export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { - let moduleState = getModuleInstanceState(node) + let moduleState = getModuleInstanceState(node); return moduleState === ModuleInstanceState.Instantiated || (preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly); } @@ -1015,7 +1033,7 @@ namespace ts { export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag { if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param + // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. let parameterName = (parameter.name).text; @@ -1285,7 +1303,7 @@ namespace ts { if (isNoDefaultLibRegEx.exec(comment)) { return { isNoDefaultLib: true - } + }; } else { let matchResult = fullTripleSlashReferencePathRegEx.exec(comment); @@ -1321,6 +1339,10 @@ namespace ts { return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken; } + export function isAsyncFunctionLike(node: Node): boolean { + return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node); + } + /** * A declaration has a dynamic name if both of the following are true: * 1. The declaration has a computed property name @@ -1371,14 +1393,16 @@ namespace ts { export function isModifier(token: SyntaxKind): boolean { switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsyncKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DefaultKeyword: return true; } return false; @@ -1395,7 +1419,7 @@ namespace ts { } return node; } - + export function nodeStartsNewLexicalEnvironment(n: Node): boolean { return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; } @@ -1406,14 +1430,12 @@ namespace ts { export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { let node = createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } export function createSynthesizedNodeArray(): NodeArray { - var array = >[]; + let array = >[]; array.pos = -1; array.end = -1; return array; @@ -1497,7 +1519,7 @@ namespace ts { } } } - + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -1883,10 +1905,12 @@ namespace ts { case SyntaxKind.PublicKeyword: return NodeFlags.Public; case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected; case SyntaxKind.PrivateKeyword: return NodeFlags.Private; + case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract; case SyntaxKind.ExportKeyword: return NodeFlags.Export; case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; case SyntaxKind.ConstKeyword: return NodeFlags.Const; case SyntaxKind.DefaultKeyword: return NodeFlags.Default; + case SyntaxKind.AsyncKeyword: return NodeFlags.Async; } return 0; } @@ -1970,7 +1994,7 @@ namespace ts { } /** - * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. */ function getExpandedCharCodes(input: string): number[] { @@ -2013,7 +2037,7 @@ namespace ts { * Converts a string to a base-64 encoded ASCII string. */ export function convertToBase64(input: string): string { - var result = ""; + let result = ""; let charCodes = getExpandedCharCodes(input); let i = 0; let length = charCodes.length; @@ -2055,7 +2079,7 @@ namespace ts { return lineFeed; } else if (sys) { - return sys.newLine + return sys.newLine; } return carriageReturnLineFeed; } @@ -2067,11 +2091,11 @@ namespace ts { } export function textSpanEnd(span: TextSpan) { - return span.start + span.length + return span.start + span.length; } export function textSpanIsEmpty(span: TextSpan) { - return span.length === 0 + return span.length === 0; } export function textSpanContainsPosition(span: TextSpan, position: number) { @@ -2099,7 +2123,7 @@ namespace ts { } export function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; } export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) { @@ -2160,10 +2184,10 @@ namespace ts { export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); /** - * Called to merge all the changes that occurred across several versions of a script snapshot + * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will - * have a text change from V1 to V2, V2 to V3, ..., Vn. - * + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * * This function will then merge those changes into a single change range valid between V1 and * Vn. */ @@ -2194,17 +2218,17 @@ namespace ts { // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------------------------------------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------------------------------------------------- - // | \ - // | \ - // T2 | \ - // | \ - // | \ + // | \ + // | \ + // T2 | \ + // | \ + // | \ // ------------------------------------------------------------------------------------------------------- // // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial @@ -2212,17 +2236,17 @@ namespace ts { // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------*------------------------------------------ - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ----------------------------------------$-------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // (Note the dots represent the newly inferrred start. @@ -2233,22 +2257,22 @@ namespace ts { // // 0 10 20 30 40 50 60 70 80 90 100 // --------------------------------------------------------------------------------*---------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // In other words (in this case), we're recognizing that the second edit happened after where the first edit // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started - // that's the same as if we started at char 80 instead of 60. + // that's the same as if we started at char 80 instead of 60. // // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter // than pusing the first edit forward to match the second, we'll push the second edit forward to match the @@ -2258,7 +2282,7 @@ namespace ts { // semantics: { { start: 10, length: 70 }, newLength: 60 } // // The math then works out as follows. - // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the + // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the // final result like so: // // { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0717ed68e83..c374f8add60 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -190,14 +190,14 @@ module FourSlash { return "\nMarker: " + currentTestState.lastKnownMarker + "\nChecking: " + msg + "\n\n"; } - export class TestCancellationToken implements ts.CancellationToken { + export class TestCancellationToken implements ts.HostCancellationToken { // 0 - cancelled // >0 - not cancelled // <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled - private static NotCancelled: number = -1; - private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCancelled; - public isCancellationRequested(): boolean { + private static NotCanceled: number = -1; + private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled; + public isCancellationRequested(): boolean { if (this.numberOfCallsBeforeCancellation < 0) { return false; } @@ -216,7 +216,7 @@ module FourSlash { } public resetCancelled(): void { - this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCancelled; + this.numberOfCallsBeforeCancellation = TestCancellationToken.NotCanceled; } } @@ -704,13 +704,61 @@ module FourSlash { } } - public verifyCompletionListDoesNotContain(symbol: string) { + /** + * Verify that the completion list does NOT contain the given symbol. + * The symbol is considered matched with the symbol in the list if and only if all given parameters must matched. + * When any parameter is omitted, the parameter is ignored during comparison and assumed that the parameter with + * that property of the symbol in the list. + * @param symbol the name of symbol + * @param expectedText the text associated with the symbol + * @param expectedDocumentation the documentation text associated with the symbol + * @param expectedKind the kind of symbol (see ScriptElementKind) + */ + public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string) { + let that = this; + function filterByTextOrDocumentation(entry: ts.CompletionEntry) { + let details = that.getCompletionEntryDetails(entry.name); + let documentation = ts.displayPartsToString(details.documentation); + let text = ts.displayPartsToString(details.displayParts); + if (expectedText && expectedDocumentation) { + return (documentation === expectedDocumentation && text === expectedText) ? true : false; + } + else if (expectedText && !expectedDocumentation) { + return text === expectedText ? true : false; + } + else if (expectedDocumentation && !expectedText) { + return documentation === expectedDocumentation ? true : false; + } + // Because expectedText and expectedDocumentation are undefined, we assume that + // users don't care to compare them so we will treat that entry as if the entry has matching text and documentation + // and keep it in the list of filtered entry. + return true; + } this.scenarioActions.push(''); this.scenarioActions.push(''); var completions = this.getCompletionListAtCaret(); - if (completions && completions.entries.filter(e => e.name === symbol).length !== 0) { - this.raiseError('Completion list did contain ' + symbol); + if (completions) { + let filterCompletions = completions.entries.filter(e => e.name === symbol); + filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind) : filterCompletions; + filterCompletions = filterCompletions.filter(filterByTextOrDocumentation); + if (filterCompletions.length !== 0) { + // After filtered using all present criterion, if there are still symbol left in the list + // then these symbols must meet the criterion for Not supposed to be in the list. So we + // raise an error + let error = "Completion list did contain \'" + symbol + "\'."; + let details = this.getCompletionEntryDetails(filterCompletions[0].name); + if (expectedText) { + error += "Expected text: " + expectedText + " to equal: " + ts.displayPartsToString(details.displayParts) + "."; + } + if (expectedDocumentation) { + error += "Expected documentation: " + expectedDocumentation + " to equal: " + ts.displayPartsToString(details.documentation) + "."; + } + if (expectedKind) { + error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "." + } + this.raiseError(error); + } } } @@ -2167,7 +2215,7 @@ module FourSlash { var itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); - this.raiseError('Expected "' + JSON.stringify({ name: name, text: text, documentation: documentation, kind: kind }) + '" to be in list [' + itemsString + ']'); + this.raiseError('Expected "' + JSON.stringify({ name, text, documentation, kind }) + '" to be in list [' + itemsString + ']'); } private findFile(indexOrName: any) { diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index d11c5e639e5..0db01c30f32 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -35,9 +35,9 @@ class FourSlashRunner extends RunnerBase { this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); } - this.tests.forEach((fn: string) => { - describe(fn, () => { - fn = ts.normalizeSlashes(fn); + this.tests.forEach((fn: string) => { + describe(fn, () => { + fn = ts.normalizeSlashes(fn); var justName = fn.replace(/^.*[\\\/]/, ''); // Convert to relative path @@ -45,7 +45,7 @@ class FourSlashRunner extends RunnerBase { if (testIndex >= 0) fn = fn.substr(testIndex); if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { - it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => { + it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => { FourSlash.runFourSlashTest(this.basePath, this.testType, fn); }); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index bd54d24cf73..9f26887ff90 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1055,6 +1055,10 @@ module Harness { case 'emitdecoratormetadata': options.emitDecoratorMetadata = setting.value === 'true'; break; + + case 'experimentalasyncfunctions': + options.experimentalAsyncFunctions = setting.value === 'true'; + break; case 'noemithelpers': options.noEmitHelpers = setting.value === 'true'; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8eb77817533..6cb92df5948 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -103,14 +103,11 @@ module Harness.LanguageService { } } - class CancellationToken { - public static None: CancellationToken = new CancellationToken(null); - - constructor(private cancellationToken: ts.CancellationToken) { - } + class DefaultHostCancellationToken implements ts.HostCancellationToken { + public static Instance = new DefaultHostCancellationToken(); public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return false; } } @@ -124,8 +121,8 @@ module Harness.LanguageService { export class LanguageServiceAdapterHost { protected fileNameToScript: ts.Map = {}; - constructor(protected cancellationToken: ts.CancellationToken = CancellationToken.None, - protected settings = ts.getDefaultCompilerOptions()) { + constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, + protected settings = ts.getDefaultCompilerOptions()) { } public getNewLine(): string { @@ -173,8 +170,8 @@ module Harness.LanguageService { /// Native adapter class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { - getCompilationSettings(): ts.CompilerOptions { return this.settings; } - getCancellationToken(): ts.CancellationToken { return this.cancellationToken; } + getCompilationSettings() { return this.settings; } + getCancellationToken() { return this.cancellationToken; } getCurrentDirectory(): string { return ""; } getDefaultLibFileName(): string { return ""; } getScriptFileNames(): string[] { return this.getFilenames(); } @@ -194,7 +191,7 @@ module Harness.LanguageService { export class NativeLanugageServiceAdapter implements LanguageServiceAdapter { private host: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new NativeLanguageServiceHost(cancellationToken, options); } getHost() { return this.host; } @@ -206,7 +203,7 @@ module Harness.LanguageService { /// Shim adapter class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options); } @@ -218,7 +215,7 @@ module Harness.LanguageService { positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); } getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); } - getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); } + getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); } getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); } getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); } getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } @@ -399,7 +396,7 @@ module Harness.LanguageService { export class ShimLanugageServiceAdapter implements LanguageServiceAdapter { private host: ShimLanguageServiceHost; private factory: ts.TypeScriptServicesFactory; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new ShimLanguageServiceHost(cancellationToken, options); this.factory = new TypeScript.Services.TypeScriptServicesFactory(); } @@ -446,7 +443,7 @@ module Harness.LanguageService { class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost { private client: ts.server.SessionClient; - constructor(cancellationToken: ts.CancellationToken, settings: ts.CompilerOptions) { + constructor(cancellationToken: ts.HostCancellationToken, settings: ts.CompilerOptions) { super(cancellationToken, settings); } @@ -575,7 +572,7 @@ module Harness.LanguageService { export class ServerLanugageServiceAdapter implements LanguageServiceAdapter { private host: SessionClientHost; private client: ts.server.SessionClient; - constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { // This is the main host that tests use to direct tests var clientHost = new SessionClientHost(cancellationToken, options); var client = new ts.server.SessionClient(clientHost); diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 1e9c6470421..13d93302f18 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -49,6 +49,7 @@ if (testConfigFile !== '') { if (!option) { continue; } + switch (option) { case 'compiler': runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 78971965664..f177c421f4f 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1169,3 +1169,16 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index e1f06f11009..32e8fb45ce4 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1092,16 +1092,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -2259,12 +2254,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. */ - getElementsByName(elementName: string): NodeList; + getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. @@ -2442,8 +2437,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "wbr"): NodeListOf; getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; getElementsByTagName(tagname: "xmp"): NodeListOf; - getElementsByTagName(tagname: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; /** * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ @@ -2716,6 +2711,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec scrollTop: number; scrollWidth: number; tagName: string; + id: string; + className: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; getAttributeNode(name: string): Attr; @@ -2895,8 +2892,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "wbr"): NodeListOf; getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; msGetRegionContent(): MSRangeCollection; @@ -3077,7 +3074,7 @@ interface FormData { declare var FormData: { prototype: FormData; - new(): FormData; + new (form?: HTMLFormElement): FormData; } interface GainNode extends AudioNode { @@ -3370,8 +3367,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -3815,14 +3811,12 @@ declare var HTMLDocument: { interface HTMLElement extends Element { accessKey: string; children: HTMLCollection; - className: string; contentEditable: string; dataset: DOMStringMap; dir: string; draggable: boolean; hidden: boolean; hideFocus: boolean; - id: string; innerHTML: string; innerText: string; isContentEditable: boolean; @@ -3909,7 +3903,7 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -6119,8 +6113,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -8722,6 +8715,7 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; + className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -10281,8 +10275,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10354,8 +10347,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -10463,33 +10455,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -10998,11 +10975,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -11845,8 +11819,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -12012,6 +11985,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window toolbar: BarProp; top: Window; window: Window; + URL: URL; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; @@ -12515,7 +12489,7 @@ interface NavigatorStorageUtils { interface NodeSelector { querySelector(selectors: string): Element; - querySelectorAll(selectors: string): NodeList; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { @@ -12563,7 +12537,7 @@ interface SVGLocatable { } interface SVGStylable { - className: SVGAnimatedString; + className: any; style: CSSStyleDeclaration; } @@ -12650,8 +12624,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -12827,6 +12800,7 @@ declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var URL: URL; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; @@ -12978,4 +12952,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 71df6d77436..f3c0a1418fe 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -3573,17 +3573,6 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - /** * Represents the completion of an asynchronous operation */ @@ -3603,6 +3592,7 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; [Symbol.toStringTag]: string; } diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 1ab2c7d418f..5c41869e487 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -571,8 +571,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -807,8 +806,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index da132754311..1a758886350 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -318,7 +318,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -344,7 +344,7 @@ namespace ts.formatting { // decorators this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); + this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index a4cc7ec2ad5..bc506bc22f9 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -2,7 +2,7 @@ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; - export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] { + export function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] { let patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index ead9bc519ce..e822052a5b2 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -228,7 +228,7 @@ namespace ts.NavigationBar { function merge(target: ts.NavigationBarItem, source: ts.NavigationBarItem) { // First, add any spans in the source to the target. - target.spans.push.apply(target.spans, source.spans); + addRange(target.spans, source.spans); if (source.childItems) { if (!target.childItems) { @@ -465,7 +465,7 @@ namespace ts.NavigationBar { // are not properties will be filtered out later by createChildItem. let nodes: Node[] = removeDynamicallyNamedProperties(node); if (constructor) { - nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name))); + addRange(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name))); } childItems = getItemsWorker(sortNodes(nodes), createChildItem); diff --git a/src/services/services.ts b/src/services/services.ts index 018a11fc4bb..10e38f98613 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -345,7 +345,7 @@ namespace ts { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), jsDocCommentTextRange => { let cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment); + addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } @@ -365,7 +365,7 @@ namespace ts { declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => { let cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); + addRange(jsDocCommentParts, cleanedJsDocComment); } }); } @@ -944,6 +944,10 @@ namespace ts { } } + export interface HostCancellationToken { + isCancellationRequested(): boolean; + } + // // Public interface of the host of a language service instance. // @@ -955,7 +959,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: CompilerOptions): string; log? (s: string): void; @@ -1424,6 +1428,9 @@ namespace ts { // class X {} export const classElement = "class"; + // var x = class X {} + export const localClassElement = "local class"; + // interface Y {} export const interfaceElement = "interface"; @@ -1494,6 +1501,7 @@ namespace ts { export const exportedModifier = "export"; export const ambientModifier = "declare"; export const staticModifier = "static"; + export const abstractModifier = "abstract"; } export class ClassificationTypeNames { @@ -1614,26 +1622,6 @@ namespace ts { }; } - export class OperationCanceledException { } - - export class CancellationTokenObject { - - public static None: CancellationTokenObject = new CancellationTokenObject(null) - - constructor(private cancellationToken: CancellationToken) { - } - - public isCancellationRequested() { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - } - - public throwIfCancellationRequested(): void { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - } - } - // Cache host information about scrip Should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. @@ -2400,6 +2388,21 @@ namespace ts { return ScriptElementKind.unknown; } + class CancellationTokenObject implements CancellationToken { + constructor(private cancellationToken: HostCancellationToken) { + } + + public isCancellationRequested() { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService { let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); let ruleProvider: formatting.RulesProvider; @@ -2604,7 +2607,7 @@ namespace ts { function getSyntacticDiagnostics(fileName: string) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** @@ -2626,13 +2629,13 @@ namespace ts { // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + let semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + let declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return concatenate(semanticDiagnostics, declarationDiagnostics); } @@ -2784,6 +2787,7 @@ namespace ts { case SyntaxKind.ExportKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DefaultKeyword: + case SyntaxKind.AbstractKeyword: } } } @@ -2794,21 +2798,19 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + return program.getOptionsDiagnostics(cancellationToken).concat( + program.getGlobalDiagnostics(cancellationToken)); } - /// Completion - function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string { - let displayName = symbol.getName(); - if (displayName) { - // If this is the default export, get the name of the declaration if it exists - if (displayName === "default") { - let localSymbol = getLocalSymbolForExportDefault(symbol); - if (localSymbol && localSymbol.name) { - displayName = symbol.valueDeclaration.localSymbol.name; - } - } + /** + * Get the name to be display in completion from a given symbol. + * + * @return undefined if the name is of external module otherwise a name with striped of any quote + */ + function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, location: Node): string { + let displayName: string = getDeclaredName(program.getTypeChecker(), symbol, location); + if (displayName) { let firstCharCode = displayName.charCodeAt(0); // First check of the displayName is not external module; if it is an external module, it is not valid entry if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { @@ -2821,37 +2823,38 @@ namespace ts { return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); } - function getCompletionEntryDisplayName(displayName: string, target: ScriptTarget, performCharacterChecks: boolean): string { - if (!displayName) { + /** + * Get a displayName from a given for completion list, performing any necessary quotes stripping + * and checking whether the name is valid identifier name. + */ + function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean): string { + if (!name) { return undefined; } - let firstCharCode = displayName.charCodeAt(0); - if (displayName.length >= 2 && - firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) { - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - displayName = displayName.substring(1, displayName.length - 1); - } + name = stripQuotes(name); - if (!displayName) { + if (!name) { return undefined; } + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. + // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks) { - if (!isIdentifierStart(displayName.charCodeAt(0), target)) { + if (!isIdentifierStart(name.charCodeAt(0), target)) { return undefined; } - for (let i = 1, n = displayName.length; i < n; i++) { - if (!isIdentifierPart(displayName.charCodeAt(i), target)) { + for (let i = 1, n = name.length; i < n; i++) { + if (!isIdentifierPart(name.charCodeAt(i), target)) { return undefined; } } } - return unescapeIdentifier(displayName); + return name; } function getCompletionData(fileName: string, position: number) { @@ -2890,33 +2893,36 @@ namespace ts { log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - - let options = program.getCompilerOptions(); - let jsx = options.jsx !== JsxEmit.None; - let target = options.target; - - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. let node = currentToken; let isRightOfDot = false; let isRightOfOpenTag = false; let location = getTouchingPropertyName(sourceFile, position); - if(contextToken) { - let kind = contextToken.kind; - if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.PropertyAccessExpression) { - node = (contextToken.parent).expression; - isRightOfDot = true; + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; } - else if (kind === SyntaxKind.DotToken && contextToken.parent.kind === SyntaxKind.QualifiedName) { - node = (contextToken.parent).left; - isRightOfDot = true; + + let { parent, kind } = contextToken; + if (kind === SyntaxKind.DotToken) { + if (parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (contextToken.parent).expression; + isRightOfDot = true; + } + else if (parent.kind === SyntaxKind.QualifiedName) { + node = (contextToken.parent).left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } } else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) { isRightOfOpenTag = true; @@ -3008,81 +3014,33 @@ namespace ts { } function tryGetGlobalSymbols(): boolean { - let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); - if (objectLikeContainer) { - // Object literal expression, look up possible property names from contextual type - isMemberCompletion = true; - isNewIdentifierLocation = true; + let objectLikeContainer: ObjectLiteralExpression | BindingPattern; + let importClause: ImportClause; + let jsxContainer: JsxOpeningLikeElement; - let typeForObject: Type; - let existingMembers: Declaration[]; - - if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { - typeForObject = typeChecker.getContextualType(objectLikeContainer); - existingMembers = (objectLikeContainer).properties; - } - else { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = (objectLikeContainer).elements; - } - - if (!typeForObject) { - return false; - } - - let typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); - } - return true; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (getAncestor(contextToken, SyntaxKind.ImportClause)) { - // cursor is in import clause + + if (importClause = getAncestor(contextToken, SyntaxKind.ImportClause)) { + // cursor is in an import clause // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - let importDeclaration = getAncestor(contextToken, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration !== undefined); - - let exports: Symbol[]; - if (importDeclaration.moduleSpecifier) { - let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - } - - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; - } - return true; + return tryGetImportClauseCompletionSymbols(importClause); } - else if (getAncestor(contextToken, SyntaxKind.JsxElement) || getAncestor(contextToken, SyntaxKind.JsxSelfClosingElement)) { - // Go up until we hit either the element or expression - let jsxNode = contextToken; - while (jsxNode) { - if (jsxNode.kind === SyntaxKind.JsxExpression) { - // Defer to global completion if we're inside an {expression} - break; - } else if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement || jsxNode.kind === SyntaxKind.JsxElement) { - let attrsType: Type; - if (jsxNode.kind === SyntaxKind.JsxSelfClosingElement) { - // Cursor is inside a JSX self-closing element - attrsType = typeChecker.getJsxElementAttributesType(jsxNode); - } - else { - Debug.assert(jsxNode.kind === SyntaxKind.JsxElement); - // Cursor is inside a JSX element - attrsType = typeChecker.getJsxElementAttributesType((jsxNode).openingElement); - } - symbols = typeChecker.getPropertiesOfType(attrsType); + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + let attrsType: Type; + if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + + if (attrsType) { + symbols = filterJsxAttributes((jsxContainer).attributes, typeChecker.getPropertiesOfType(attrsType)); isMemberCompletion = true; + isNewIdentifierLocation = false; return true; } - jsxNode = jsxNode.parent; + } } @@ -3143,16 +3101,16 @@ namespace ts { return scope; } - function isCompletionListBlocker(previousToken: Node): boolean { + function isCompletionListBlocker(contextToken: Node): boolean { let start = new Date().getTime(); - let result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node: Node): boolean { + function shouldShowCompletionsInImportsClause(node: Node): boolean { if (node) { // import {| // import {a,| @@ -3170,7 +3128,7 @@ namespace ts { switch (previousToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression // func( a, | - || containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ || containingNodeKind === SyntaxKind.NewExpression // new C(a, | || containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, | || containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, | @@ -3181,10 +3139,12 @@ namespace ts { || containingNodeKind === SyntaxKind.Constructor // constructor( | || containingNodeKind === SyntaxKind.NewExpression // new C(a| || containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a| - || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case SyntaxKind.OpenBracketToken: - return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ | + return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ | + || containingNodeKind === SyntaxKind.IndexSignature // [ | : string ] + || containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */ case SyntaxKind.ModuleKeyword: // module | case SyntaxKind.NamespaceKeyword: // namespace | @@ -3224,12 +3184,12 @@ namespace ts { return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { - if (previousToken.kind === SyntaxKind.StringLiteral - || previousToken.kind === SyntaxKind.RegularExpressionLiteral - || isTemplateLiteralKind(previousToken.kind)) { - let start = previousToken.getStart(); - let end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken: Node): boolean { + if (contextToken.kind === SyntaxKind.StringLiteral + || contextToken.kind === SyntaxKind.RegularExpressionLiteral + || isTemplateLiteralKind(contextToken.kind)) { + let start = contextToken.getStart(); + let end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -3240,14 +3200,94 @@ namespace ts { } if (position === end) { - return !!(previousToken).isUnterminated || - previousToken.kind === SyntaxKind.RegularExpressionLiteral; + return !!(contextToken).isUnterminated + || contextToken.kind === SyntaxKind.RegularExpressionLiteral; } } return false; } + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | BindingPattern): boolean { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + + let typeForObject: Type; + let existingMembers: Declaration[]; + + if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = (objectLikeContainer).properties; + } + else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + else { + Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + + if (!typeForObject) { + return false; + } + + let typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean { + // cursor is in import clause + // try to show exported member for imported module + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + + let importDeclaration = importClause.parent; + Debug.assert(importDeclaration !== undefined && importDeclaration.kind === SyntaxKind.ImportDeclaration); + + let exports: Symbol[]; + let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + + return true; + } + /** * Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given. @@ -3268,6 +3308,36 @@ namespace ts { return undefined; } + function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement { + if (contextToken) { + let parent = contextToken.parent; + switch(contextToken.kind) { + case SyntaxKind.LessThanSlashToken: + case SyntaxKind.SlashToken: + case SyntaxKind.Identifier: + if(parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { + return parent; + } + break; + + case SyntaxKind.CloseBraceToken: + // The context token is the closing } of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + if(parent && + parent.kind === SyntaxKind.JsxExpression && + parent.parent && + parent.parent.kind === SyntaxKind.JsxAttribute) { + + return parent.parent.parent; + } + + break; + } + } + return undefined; + } + function isFunction(kind: SyntaxKind): boolean { switch (kind) { case SyntaxKind.FunctionExpression: @@ -3285,101 +3355,98 @@ namespace ts { return false; } - function isIdentifierDefinitionLocation(previousToken: Node): boolean { - if (previousToken) { - let containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case SyntaxKind.CommaToken: - return containingNodeKind === SyntaxKind.VariableDeclaration || - containingNodeKind === SyntaxKind.VariableDeclarationList || - containingNodeKind === SyntaxKind.VariableStatement || - containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | - isFunction(containingNodeKind) || - containingNodeKind === SyntaxKind.ClassDeclaration || // class AimportDeclaration.importClause.namedBindings).elements, el => { + // If this is the current item we are editing right now, do not filter it out + if (el.getStart() <= position && position <= el.getEnd()) { + return; + } + let name = el.propertyName || el.name; exisingImports[name.text] = true; }); @@ -3451,8 +3523,30 @@ namespace ts { return filteredMembers; } + + function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { + let seenNames: Map = {}; + for (let attr of attributes) { + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + + if (attr.kind === SyntaxKind.JsxAttribute) { + seenNames[(attr).name.text] = true; + } + } + let result: Symbol[] = []; + for (let sym of symbols) { + if (!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } } + function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { synchronizeHostData(); @@ -3514,7 +3608,7 @@ namespace ts { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true); + let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } @@ -3571,7 +3665,7 @@ namespace ts { // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined); + let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location) === entryName ? s : undefined); if (symbol) { let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All); @@ -3604,7 +3698,8 @@ namespace ts { function getSymbolKind(symbol: Symbol, location: Node): string { let flags = symbol.getFlags(); - if (flags & SymbolFlags.Class) return ScriptElementKind.classElement; + if (flags & SymbolFlags.Class) return getDeclarationOfKind(symbol, SyntaxKind.ClassExpression) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement; if (flags & SymbolFlags.TypeAlias) return ScriptElementKind.typeElement; if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement; @@ -3649,7 +3744,7 @@ namespace ts { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.UnionProperty) { + if (flags & SymbolFlags.SyntheticProperty) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property let unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { let rootSymbolFlags = rootSymbol.getFlags(); @@ -3772,7 +3867,7 @@ namespace ts { displayParts.push(spacePart()); } if (!(type.flags & TypeFlags.Anonymous)) { - displayParts.push.apply(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); + addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); } addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); break; @@ -3813,7 +3908,16 @@ namespace ts { } } if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) { - displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); + if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) { + // Special case for class expressions because we would like to indicate that + // the class name is local to the class body (similar to function expression) + // (local class) class + pushTypePart(ScriptElementKind.localClassElement); + } + else { + // Class declaration has name which is not local. + displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); + } displayParts.push(spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -3833,7 +3937,7 @@ namespace ts { displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); - displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + addRange(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & SymbolFlags.Enum) { addNewLineIfDisplayPartsExist(); @@ -3879,7 +3983,7 @@ namespace ts { else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); } } if (symbolFlags & SymbolFlags.EnumMember) { @@ -3940,10 +4044,10 @@ namespace ts { let typeParameterParts = mapToDisplayParts(writer => { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + addRange(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration)); } } else if (symbolFlags & SymbolFlags.Function || @@ -3977,7 +4081,7 @@ namespace ts { function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) { let fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing); - displayParts.push.apply(displayParts, fullSymbolDisplayParts); + addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) { @@ -4007,7 +4111,7 @@ namespace ts { } function addSignatureDisplayParts(signature: Signature, allSignatures: Signature[], flags?: TypeFormatFlags) { - displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature)); + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature)); if (allSignatures.length > 1) { displayParts.push(spacePart()); displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); @@ -4024,7 +4128,7 @@ namespace ts { let typeParameterParts = mapToDisplayParts(writer => { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + addRange(displayParts, typeParameterParts); } } @@ -5019,7 +5123,7 @@ namespace ts { // Get the text to search for. // Note: if this is an external module symbol, the name doesn't include quotes. - let declaredName = getDeclaredName(typeChecker, symbol, node); + let declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -5096,10 +5200,10 @@ namespace ts { * a reference to a symbol can occur anywhere. */ function getSymbolScope(symbol: Symbol): Node { - // If this is the symbol of a function expression, then named references - // are limited to its own scope. + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. let valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { return valueDeclaration; } @@ -5119,7 +5223,7 @@ namespace ts { // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.UnionProperty)) { + if (symbol.parent || (symbol.flags & SymbolFlags.SyntheticProperty)) { return undefined; } @@ -5538,7 +5642,7 @@ namespace ts { // type to the search set if (isNameOfPropertyAssignment(location)) { forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => { - result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol)); + addRange(result, typeChecker.getRootSymbols(contextualSymbol)); }); /* Because in short-hand property assignment, location has two meaning : property name and as value of the property @@ -5776,7 +5880,7 @@ namespace ts { }); } - let emitOutput = program.emit(sourceFile, writeFile); + let emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles, @@ -6024,6 +6128,26 @@ namespace ts { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind: SyntaxKind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // That means we're calling back into the host around every 1.2k of the file we process. + // Lib.d.ts has similar numbers. + switch (kind) { + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.FunctionDeclaration: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { synchronizeHostData(); @@ -6091,7 +6215,10 @@ namespace ts { function processNode(node: Node) { // Only walk into nodes that intersect the requested span. if (node && textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { + let kind = node.kind; + checkForClassificationCancellation(kind); + + if (kind === SyntaxKind.Identifier && !nodeIsMissing(node)) { let identifier = node; // Only bother calling into the typechecker if this is an identifier that @@ -6458,6 +6585,8 @@ namespace ts { // Ignore nodes that don't intersect the original span to classify. if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); + let children = element.getChildren(sourceFile); for (let i = 0, n = children.length; i < n; i++) { let child = children[i]; @@ -6745,7 +6874,7 @@ namespace ts { } } - let displayName = getDeclaredName(typeChecker, symbol, node); + let displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); let kind = getSymbolKind(symbol, node); if (kind) { return { @@ -7347,8 +7476,8 @@ namespace ts { } let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e8b3eb774d..6e765eff499 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -51,7 +51,7 @@ namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): ScriptSnapshotShim; getLocalizedDiagnosticMessages(): string; - getCancellationToken(): CancellationToken; + getCancellationToken(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; getNewLine?(): string; @@ -326,8 +326,9 @@ namespace ts { } } - public getCancellationToken(): CancellationToken { - return this.shimHost.getCancellationToken(); + public getCancellationToken(): HostCancellationToken { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); } public getCurrentDirectory(): string { @@ -346,6 +347,29 @@ namespace ts { } } + /** A cancellation that throttles calls to the host */ + class ThrottledCancellationToken implements HostCancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: HostCancellationToken) { + } + + public isCancellationRequested(): boolean { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + } + export class CoreServicesShimHostAdapter implements ParseConfigHost { constructor(private shimHost: CoreServicesShimHost) { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index fce4e2c3025..f44ebade2a7 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -178,7 +178,7 @@ namespace ts.SignatureHelp { argumentCount: number; } - export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationTokenObject): SignatureHelpItems { + export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems { let typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -550,7 +550,7 @@ namespace ts.SignatureHelp { let suffixDisplayParts: SymbolDisplayPart[] = []; if (callTargetDisplayParts) { - prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts); + addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { @@ -560,12 +560,12 @@ namespace ts.SignatureHelp { suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); let parameterParts = mapToDisplayParts(writer => typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation)); - suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts); + addRange(suffixDisplayParts, parameterParts); } else { let typeParameterParts = mapToDisplayParts(writer => typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation)); - prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts); + addRange(prefixDisplayParts, typeParameterParts); prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); let parameters = candidateSignature.parameters; @@ -575,7 +575,7 @@ namespace ts.SignatureHelp { let returnTypeParts = mapToDisplayParts(writer => typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation)); - suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts); + addRange(suffixDisplayParts, returnTypeParts); return { isVariadic: candidateSignature.hasRestParameter, diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0fd945caa7d..5f8859c815e 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -429,6 +429,7 @@ namespace ts { if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier); if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier); if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier); + if (flags & NodeFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier); if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier); if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier); @@ -666,7 +667,7 @@ namespace ts { let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return stripQuotes(name); + return name; } export function isImportOrExportSpecifierName(location: Node): boolean { @@ -675,9 +676,16 @@ namespace ts { (location.parent).propertyName === location; } + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ export function stripQuotes(name: string) { let length = name.length; - if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) { + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === CharacterCodes.doubleQuote || name.charCodeAt(0) === CharacterCodes.singleQuote)) { return name.substring(1, length - 1); }; return name; diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index ca7078981f7..30951b90fca 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 191 /* ForStatement */: - case 192 /* ForInStatement */: - case 190 /* WhileStatement */: - case 189 /* DoStatement */: - if (node.statement.kind !== 184 /* Block */) { + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: + if (node.statement.kind !== 189 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 188 /* IfStatement */: + case 193 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 184 /* Block */) { + if (ifStatement.thenStatement.kind !== 189 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 184 /* Block */ && - ifStatement.elseStatement.kind !== 188 /* IfStatement */) { + ifStatement.elseStatement.kind !== 189 /* Block */ && + ifStatement.elseStatement.kind !== 193 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 173 /* BinaryExpression */: + case 178 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 35edf48564a..6efd10dce09 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,20 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== function * foo(a = yield => yield) { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~ +!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index 51694533964..ccff1ac1036 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,6 +3,6 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function foo(a) { - if (a === void 0) { a = function (yield) { return yield; }; } +yield; +{ } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 9f696e71084..eae7628f046 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,1 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 91fab36ed31..4a9e4bca6d3 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== @@ -12,6 +12,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,2 ~ !!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher. ~~~~~ -!!! error TS2304: Cannot find name 'yield'. +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } } \ No newline at end of file diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js new file mode 100644 index 00000000000..92d159766d7 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -0,0 +1,14 @@ +//// [abstractIdentifierNameStrict.ts] +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} + +//// [abstractIdentifierNameStrict.js] +var abstract = true; +function foo() { + "use strict"; + var abstract = true; +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.symbols b/tests/baselines/reference/abstractIdentifierNameStrict.symbols new file mode 100644 index 00000000000..c6a374e9bcd --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) + +function foo() { +>foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) + + "use strict"; + var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types new file mode 100644 index 00000000000..7c79ce58a37 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : boolean +>true : boolean + +function foo() { +>foo : () => void + + "use strict"; +>"use strict" : string + + var abstract = true; +>abstract : boolean +>true : boolean +} diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.js b/tests/baselines/reference/abstractInterfaceIdentifierName.js new file mode 100644 index 00000000000..67058bfc619 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.js @@ -0,0 +1,8 @@ +//// [abstractInterfaceIdentifierName.ts] + +interface abstract { + abstract(): void; +} + + +//// [abstractInterfaceIdentifierName.js] diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols new file mode 100644 index 00000000000..c70cdec8ac9 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) + + abstract(): void; +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) +} + diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.types b/tests/baselines/reference/abstractInterfaceIdentifierName.types new file mode 100644 index 00000000000..c6d30ca38a0 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : abstract + + abstract(): void; +>abstract : () => void +} + diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 9b68573b378..208646dc101 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe let blah = arguments[Symbol.iterator]; >blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7)) >arguments : Symbol(arguments) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index d8717c2c6d2..faf0b130738 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt new file mode 100644 index 00000000000..2476eaec6e3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,17): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,20): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(4,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts (5 errors) ==== + + var foo = async foo(): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.js b/tests/baselines/reference/asyncArrowFunction10_es6.js new file mode 100644 index 00000000000..23b2c3af80e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.js @@ -0,0 +1,13 @@ +//// [asyncArrowFunction10_es6.ts] + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncArrowFunction10_es6.js] +var foo = async, foo = () => { + // Legal to use 'await' in a type context. + var v; +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.js b/tests/baselines/reference/asyncArrowFunction1_es6.js new file mode 100644 index 00000000000..4f03acc5ced --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction1_es6.ts] + +var foo = async (): Promise => { +}; + +//// [asyncArrowFunction1_es6.js] +var foo = () => __awaiter(this, void 0, Promise, function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols new file mode 100644 index 00000000000..cb2c5255486 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.types b/tests/baselines/reference/asyncArrowFunction1_es6.types new file mode 100644 index 00000000000..3ecfdeb7919 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts === + +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => {} : () => Promise +>Promise : Promise + +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.js b/tests/baselines/reference/asyncArrowFunction2_es6.js new file mode 100644 index 00000000000..9d7f1d10ea6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction2_es6.ts] +var f = (await) => { +} + +//// [asyncArrowFunction2_es6.js] +var f = (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.symbols b/tests/baselines/reference/asyncArrowFunction2_es6.symbols new file mode 100644 index 00000000000..dd8b4ea2390 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : Symbol(f, Decl(asyncArrowFunction2_es6.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction2_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/asyncArrowFunction2_es6.types b/tests/baselines/reference/asyncArrowFunction2_es6.types new file mode 100644 index 00000000000..98808d175f8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts === +var f = (await) => { +>f : (await: any) => void +>(await) => {} : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt new file mode 100644 index 00000000000..d0f56df51da --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.js b/tests/baselines/reference/asyncArrowFunction3_es6.js new file mode 100644 index 00000000000..9616336d76a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction3_es6.ts] +function f(await = await) { +} + +//// [asyncArrowFunction3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.js b/tests/baselines/reference/asyncArrowFunction4_es6.js new file mode 100644 index 00000000000..eb89d98bbeb --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction4_es6.ts] +var await = () => { +} + +//// [asyncArrowFunction4_es6.js] +var await = () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.symbols b/tests/baselines/reference/asyncArrowFunction4_es6.symbols new file mode 100644 index 00000000000..1c001040720 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : Symbol(await, Decl(asyncArrowFunction4_es6.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es6.types b/tests/baselines/reference/asyncArrowFunction4_es6.types new file mode 100644 index 00000000000..e23ff786105 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts === +var await = () => { +>await : () => void +>() => {} : () => void +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt new file mode 100644 index 00000000000..fed29620532 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,18): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,33): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(2,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts (6 errors) ==== + + var foo = async (await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js new file mode 100644 index 00000000000..ed4035e6175 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -0,0 +1,9 @@ +//// [asyncArrowFunction5_es6.ts] + +var foo = async (await): Promise => { +} + +//// [asyncArrowFunction5_es6.js] +var foo = async(await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt new file mode 100644 index 00000000000..111e4ff46d0 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts(2,27): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts (2 errors) ==== + + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.js b/tests/baselines/reference/asyncArrowFunction6_es6.js new file mode 100644 index 00000000000..54b8aa1f6b1 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction6_es6.ts] + +var foo = async (a = await): Promise => { +} + +//// [asyncArrowFunction6_es6.js] +var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt new file mode 100644 index 00000000000..6376626d0e7 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts(4,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts (2 errors) ==== + + var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.js b/tests/baselines/reference/asyncArrowFunction7_es6.js new file mode 100644 index 00000000000..ac68a8fd2f8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunction7_es6.ts] + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} + +//// [asyncArrowFunction7_es6.js] +var bar = () => __awaiter(this, void 0, Promise, function* () { + // 'await' here is an identifier, and not an await expression. + var foo = (a = yield ) => __awaiter(this, void 0, Promise, function* () { + }); +}); diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt new file mode 100644 index 00000000000..7252805cdca --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts(3,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts (1 errors) ==== + + var foo = async (): Promise => { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.js b/tests/baselines/reference/asyncArrowFunction8_es6.js new file mode 100644 index 00000000000..9cee5ee1525 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.js @@ -0,0 +1,10 @@ +//// [asyncArrowFunction8_es6.ts] + +var foo = async (): Promise => { + var v = { [await]: foo } +} + +//// [asyncArrowFunction8_es6.js] +var foo = () => __awaiter(this, void 0, Promise, function* () { + var v = { [yield ]: foo }; +}); diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt new file mode 100644 index 00000000000..623095e8a5e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js new file mode 100644 index 00000000000..fb2f9d28a17 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction9_es6.ts] +var foo = async (a = await => await): Promise => { +} + +//// [asyncArrowFunction9_es6.js] +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js new file mode 100644 index 00000000000..c24259cf0b5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.js @@ -0,0 +1,16 @@ +//// [asyncArrowFunctionCapturesArguments_es6.ts] +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} + + +//// [asyncArrowFunctionCapturesArguments_es6.js] +class C { + method() { + function other() { } + var fn = () => __awaiter(this, arguments, Promise, function* (_arguments) { return yield other.apply(this, _arguments); }); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols new file mode 100644 index 00000000000..5f820eec862 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) + + method() { +>method : Symbol(method, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) + + var fn = async () => await other.apply(this, arguments); +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) +>other.apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20)) +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types new file mode 100644 index 00000000000..b3f6f18cde8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>other.apply(this, arguments) : any +>other.apply : (thisArg: any, argArray?: any) => any +>other : () => void +>apply : (thisArg: any, argArray?: any) => any +>this : C +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js new file mode 100644 index 00000000000..0f09e366ef3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunctionCapturesThis_es6.ts] +class C { + method() { + var fn = async () => await this; + } +} + + +//// [asyncArrowFunctionCapturesThis_es6.js] +class C { + method() { + var fn = () => __awaiter(this, void 0, Promise, function* () { return yield this; }); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols new file mode 100644 index 00000000000..ae516bb7fe3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + + method() { +>method : Symbol(method, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 9)) + + var fn = async () => await this; +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es6.ts, 2, 9)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es6.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types new file mode 100644 index 00000000000..f3cd0f2d2de --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts === +class C { +>C : C + + method() { +>method : () => void + + var fn = async () => await this; +>fn : () => Promise +>async () => await this : () => Promise +>this : C + } +} + diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt new file mode 100644 index 00000000000..068fbb604e1 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts(1,27): error TS2307: Cannot find module 'missing'. + + +==== tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts (1 errors) ==== + import { MyPromise } from "missing"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'missing'. + + declare var p: Promise; + declare var mp: MyPromise; + + async function f0() { } + async function f1(): Promise { } + async function f3(): MyPromise { } + + let f4 = async function() { } + let f5 = async function(): Promise { } + let f6 = async function(): MyPromise { } + + let f7 = async () => { }; + let f8 = async (): Promise => { }; + let f9 = async (): MyPromise => { }; + let f10 = async () => p; + let f11 = async () => mp; + let f12 = async (): Promise => mp; + let f13 = async (): MyPromise => p; + + let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } + }; + + class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } + } + + module M { + export async function f1() { } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js new file mode 100644 index 00000000000..7007c66ae28 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -0,0 +1,118 @@ +//// [asyncAwaitIsolatedModules_es6.ts] +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwaitIsolatedModules_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f1() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f3() { + return __awaiter(this, void 0, MyPromise, function* () { }); +} +let f4 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f5 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f6 = function () { + return __awaiter(this, void 0, MyPromise, function* () { }); +}; +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); +let o = { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +}; +class C { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } + static m4() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m5() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m6() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js new file mode 100644 index 00000000000..155a44d339d --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -0,0 +1,118 @@ +//// [asyncAwait_es6.ts] +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwait_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f0() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f1() { + return __awaiter(this, void 0, Promise, function* () { }); +} +function f3() { + return __awaiter(this, void 0, MyPromise, function* () { }); +} +let f4 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f5 = function () { + return __awaiter(this, void 0, Promise, function* () { }); +}; +let f6 = function () { + return __awaiter(this, void 0, MyPromise, function* () { }); +}; +let f7 = () => __awaiter(this, void 0, Promise, function* () { }); +let f8 = () => __awaiter(this, void 0, Promise, function* () { }); +let f9 = () => __awaiter(this, void 0, MyPromise, function* () { }); +let f10 = () => __awaiter(this, void 0, Promise, function* () { return p; }); +let f11 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f12 = () => __awaiter(this, void 0, Promise, function* () { return mp; }); +let f13 = () => __awaiter(this, void 0, MyPromise, function* () { return p; }); +let o = { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + }, + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +}; +class C { + m1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m2() { + return __awaiter(this, void 0, Promise, function* () { }); + } + m3() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } + static m4() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m5() { + return __awaiter(this, void 0, Promise, function* () { }); + } + static m6() { + return __awaiter(this, void 0, MyPromise, function* () { }); + } +} +var M; +(function (M) { + function f1() { + return __awaiter(this, void 0, Promise, function* () { }); + } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols new file mode 100644 index 00000000000..8d4b98a20a1 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) + +declare var MyPromise: typeof Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwait_es6.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwait_es6.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwait_es6.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwait_es6.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwait_es6.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwait_es6.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwait_es6.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwait_es6.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(m1, Decl(asyncAwait_es6.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwait_es6.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) +} + +module M { +>M : Symbol(M, Decl(asyncAwait_es6.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwait_es6.types b/tests/baselines/reference/asyncAwait_es6.types new file mode 100644 index 00000000000..5f0cd2cc35a --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es6.types @@ -0,0 +1,129 @@ +=== tests/cases/conformance/async/es6/asyncAwait_es6.ts === +type MyPromise = Promise; +>MyPromise : Promise +>T : T +>Promise : Promise +>T : T + +declare var MyPromise: typeof Promise; +>MyPromise : PromiseConstructor +>Promise : PromiseConstructor + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : Promise +>MyPromise : Promise + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => Promise +>MyPromise : Promise + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => Promise +>async function(): MyPromise { } : () => Promise +>MyPromise : Promise + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => Promise +>async (): MyPromise => { } : () => Promise +>MyPromise : Promise + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : Promise + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : Promise + +let f13 = async (): MyPromise => p; +>f13 : () => Promise +>async (): MyPromise => p : () => Promise +>MyPromise : Promise +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): Promise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => Promise +>MyPromise : Promise +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncClass_es6.errors.txt b/tests/baselines/reference/asyncClass_es6.errors.txt new file mode 100644 index 00000000000..ee8a3a85dbc --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncClass_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncClass_es6.ts (1 errors) ==== + async class C { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es6.js b/tests/baselines/reference/asyncClass_es6.js new file mode 100644 index 00000000000..b5e1498f70c --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.js @@ -0,0 +1,7 @@ +//// [asyncClass_es6.ts] +async class C { +} + +//// [asyncClass_es6.js] +class C { +} diff --git a/tests/baselines/reference/asyncConstructor_es6.errors.txt b/tests/baselines/reference/asyncConstructor_es6.errors.txt new file mode 100644 index 00000000000..6eb18cf41a1 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncConstructor_es6.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. + + +==== tests/cases/conformance/async/es6/asyncConstructor_es6.ts (1 errors) ==== + class C { + async constructor() { + ~~~~~ +!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es6.js b/tests/baselines/reference/asyncConstructor_es6.js new file mode 100644 index 00000000000..a0cfa7709df --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.js @@ -0,0 +1,11 @@ +//// [asyncConstructor_es6.ts] +class C { + async constructor() { + } +} + +//// [asyncConstructor_es6.js] +class C { + constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es6.errors.txt b/tests/baselines/reference/asyncDeclare_es6.errors.txt new file mode 100644 index 00000000000..65a4068e140 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/async/es6/asyncDeclare_es6.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. + + +==== tests/cases/conformance/async/es6/asyncDeclare_es6.ts (1 errors) ==== + declare async function foo(): Promise; + ~~~~~ +!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es6.js b/tests/baselines/reference/asyncDeclare_es6.js new file mode 100644 index 00000000000..096f43a248a --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.js @@ -0,0 +1,4 @@ +//// [asyncDeclare_es6.ts] +declare async function foo(): Promise; + +//// [asyncDeclare_es6.js] diff --git a/tests/baselines/reference/asyncEnum_es6.errors.txt b/tests/baselines/reference/asyncEnum_es6.errors.txt new file mode 100644 index 00000000000..a50853fd8ea --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/asyncEnum_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncEnum_es6.ts (1 errors) ==== + async enum E { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + Value + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es6.js b/tests/baselines/reference/asyncEnum_es6.js new file mode 100644 index 00000000000..074de3dd0ae --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.js @@ -0,0 +1,10 @@ +//// [asyncEnum_es6.ts] +async enum E { + Value +} + +//// [asyncEnum_es6.js] +var E; +(function (E) { + E[E["Value"] = 0] = "Value"; +})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt new file mode 100644 index 00000000000..15ceb3e60c7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js new file mode 100644 index 00000000000..141c0cbab55 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration10_es6.ts] +async function foo(a = await => await): Promise { +} + +//// [asyncFunctionDeclaration10_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.js b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js new file mode 100644 index 00000000000..a44343cef78 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration11_es6.ts] +async function await(): Promise { +} + +//// [asyncFunctionDeclaration11_es6.js] +function await() { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols new file mode 100644 index 00000000000..889614387d7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.types b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types new file mode 100644 index 00000000000..65896e7b3b5 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === +async function await(): Promise { +>await : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt new file mode 100644 index 00000000000..978492f0744 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts (4 errors) ==== + var v = async function await(): Promise { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js new file mode 100644 index 00000000000..dae33682ce6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration12_es6.ts] +var v = async function await(): Promise { } + +//// [asyncFunctionDeclaration12_es6.js] +var v = , await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt new file mode 100644 index 00000000000..6cf65ca4e3a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts (1 errors) ==== + async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.js b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js new file mode 100644 index 00000000000..4257c8691c2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.js @@ -0,0 +1,14 @@ +//// [asyncFunctionDeclaration13_es6.ts] +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncFunctionDeclaration13_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + // Legal to use 'await' in a type context. + var v; + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.js b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js new file mode 100644 index 00000000000..f32d106f92e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration14_es6.ts] +async function foo(): Promise { + return; +} + +//// [asyncFunctionDeclaration14_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + return; + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols new file mode 100644 index 00000000000..626b820e312 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.types b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types new file mode 100644 index 00000000000..7727ffafaeb --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.js b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js new file mode 100644 index 00000000000..263e27fa35e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration1_es6.ts] +async function foo(): Promise { +} + +//// [asyncFunctionDeclaration1_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols new file mode 100644 index 00000000000..c71592c0463 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.types b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types new file mode 100644 index 00000000000..5cba25724f0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.js b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js new file mode 100644 index 00000000000..1c54b9bc056 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration2_es6.ts] +function f(await) { +} + +//// [asyncFunctionDeclaration2_es6.js] +function f(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols new file mode 100644 index 00000000000..c709d7f7386 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration2_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration2_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es6.types b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types new file mode 100644 index 00000000000..9c9a19f3e76 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts === +function f(await) { +>f : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt new file mode 100644 index 00000000000..a480bf3d2b8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.js b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js new file mode 100644 index 00000000000..7038858d2c8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration3_es6.ts] +function f(await = await) { +} + +//// [asyncFunctionDeclaration3_es6.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.js b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js new file mode 100644 index 00000000000..8bfb7bf642f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration4_es6.ts] +function await() { +} + +//// [asyncFunctionDeclaration4_es6.js] +function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols new file mode 100644 index 00000000000..cdbe1f5a8db --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : Symbol(await, Decl(asyncFunctionDeclaration4_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es6.types b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types new file mode 100644 index 00000000000..537661e2c66 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts === +function await() { +>await : () => void +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt new file mode 100644 index 00000000000..a6944e0c6e6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== + async function foo(await): Promise { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js new file mode 100644 index 00000000000..8d28c371465 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration5_es6.ts] +async function foo(await): Promise { +} + +//// [asyncFunctionDeclaration5_es6.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt new file mode 100644 index 00000000000..ee8abb7bdad --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts(1,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts (2 errors) ==== + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.js b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js new file mode 100644 index 00000000000..8c37968ab4c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration6_es6.ts] +async function foo(a = await): Promise { +} + +//// [asyncFunctionDeclaration6_es6.js] +function foo(a = yield ) { + return __awaiter(this, void 0, Promise, function* () { + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt new file mode 100644 index 00000000000..91ba4508ba1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts(3,31): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts (2 errors) ==== + async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.js b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js new file mode 100644 index 00000000000..ef66df4e413 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.js @@ -0,0 +1,17 @@ +//// [asyncFunctionDeclaration7_es6.ts] +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} + +//// [asyncFunctionDeclaration7_es6.js] +function bar() { + return __awaiter(this, void 0, Promise, function* () { + // 'await' here is an identifier, and not a yield expression. + function foo(a = yield ) { + return __awaiter(this, void 0, Promise, function* () { + }); + } + }); +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt new file mode 100644 index 00000000000..c785ae41b17 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts (2 errors) ==== + var v = { [await]: foo } + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.js b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js new file mode 100644 index 00000000000..a363015f8ab --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration8_es6.ts] +var v = { [await]: foo } + +//// [asyncFunctionDeclaration8_es6.js] +var v = { [await]: foo }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt new file mode 100644 index 00000000000..235ef165bed --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts (1 errors) ==== + async function foo(): Promise { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.js b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js new file mode 100644 index 00000000000..9723a69f2a2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.js @@ -0,0 +1,11 @@ +//// [asyncFunctionDeclaration9_es6.ts] +async function foo(): Promise { + var v = { [await]: foo } +} + +//// [asyncFunctionDeclaration9_es6.js] +function foo() { + return __awaiter(this, void 0, Promise, function* () { + var v = { [yield ]: foo }; + }); +} diff --git a/tests/baselines/reference/asyncGetter_es6.errors.txt b/tests/baselines/reference/asyncGetter_es6.errors.txt new file mode 100644 index 00000000000..5f5a9f6b1d7 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/async/es6/asyncGetter_es6.ts (2 errors) ==== + class C { + async get foo() { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + ~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es6.js b/tests/baselines/reference/asyncGetter_es6.js new file mode 100644 index 00000000000..606f4d95dc7 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncGetter_es6.ts] +class C { + async get foo() { + } +} + +//// [asyncGetter_es6.js] +class C { + get foo() { + } +} diff --git a/tests/baselines/reference/asyncInterface_es6.errors.txt b/tests/baselines/reference/asyncInterface_es6.errors.txt new file mode 100644 index 00000000000..c7519ba040e --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncInterface_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncInterface_es6.ts (1 errors) ==== + async interface I { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es6.js b/tests/baselines/reference/asyncInterface_es6.js new file mode 100644 index 00000000000..36314fa2141 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.js @@ -0,0 +1,5 @@ +//// [asyncInterface_es6.ts] +async interface I { +} + +//// [asyncInterface_es6.js] diff --git a/tests/baselines/reference/asyncModule_es6.errors.txt b/tests/baselines/reference/asyncModule_es6.errors.txt new file mode 100644 index 00000000000..91e5e8ccdd3 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es6/asyncModule_es6.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncModule_es6.ts (1 errors) ==== + async module M { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es6.js b/tests/baselines/reference/asyncModule_es6.js new file mode 100644 index 00000000000..e3e9306dbcb --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.js @@ -0,0 +1,5 @@ +//// [asyncModule_es6.ts] +async module M { +} + +//// [asyncModule_es6.js] diff --git a/tests/baselines/reference/asyncSetter_es6.errors.txt b/tests/baselines/reference/asyncSetter_es6.errors.txt new file mode 100644 index 00000000000..e60e05cbc55 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es6/asyncSetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es6/asyncSetter_es6.ts (1 errors) ==== + class C { + async set foo(value) { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es6.js b/tests/baselines/reference/asyncSetter_es6.js new file mode 100644 index 00000000000..303e483f9a9 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.js @@ -0,0 +1,11 @@ +//// [asyncSetter_es6.ts] +class C { + async set foo(value) { + } +} + +//// [asyncSetter_es6.js] +class C { + set foo(value) { + } +} diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 5881e49dae9..278dca816fa 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2300: Duplicate identifier 'c11'. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2300: Duplicate identifier 'c11'. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2518: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index a9fc28dd5ae..690bf8b7a99 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2300: Duplicate identifier 'i2'. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2300: Duplicate identifier 'i2'. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2518: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.js b/tests/baselines/reference/awaitBinaryExpression1_es6.js new file mode 100644 index 00000000000..8deb771f5ab --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} + +//// [awaitBinaryExpression1_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) || a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols new file mode 100644 index 00000000000..6a72f1b1506 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p || a; +>b : Symbol(b, Decl(awaitBinaryExpression1_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.types b/tests/baselines/reference/awaitBinaryExpression1_es6.types new file mode 100644 index 00000000000..59370dda14b --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p || a; +>b : boolean +>await p || a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.js b/tests/baselines/reference/awaitBinaryExpression2_es6.js new file mode 100644 index 00000000000..506af50a0ef --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} + +//// [awaitBinaryExpression2_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) && a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols new file mode 100644 index 00000000000..f81a146f943 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p && a; +>b : Symbol(b, Decl(awaitBinaryExpression2_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.types b/tests/baselines/reference/awaitBinaryExpression2_es6.types new file mode 100644 index 00000000000..c3f33bca2fa --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p && a; +>b : boolean +>await p && a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.js b/tests/baselines/reference/awaitBinaryExpression3_es6.js new file mode 100644 index 00000000000..4b298d7b947 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression3_es6.ts] +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} + +//// [awaitBinaryExpression3_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield p) + a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols new file mode 100644 index 00000000000..479b3b30650 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p + a; +>b : Symbol(b, Decl(awaitBinaryExpression3_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.types b/tests/baselines/reference/awaitBinaryExpression3_es6.types new file mode 100644 index 00000000000..786eabadae4 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts === +declare var a: number; +>a : number + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p + a; +>b : number +>await p + a : number +>p : any +>a : number + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.js b/tests/baselines/reference/awaitBinaryExpression4_es6.js new file mode 100644 index 00000000000..4d313588984 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} + +//// [awaitBinaryExpression4_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = yield p, a; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols new file mode 100644 index 00000000000..5d15c754793 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = await p, a; +>b : Symbol(b, Decl(awaitBinaryExpression4_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 4, 20)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.types b/tests/baselines/reference/awaitBinaryExpression4_es6.types new file mode 100644 index 00000000000..73126b7797d --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = await p, a; +>b : boolean +>p : any +>a : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.js b/tests/baselines/reference/awaitBinaryExpression5_es6.js new file mode 100644 index 00000000000..01d6c50f6f0 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.js @@ -0,0 +1,19 @@ +//// [awaitBinaryExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} + +//// [awaitBinaryExpression5_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var o; + o.a = yield p; + "after"; + }); +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols new file mode 100644 index 00000000000..bc1e2f19310 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var o: { a: boolean; }; +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + o.a = await p; +>o.a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) +>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) + + "after"; +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.types b/tests/baselines/reference/awaitBinaryExpression5_es6.types new file mode 100644 index 00000000000..922e5887a77 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var o: { a: boolean; }; +>o : { a: boolean; } +>a : boolean + + o.a = await p; +>o.a = await p : boolean +>o.a : boolean +>o : { a: boolean; } +>a : boolean +>p : any + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.js b/tests/baselines/reference/awaitCallExpression1_es6.js new file mode 100644 index 00000000000..f9dad87a8b6 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression1_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} + +//// [awaitCallExpression1_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols new file mode 100644 index 00000000000..7e28d92cd9c --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression1_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression1_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression1_es6.types b/tests/baselines/reference/awaitCallExpression1_es6.types new file mode 100644 index 00000000000..334175b7edb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, a, a); +>b : void +>fn(a, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.js b/tests/baselines/reference/awaitCallExpression2_es6.js new file mode 100644 index 00000000000..87d99cd0793 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression2_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression2_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(yield p, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols new file mode 100644 index 00000000000..305a4c77aa3 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression2_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression2_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression2_es6.types b/tests/baselines/reference/awaitCallExpression2_es6.types new file mode 100644 index 00000000000..6c7f02a578a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(await p, a, a); +>b : void +>fn(await p, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.js b/tests/baselines/reference/awaitCallExpression3_es6.js new file mode 100644 index 00000000000..f397d83c3a1 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression3_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression3_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = fn(a, yield p, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols new file mode 100644 index 00000000000..715c125bcf0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression3_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression3_es6.ts, 8, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression3_es6.types b/tests/baselines/reference/awaitCallExpression3_es6.types new file mode 100644 index 00000000000..24d22db3c8c --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es6.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = fn(a, await p, a); +>b : void +>fn(a, await p, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.js b/tests/baselines/reference/awaitCallExpression4_es6.js new file mode 100644 index 00000000000..d8824d7e7a0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression4_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} + +//// [awaitCallExpression4_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield pfn)(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols new file mode 100644 index 00000000000..98a995d8117 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression4_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = (await pfn)(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression4_es6.ts, 8, 7)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression4_es6.types b/tests/baselines/reference/awaitCallExpression4_es6.types new file mode 100644 index 00000000000..04115466427 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es6.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await pfn)(a, a, a); +>b : void +>(await pfn)(a, a, a) : void +>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : any +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.js b/tests/baselines/reference/awaitCallExpression5_es6.js new file mode 100644 index 00000000000..f39a633765d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression5_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} + +//// [awaitCallExpression5_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols new file mode 100644 index 00000000000..30df9c8d022 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression5_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression5_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression5_es6.types b/tests/baselines/reference/awaitCallExpression5_es6.types new file mode 100644 index 00000000000..5074c007743 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, a, a); +>b : void +>o.fn(a, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.js b/tests/baselines/reference/awaitCallExpression6_es6.js new file mode 100644 index 00000000000..de8477fa938 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression6_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} + +//// [awaitCallExpression6_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(yield p, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols new file mode 100644 index 00000000000..ac1cca1c16f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression6_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression6_es6.types b/tests/baselines/reference/awaitCallExpression6_es6.types new file mode 100644 index 00000000000..d18377cebbb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(await p, a, a); +>b : void +>o.fn(await p, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>p : any +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.js b/tests/baselines/reference/awaitCallExpression7_es6.js new file mode 100644 index 00000000000..24edc3b9393 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression7_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} + +//// [awaitCallExpression7_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = o.fn(a, yield p, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols new file mode 100644 index 00000000000..b48e99ddec1 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = o.fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression7_es6.ts, 8, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression7_es6.types b/tests/baselines/reference/awaitCallExpression7_es6.types new file mode 100644 index 00000000000..b213a75dcd6 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = o.fn(a, await p, a); +>b : void +>o.fn(a, await p, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>p : any +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.js b/tests/baselines/reference/awaitCallExpression8_es6.js new file mode 100644 index 00000000000..8bee6112a7a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression8_es6.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} + +//// [awaitCallExpression8_es6.js] +function func() { + return __awaiter(this, void 0, Promise, function* () { + "before"; + var b = (yield po).fn(a, a, a); + "after"; + }); +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols new file mode 100644 index 00000000000..4dd9d500347 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression8_es6.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 5, 58)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) + + "before"; + var b = (await po).fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression8_es6.ts, 8, 7)) +>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) + + "after"; +} diff --git a/tests/baselines/reference/awaitCallExpression8_es6.types b/tests/baselines/reference/awaitCallExpression8_es6.types new file mode 100644 index 00000000000..37511a7e3d7 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es6.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "before"; +>"before" : string + + var b = (await po).fn(a, a, a); +>b : void +>(await po).fn(a, a, a) : void +>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : any +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + "after"; +>"after" : string +} diff --git a/tests/baselines/reference/awaitUnion_es6.js b/tests/baselines/reference/awaitUnion_es6.js new file mode 100644 index 00000000000..80c68f811ef --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.js @@ -0,0 +1,24 @@ +//// [awaitUnion_es6.ts] +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} + +//// [awaitUnion_es6.js] +function f() { + return __awaiter(this, void 0, Promise, function* () { + let await_a = yield a; + let await_b = yield b; + let await_c = yield c; + let await_d = yield d; + let await_e = yield e; + }); +} diff --git a/tests/baselines/reference/awaitUnion_es6.symbols b/tests/baselines/reference/awaitUnion_es6.symbols new file mode 100644 index 00000000000..ca0b9afaf92 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11)) + +declare let b: PromiseLike | PromiseLike; +>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let c: PromiseLike; +>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let d: number | PromiseLike; +>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +declare let e: number | PromiseLike; +>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163)) + +async function f() { +>f : Symbol(f, Decl(awaitUnion_es6.ts, 4, 53)) + + let await_a = await a; +>await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4)) + + let await_b = await b; +>await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4)) + + let await_c = await c; +>await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4)) + + let await_d = await d; +>await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4)) + + let await_e = await e; +>await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4)) +} diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types new file mode 100644 index 00000000000..fc7bef8a28c --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/async/es6/awaitUnion_es6.ts === +declare let a: number | string; +>a : string | number + +declare let b: PromiseLike | PromiseLike; +>b : PromiseLike | PromiseLike +>PromiseLike : PromiseLike +>PromiseLike : PromiseLike + +declare let c: PromiseLike; +>c : PromiseLike +>PromiseLike : PromiseLike + +declare let d: number | PromiseLike; +>d : number | PromiseLike +>PromiseLike : PromiseLike + +declare let e: number | PromiseLike; +>e : number | PromiseLike +>PromiseLike : PromiseLike + +async function f() { +>f : () => Promise + + let await_a = await a; +>await_a : string | number +>a : any + + let await_b = await b; +>await_b : string | number +>b : any + + let await_c = await c; +>await_c : string | number +>c : any + + let await_d = await d; +>await_d : string | number +>d : any + + let await_e = await e; +>await_e : string | number +>e : any +} diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 008488d0ce9..0e236821020 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1355, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/class1.errors.txt b/tests/baselines/reference/class1.errors.txt deleted file mode 100644 index b90fae9cb40..00000000000 --- a/tests/baselines/reference/class1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/class1.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/class1.ts(2,7): error TS2300: Duplicate identifier 'foo'. - - -==== tests/cases/compiler/class1.ts (2 errors) ==== - interface foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - class foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/class1.js b/tests/baselines/reference/class1.js deleted file mode 100644 index 7a104e237b6..00000000000 --- a/tests/baselines/reference/class1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [class1.ts] -interface foo{ } // error -class foo{ } // error - -//// [class1.js] -var foo = (function () { - function foo() { - } - return foo; -})(); // error diff --git a/tests/baselines/reference/classAbstractAsIdentifier.js b/tests/baselines/reference/classAbstractAsIdentifier.js new file mode 100644 index 00000000000..6adadd346b5 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.js @@ -0,0 +1,15 @@ +//// [classAbstractAsIdentifier.ts] +class abstract { + foo() { return 1; } +} + +new abstract; + +//// [classAbstractAsIdentifier.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.foo = function () { return 1; }; + return abstract; +})(); +new abstract; diff --git a/tests/baselines/reference/classAbstractAsIdentifier.symbols b/tests/baselines/reference/classAbstractAsIdentifier.symbols new file mode 100644 index 00000000000..f2ce2ebcab5 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + + foo() { return 1; } +>foo : Symbol(foo, Decl(classAbstractAsIdentifier.ts, 0, 16)) +} + +new abstract; +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + diff --git a/tests/baselines/reference/classAbstractAsIdentifier.types b/tests/baselines/reference/classAbstractAsIdentifier.types new file mode 100644 index 00000000000..e2894af804d --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : abstract + + foo() { return 1; } +>foo : () => number +>1 : number +} + +new abstract; +>new abstract : abstract +>abstract : typeof abstract + diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt new file mode 100644 index 00000000000..fee9f4cefee --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ==== + abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractConstructor.js b/tests/baselines/reference/classAbstractConstructor.js new file mode 100644 index 00000000000..fa88b0c7d37 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.js @@ -0,0 +1,11 @@ +//// [classAbstractConstructor.ts] +abstract class A { + abstract constructor() {} +} + +//// [classAbstractConstructor.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractCrashedOnce.errors.txt b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt new file mode 100644 index 00000000000..c2e38a6cf44 --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts(8,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts (1 errors) ==== + abstract class foo { + protected abstract test(); + } + + class bar extends foo { + test() { + this. + } + ~ +!!! error TS1003: Identifier expected. + } + var x = new bar(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js new file mode 100644 index 00000000000..f4268a4a13c --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -0,0 +1,35 @@ +//// [classAbstractCrashedOnce.ts] +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); + +//// [classAbstractCrashedOnce.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 foo = (function () { + function foo() { + } + return foo; +})(); +var bar = (function (_super) { + __extends(bar, _super); + function bar() { + _super.apply(this, arguments); + } + bar.prototype.test = function () { + this. + ; + }; + return bar; +})(foo); +var x = new bar(); diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt new file mode 100644 index 00000000000..20d5ca46933 --- /dev/null +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (5 errors) ==== + declare abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. + } + + declare abstract class AA { + abstract foo(); + } + + declare abstract class BB extends AA {} + + declare class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + declare class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + declare abstract class EE extends BB {} + + declare class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + declare abstract class GG extends CC {} + + declare abstract class AAA {} + + declare abstract class BBB extends AAA {} + + declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.errors.txt b/tests/baselines/reference/classAbstractGeneric.errors.txt new file mode 100644 index 00000000000..fb5a4c32a39 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(14,7): error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(18,7): error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts (6 errors) ==== + abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); + } + + abstract class B extends A {} + + class C extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. + + class D extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. + + class E extends A { // error -- doesn't implement bar + ~ +!!! error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. + foo() { return this.t; } + } + + class F extends A { // error -- doesn't implement foo + ~ +!!! error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + bar(t : T) {} + } + + class G extends A { + foo() { return this.t; } + bar(t: T) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js new file mode 100644 index 00000000000..5af7da1601a --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -0,0 +1,84 @@ +//// [classAbstractGeneric.ts] +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} + +//// [classAbstractGeneric.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); // error -- inherits abstract methods +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(A); // error -- inherits abstract methods +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { return this.t; }; + return E; +})(A); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function (t) { }; + return F; +})(A); +var G = (function (_super) { + __extends(G, _super); + function G() { + _super.apply(this, arguments); + } + G.prototype.foo = function () { return this.t; }; + G.prototype.bar = function (t) { }; + return G; +})(A); diff --git a/tests/baselines/reference/classAbstractImportInstantiation.errors.txt b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt new file mode 100644 index 00000000000..76110afa4ff --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(4,5): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts (2 errors) ==== + module M { + export abstract class A {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + } + + import myA = M.A; + + new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractImportInstantiation.js b/tests/baselines/reference/classAbstractImportInstantiation.js new file mode 100644 index 00000000000..bb25181f20d --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.js @@ -0,0 +1,25 @@ +//// [classAbstractImportInstantiation.ts] +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; + + +//// [classAbstractImportInstantiation.js] +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + new A; +})(M || (M = {})); +var myA = M.A; +new myA; diff --git a/tests/baselines/reference/classAbstractInAModule.errors.txt b/tests/baselines/reference/classAbstractInAModule.errors.txt new file mode 100644 index 00000000000..426da866087 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts(6,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts (1 errors) ==== + module M { + export abstract class A {} + export class B extends A {} + } + + new M.A; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new M.B; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js new file mode 100644 index 00000000000..e7ecd66b5bd --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -0,0 +1,34 @@ +//// [classAbstractInAModule.ts] +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; + +//// [classAbstractInAModule.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 M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(A); + M.B = B; +})(M || (M = {})); +new M.A; +new M.B; diff --git a/tests/baselines/reference/classAbstractInheritance.errors.txt b/tests/baselines/reference/classAbstractInheritance.errors.txt new file mode 100644 index 00000000000..3e106204415 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts (3 errors) ==== + abstract class A {} + + abstract class B extends A {} + + class C extends A {} + + abstract class AA { + abstract foo(); + } + + abstract class BB extends AA {} + + class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + abstract class EE extends BB {} + + class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js new file mode 100644 index 00000000000..6656e4687d2 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -0,0 +1,95 @@ +//// [classAbstractInheritance.ts] +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} + +//// [classAbstractInheritance.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + return DD; +})(BB); +var EE = (function (_super) { + __extends(EE, _super); + function EE() { + _super.apply(this, arguments); + } + return EE; +})(BB); +var FF = (function (_super) { + __extends(FF, _super); + function FF() { + _super.apply(this, arguments); + } + return FF; +})(CC); +var GG = (function (_super) { + __extends(GG, _super); + function GG() { + _super.apply(this, arguments); + } + return GG; +})(CC); diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt new file mode 100644 index 00000000000..6171ef2efab --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new A(1); // should report 1 error + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js new file mode 100644 index 00000000000..f3a0eecada9 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -0,0 +1,57 @@ +//// [classAbstractInstantiations1.ts] + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new A(1); // should report 1 error +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; + + +//// [classAbstractInstantiations1.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +new A; +new A(1); // should report 1 error +new B; +new C; +var a; +var b; +var c; +a = new B; +b = new B; +c = new B; diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt new file mode 100644 index 00000000000..b3b01fd656d --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -0,0 +1,75 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ==== + class A { + // ... + } + + abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; + } + + new B; // error + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var BB: typeof B = B; + var AA: typeof A = BB; // error, AA is not of abstract type. + new AA; + + function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. + ~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + var BB = B; + new BB; // error -- BB is of type typeof B. + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var x : any = C; + new x; // okay -- undefined behavior at runtime + + class C extends B { } // error -- not declared abstract + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. + + abstract class D extends B { } // okay + + class E extends B { // okay -- implements abstract method + bar() { return 1; } + } + + abstract class F extends B { + abstract foo() : number; + bar() { return 2; } + } + + abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + } + + class H { // error -- not declared abstract + abstract baz() : number; + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js new file mode 100644 index 00000000000..1f45f02da0b --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -0,0 +1,121 @@ +//// [classAbstractInstantiations2.ts] +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} + +//// [classAbstractInstantiations2.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { return this.bar(); }; + return B; +})(); +new B; // error +var BB = B; +var AA = BB; // error, AA is not of abstract type. +new AA; +function constructB(Factory) { + new Factory; // error -- Factory is of type typeof B. +} +var BB = B; +new BB; // error -- BB is of type typeof B. +var x = C; +new x; // okay -- undefined behavior at runtime +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); // error -- not declared abstract +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); // okay +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { return 1; }; + return E; +})(B); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function () { return 2; }; + return F; +})(B); +var G = (function () { + function G() { + } + return G; +})(); +var H = (function () { + function H() { + } + return H; +})(); diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt new file mode 100644 index 00000000000..b200404eaf0 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== + export default abstract class A {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. + ~~~~~ +!!! error TS1005: ';' expected. + export abstract class B {} + default abstract class C {} + ~~~~~~~ +!!! error TS1128: Declaration or statement expected. + import abstract class D {} + ~~~~~ +!!! error TS1005: '=' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractManyKeywords.js b/tests/baselines/reference/classAbstractManyKeywords.js new file mode 100644 index 00000000000..79191c029e1 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.js @@ -0,0 +1,28 @@ +//// [classAbstractManyKeywords.ts] +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} + +//// [classAbstractManyKeywords.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +exports.B = B; +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt new file mode 100644 index 00000000000..b3a2dec5e9c --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -0,0 +1,103 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(25,24): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(26,15): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(28,15): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(29,24): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(31,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(32,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(33,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(34,1): error TS2511: Cannot create an instance of the abstract class 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(37,1): error TS2511: Cannot create an instance of the abstract class 'DCI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(38,1): error TS2511: Cannot create an instance of the abstract class 'DIC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ==== + abstract class CM {} + module CM {} + + module MC {} + abstract class MC {} + + abstract class CI {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + interface CI {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface IC {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + abstract class IC {} + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + abstract class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + + class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + abstract class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + + declare abstract class DCI {} + interface DCI {} + + interface DIC {} + declare abstract class DIC {} + + declare abstract class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + declare class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + + declare class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + declare abstract class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + + new CM; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CM'. + new MC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'MC'. + new CI; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CI'. + new IC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'IC'. + new CC1; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CC1'. + new CC2; + new DCI; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCI'. + new DIC; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DIC'. + new DCC1; + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCC1'. + new DCC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js new file mode 100644 index 00000000000..f6a91f870d2 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -0,0 +1,93 @@ +//// [classAbstractMergedDeclaration.ts] +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; + +//// [classAbstractMergedDeclaration.js] +var CM = (function () { + function CM() { + } + return CM; +})(); +var MC = (function () { + function MC() { + } + return MC; +})(); +var CI = (function () { + function CI() { + } + return CI; +})(); +var IC = (function () { + function IC() { + } + return IC; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt new file mode 100644 index 00000000000..412378e267d --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== + abstract class A { + abstract foo() {} + ~~~~~~~~~~~~~~~~~ +!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.js b/tests/baselines/reference/classAbstractMethodWithImplementation.js new file mode 100644 index 00000000000..d9319012712 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.js @@ -0,0 +1,12 @@ +//// [classAbstractMethodWithImplementation.ts] +abstract class A { + abstract foo() {} +} + +//// [classAbstractMethodWithImplementation.js] +var A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt new file mode 100644 index 00000000000..121c1739632 --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ==== + abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract public foo_bb(); + ~~~~~~ +!!! error TS1029: 'public' modifier must precede 'abstract' modifier. + abstract protected foo_cc(); + ~~~~~~~~~ +!!! error TS1029: 'protected' modifier must precede 'abstract' modifier. + abstract private foo_dd(); + ~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract static foo_d(); + ~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + static abstract foo_e(); + ~~~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.js b/tests/baselines/reference/classAbstractMixedWithModifiers.js new file mode 100644 index 00000000000..71eb4c61c04 --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.js @@ -0,0 +1,23 @@ +//// [classAbstractMixedWithModifiers.ts] +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} + +//// [classAbstractMixedWithModifiers.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt new file mode 100644 index 00000000000..5af440ed4df --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + class B {} + + abstract + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractMultiLineDecl.js new file mode 100644 index 00000000000..3a92e2aa1e5 --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.js @@ -0,0 +1,33 @@ +//// [classAbstractMultiLineDecl.ts] +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; + +//// [classAbstractMultiLineDecl.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function () { + function C() { + } + return C; +})(); +new A; +new B; +new C; diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt new file mode 100644 index 00000000000..0a1c96bd30a --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts (5 errors) ==== + abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + abstract bar(); + + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz(); + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz() {} + + qux(); + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + + abstract class B { + abstract foo() : number; + abstract foo(); + ~~~ +!!! error TS2516: All declarations of an abstract method must be consecutive. + x : number; + abstract foo(); + abstract foo(); + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.js b/tests/baselines/reference/classAbstractOverloads.js new file mode 100644 index 00000000000..1bdff73d5b7 --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.js @@ -0,0 +1,38 @@ +//// [classAbstractOverloads.ts] +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} + +//// [classAbstractOverloads.js] +var A = (function () { + function A() { + } + A.prototype.baz = function () { }; + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt new file mode 100644 index 00000000000..223a3049825 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ==== + abstract class A { + abstract x : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + public abstract y : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + protected abstract z : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + private abstract w : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract m: () => void; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractProperties.js b/tests/baselines/reference/classAbstractProperties.js new file mode 100644 index 00000000000..0cbebcf0de0 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.js @@ -0,0 +1,21 @@ +//// [classAbstractProperties.ts] +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} + +//// [classAbstractProperties.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt new file mode 100644 index 00000000000..a9dbf0f7ba8 --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,41): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (2 errors) ==== + + class A { + foo() { return 1; } + } + + abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } + } + + class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + norf() { return super.bar(); } + } + + class AA { + foo() { return 1; } + bar() { return this.foo(); } + } + + abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js new file mode 100644 index 00000000000..deccaa50ccf --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -0,0 +1,74 @@ +//// [classAbstractSuperCalls.ts] + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} + + +//// [classAbstractSuperCalls.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 A = (function () { + function A() { + } + A.prototype.foo = function () { return 1; }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.bar = function () { _super.prototype.foo.call(this); }; + B.prototype.baz = function () { return this.foo; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.foo = function () { return 2; }; + C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract + C.prototype.norf = function () { return _super.prototype.bar.call(this); }; + return C; +})(B); +var AA = (function () { + function AA() { + } + AA.prototype.foo = function () { return 1; }; + AA.prototype.bar = function () { return this.foo(); }; + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt new file mode 100644 index 00000000000..df3682a36af --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts (1 errors) ==== + abstract class A { + abstract foo() : number; + } + + class B extends A { + foo() { return 1; } + } + + abstract class C extends A { + abstract foo() : number; + } + + var a = new B; + a.foo(); + + a = new C; // error, cannot instantiate abstract class. + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + a.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js new file mode 100644 index 00000000000..18d22803a7d --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -0,0 +1,49 @@ +//// [classAbstractUsingAbstractMethod1.ts] +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); + +//// [classAbstractUsingAbstractMethod1.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.foo = function () { return 1; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var a = new B; +a.foo(); +a = new C; // error, cannot instantiate abstract class. +a.foo(); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt new file mode 100644 index 00000000000..e01b233a4c1 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (3 errors) ==== + class A { + abstract foo(); + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } + + class B extends A {} + ~ +!!! error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. + + abstract class C extends A {} + + class D extends A { + foo() {} + } + + abstract class E extends A { + foo() {} + } + + abstract class AA { + abstract foo(); + } + + class BB extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + abstract class CC extends AA {} + + class DD extends AA { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js new file mode 100644 index 00000000000..d5797232929 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -0,0 +1,97 @@ +//// [classAbstractUsingAbstractMethods2.ts] +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} + +//// [classAbstractUsingAbstractMethods2.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.foo = function () { }; + return D; +})(A); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { }; + return E; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + DD.prototype.foo = function () { }; + return DD; +})(AA); diff --git a/tests/baselines/reference/classAbstractWithInterface.errors.txt b/tests/baselines/reference/classAbstractWithInterface.errors.txt new file mode 100644 index 00000000000..fa0a3d08957 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ==== + abstract interface I {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractWithInterface.js b/tests/baselines/reference/classAbstractWithInterface.js new file mode 100644 index 00000000000..317e393a2f5 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.js @@ -0,0 +1,4 @@ +//// [classAbstractWithInterface.ts] +abstract interface I {} + +//// [classAbstractWithInterface.js] diff --git a/tests/baselines/reference/classAndInterface1.errors.txt b/tests/baselines/reference/classAndInterface1.errors.txt deleted file mode 100644 index 8d31e847d71..00000000000 --- a/tests/baselines/reference/classAndInterface1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/classAndInterface1.ts(1,8): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/classAndInterface1.ts(2,11): error TS2300: Duplicate identifier 'cli'. - - -==== tests/cases/compiler/classAndInterface1.ts (2 errors) ==== - class cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. - interface cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterface1.js b/tests/baselines/reference/classAndInterface1.js deleted file mode 100644 index 5efabded838..00000000000 --- a/tests/baselines/reference/classAndInterface1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [classAndInterface1.ts] - class cli { } // error -interface cli { } // error - -//// [classAndInterface1.js] -var cli = (function () { - function cli() { - } - return cli; -})(); // error diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.symbols b/tests/baselines/reference/classAndInterfaceMerge.d.symbols new file mode 100644 index 00000000000..84fc2b129c1 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare class C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + class C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + export class C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + export interface C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.types b/tests/baselines/reference/classAndInterfaceMerge.d.types new file mode 100644 index 00000000000..baab121ca6e --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : C + +declare class C { } +>C : C + +interface C { } +>C : C + +interface C { } +>C : C + +declare module M { +>M : typeof M + + interface C1 { } +>C1 : C1 + + class C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + export class C2 { } +>C2 : C2 +} + +declare module M { +>M : typeof M + + export interface C2 { } +>C2 : C2 +} diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt new file mode 100644 index 00000000000..48e52faae1e --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(2,12): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(6,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (6 errors) ==== + declare class C1 { + public x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C1 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C2 { + protected x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C2 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C3 { + private x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C3 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js new file mode 100644 index 00000000000..07b425383f4 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js @@ -0,0 +1,26 @@ +//// [classAndInterfaceMergeConflictingMembers.ts] +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} + +//// [classAndInterfaceMergeConflictingMembers.js] diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index aa3e687cf4d..332024b74fd 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,27 +1,39 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2300: Duplicate identifier 'D'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } interface D { // error ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionTest2.types b/tests/baselines/reference/classExpressionTest2.types index 5586b451d3a..2ff7d79bc5f 100644 --- a/tests/baselines/reference/classExpressionTest2.types +++ b/tests/baselines/reference/classExpressionTest2.types @@ -28,13 +28,13 @@ function M() { } var v = new m(); ->v : ->new m() : +>v : C +>new m() : C >m : typeof C return v.f(); >v.f() : { t: string; x: number; } >v.f : () => { t: T; x: number; } ->v : +>v : C >f : () => { t: T; x: number; } } diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt new file mode 100644 index 00000000000..3e62e72be84 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C2'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2420: Class 'C3' incorrectly implements interface 'C1'. + Property 'y' is missing in type 'C3'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2420: Class 'C4' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C4'. + + +==== tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts (3 errors) ==== + declare class C1 { + x : number; + } + + interface C1 { + y : number; + } + + class C2 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C2' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C2'. + } + + class C3 implements C1 { // error -- missing y + ~~ +!!! error TS2420: Class 'C3' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'y' is missing in type 'C3'. + x : number; + } + + class C4 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C4' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C4'. + y : number; + } + + class C5 implements C1 { // okay + x : number; + y : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.js b/tests/baselines/reference/classImplementsMergedClassInterface.js new file mode 100644 index 00000000000..64a0198cc16 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.js @@ -0,0 +1,46 @@ +//// [classImplementsMergedClassInterface.ts] +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} + +//// [classImplementsMergedClassInterface.js] +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function () { + function C4() { + } + return C4; +})(); +var C5 = (function () { + function C5() { + } + return C5; +})(); diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index d5eab2c7994..5960e6ae32b 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2300: Duplicate identifier 'Bar'. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier 'Bar'. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2518: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/clinterfaces.js b/tests/baselines/reference/clinterfaces.js index 02ae7349869..a55924227c9 100644 --- a/tests/baselines/reference/clinterfaces.js +++ b/tests/baselines/reference/clinterfaces.js @@ -49,3 +49,4 @@ var Bar = (function () { } return Bar; })(); +module.exports = Foo; diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types index e40422450b4..92835611c6d 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types @@ -98,7 +98,7 @@ x2 += E.a; x2 += {}; >x2 += {} : string >x2 : string ->{} : {} +>{} : { [x: number]: undefined; } x2 += null; >x2 += null : string diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt index 1dfb605db33..deb80dbcca8 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt index dc8892fd326..b10d184f799 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/contextualIntersectionType.js b/tests/baselines/reference/contextualIntersectionType.js new file mode 100644 index 00000000000..d61fc52fce7 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.js @@ -0,0 +1,14 @@ +//// [contextualIntersectionType.ts] +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; + + +//// [contextualIntersectionType.js] +var x; +x = { + a: function (s) { return s; }, + b: function (n) { return n; } +}; diff --git a/tests/baselines/reference/contextualIntersectionType.symbols b/tests/baselines/reference/contextualIntersectionType.symbols new file mode 100644 index 00000000000..cb7ac9f3d41 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) +>a : Symbol(a, Decl(contextualIntersectionType.ts, 0, 8)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 0, 13)) +>b : Symbol(b, Decl(contextualIntersectionType.ts, 0, 39)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 0, 44)) + +x = { +>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3)) + + a: s => s, +>a : Symbol(a, Decl(contextualIntersectionType.ts, 1, 5)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) +>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6)) + + b: n => n +>b : Symbol(b, Decl(contextualIntersectionType.ts, 2, 14)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) +>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6)) + +}; + diff --git a/tests/baselines/reference/contextualIntersectionType.types b/tests/baselines/reference/contextualIntersectionType.types new file mode 100644 index 00000000000..4967979d736 --- /dev/null +++ b/tests/baselines/reference/contextualIntersectionType.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts === +var x: { a: (s: string) => string } & { b: (n: number) => number }; +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>a : (s: string) => string +>s : string +>b : (n: number) => number +>n : number + +x = { +>x = { a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } +>x : { a: (s: string) => string; } & { b: (n: number) => number; } +>{ a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; } + + a: s => s, +>a : (s: string) => string +>s => s : (s: string) => string +>s : string +>s : string + + b: n => n +>b : (n: number) => number +>n => n : (n: number) => number +>n : number +>n : number + +}; + diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols index 172336603ab..3e23a7812f5 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols @@ -82,5 +82,7 @@ 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 02dfecf5c08..8e1915d4754 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: any) => any ->a : any ->a.toString() : any ->a.toString : any ->a : any ->toString : any +>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 diff --git a/tests/baselines/reference/declFileFunctions.js b/tests/baselines/reference/declFileFunctions.js index da1917163e1..163fa1905c8 100644 --- a/tests/baselines/reference/declFileFunctions.js +++ b/tests/baselines/reference/declFileFunctions.js @@ -26,6 +26,19 @@ export function fooWithSingleOverload(a: any) { return a; } +export function fooWithTypePredicate(a: any): a is number { + return true; +} +export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number { + return true; +} +export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { + return true; +} +export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number { + return true; +} + /** This comment should appear for nonExportedFoo*/ function nonExportedFoo() { } @@ -92,6 +105,26 @@ function fooWithSingleOverload(a) { return a; } exports.fooWithSingleOverload = fooWithSingleOverload; +function fooWithTypePredicate(a) { + return true; +} +exports.fooWithTypePredicate = fooWithTypePredicate; +function fooWithTypePredicateAndMulitpleParams(a, b, c) { + return true; +} +exports.fooWithTypePredicateAndMulitpleParams = fooWithTypePredicateAndMulitpleParams; +function fooWithTypeTypePredicateAndGeneric(a) { + return true; +} +exports.fooWithTypeTypePredicateAndGeneric = fooWithTypeTypePredicateAndGeneric; +function fooWithTypeTypePredicateAndRestParam(a) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return true; +} +exports.fooWithTypeTypePredicateAndRestParam = fooWithTypeTypePredicateAndRestParam; /** This comment should appear for nonExportedFoo*/ function nonExportedFoo() { } @@ -144,6 +177,10 @@ export declare function fooWithRestParameters(a: string, ...rests: string[]): st export declare function fooWithOverloads(a: string): string; export declare function fooWithOverloads(a: number): number; export declare function fooWithSingleOverload(a: string): string; +export declare function fooWithTypePredicate(a: any): a is number; +export declare function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number; +export declare function fooWithTypeTypePredicateAndGeneric(a: any): a is T; +export declare function fooWithTypeTypePredicateAndRestParam(a: any, ...rest: any[]): a is number; //// [declFileFunctions_1.d.ts] /** This comment should appear for foo*/ declare function globalfoo(): void; diff --git a/tests/baselines/reference/declFileFunctions.symbols b/tests/baselines/reference/declFileFunctions.symbols index ff04d211557..1853da94a46 100644 --- a/tests/baselines/reference/declFileFunctions.symbols +++ b/tests/baselines/reference/declFileFunctions.symbols @@ -57,49 +57,83 @@ export function fooWithSingleOverload(a: any) { >a : Symbol(a, Decl(declFileFunctions_0.ts, 21, 38)) } +export function fooWithTypePredicate(a: any): a is number { +>fooWithTypePredicate : Symbol(fooWithTypePredicate, Decl(declFileFunctions_0.ts, 23, 1)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37)) + + return true; +} +export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number { +>fooWithTypePredicateAndMulitpleParams : Symbol(fooWithTypePredicateAndMulitpleParams, Decl(declFileFunctions_0.ts, 27, 1)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54)) +>b : Symbol(b, Decl(declFileFunctions_0.ts, 28, 61)) +>c : Symbol(c, Decl(declFileFunctions_0.ts, 28, 69)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54)) + + return true; +} +export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { +>fooWithTypeTypePredicateAndGeneric : Symbol(fooWithTypeTypePredicateAndGeneric, Decl(declFileFunctions_0.ts, 30, 1)) +>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54)) +>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51)) + + return true; +} +export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number { +>fooWithTypeTypePredicateAndRestParam : Symbol(fooWithTypeTypePredicateAndRestParam, Decl(declFileFunctions_0.ts, 33, 1)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53)) +>rest : Symbol(rest, Decl(declFileFunctions_0.ts, 34, 60)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53)) + + return true; +} + /** This comment should appear for nonExportedFoo*/ function nonExportedFoo() { ->nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 23, 1)) +>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 36, 1)) } /** This is comment for function signature*/ function nonExportedFooWithParameters(/** this is comment about a*/a: string, ->nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 27, 1)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38)) +>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 40, 1)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38)) /** this is comment for b*/ b: number) { ->b : Symbol(b, Decl(declFileFunctions_0.ts, 29, 77)) +>b : Symbol(b, Decl(declFileFunctions_0.ts, 42, 77)) var d = a; ->d : Symbol(d, Decl(declFileFunctions_0.ts, 32, 7)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38)) +>d : Symbol(d, Decl(declFileFunctions_0.ts, 45, 7)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38)) } function nonExportedFooWithRestParameters(a: string, ...rests: string[]) { ->nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 33, 1)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42)) ->rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52)) +>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 46, 1)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42)) +>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52)) return a + rests.join(""); ->a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42)) >rests.join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31)) ->rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52)) +>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52)) >join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31)) } function nonExportedFooWithOverloads(a: string): string; ->nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 38, 37)) +>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 51, 37)) function nonExportedFooWithOverloads(a: number): number; ->nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 39, 37)) +>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 52, 37)) function nonExportedFooWithOverloads(a: any): any { ->nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56)) ->a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37)) +>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37)) return a; ->a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37)) +>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37)) } === tests/cases/compiler/declFileFunctions_1.ts === diff --git a/tests/baselines/reference/declFileFunctions.types b/tests/baselines/reference/declFileFunctions.types index b9e94f7ffcd..9ad974463b7 100644 --- a/tests/baselines/reference/declFileFunctions.types +++ b/tests/baselines/reference/declFileFunctions.types @@ -60,6 +60,44 @@ export function fooWithSingleOverload(a: any) { >a : any } +export function fooWithTypePredicate(a: any): a is number { +>fooWithTypePredicate : (a: any) => a is number +>a : any +>a : any + + return true; +>true : boolean +} +export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number { +>fooWithTypePredicateAndMulitpleParams : (a: any, b: any, c: any) => a is number +>a : any +>b : any +>c : any +>a : any + + return true; +>true : boolean +} +export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { +>fooWithTypeTypePredicateAndGeneric : (a: any) => a is T +>T : T +>a : any +>a : any +>T : T + + return true; +>true : boolean +} +export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number { +>fooWithTypeTypePredicateAndRestParam : (a: any, ...rest: any[]) => a is number +>a : any +>rest : any[] +>a : any + + return true; +>true : boolean +} + /** This comment should appear for nonExportedFoo*/ function nonExportedFoo() { >nonExportedFoo : () => void diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 8ec341ce15b..179db3598ab 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/declInput.ts(5,7): error TS2300: Duplicate identifier 'bar'. +tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2518: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt new file mode 100644 index 00000000000..a46dfb0d339 --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(5,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(7,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(9,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file2.ts(2,15): error TS2300: Duplicate identifier 'C3'. +tests/cases/conformance/classes/classDeclarations/file3.ts(2,15): error TS2300: Duplicate identifier 'C3'. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (5 errors) ==== + + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + interface C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js new file mode 100644 index 00000000000..a38391d90db --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts] //// + +//// [file1.ts] + + +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +//// [file2.ts] + +declare class C3 { } + +//// [file3.ts] + +declare class C3 { } + +//// [file1.js] +//// [file2.js] +//// [file3.js] diff --git a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt index 14845839089..3ad3cabebe2 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10 class C extends S { @super.decorator ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. method() { } } } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt index 40610b5b838..c67bc2479ec 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts (5 errors) ==== @@ -30,7 +30,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r2 = () => super(); // error for misplaced super call (nested function) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. @@ -42,7 +42,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r = function () { super() } // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index f465afbccad..ab79f8d3e23 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (10 errors) ==== @@ -22,43 +22,43 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index 6af2560504d..c232eb24636 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 84c21ff77e6..89f62f97185 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 6c80d13b2f4..731e9748203 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2300: Duplicate identifier 'I'. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2300: Duplicate identifier 'I'. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt new file mode 100644 index 00000000000..9867441f770 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -0,0 +1,68 @@ +tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged +tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/compiler/file1.ts (5 errors) ==== + + interface I { } + ~ +!!! error TS2518: Only an ambient class can be merged with an interface. + class C1 { } + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + class C2 { } + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + function f() { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + class Foo { + static x: number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + module N { + export module F { + var t; + } + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + class I { } // error -- cannot merge interface with non-ambient class + ~ +!!! error TS2518: Only an ambient class can be merged with an interface. + interface C1 { } // error -- cannot merge interface with non-ambient class + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + function C2() { } // error -- cannot merge function with non-ambient class + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + class f { } // error -- cannot merge function with non-ambient class + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + module Foo { + ~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged + export var x: number; // error for redeclaring var in a different parent + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare module N { + export function F(); // no error because function is ambient + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js new file mode 100644 index 00000000000..a2509ea97f4 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -0,0 +1,110 @@ +//// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// + +//// [file1.ts] + +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +//// [file2.ts] +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} + + +//// [file1.js] +var C1 = (function () { + function C1() { + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +function f() { } +var v = 3; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var N; +(function (N) { + var F; + (function (F) { + var t; + })(F = N.F || (N.F = {})); +})(N || (N = {})); +//// [file2.js] +var I = (function () { + function I() { + } + return I; +})(); // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +var f = (function () { + function f() { + } + return f; +})(); // error -- cannot merge function with non-ambient class +var v = 3; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); + + +//// [file1.d.ts] +interface I { +} +declare class C1 { +} +declare class C2 { +} +declare function f(): void; +declare var v: number; +declare class Foo { + static x: number; +} +declare module N { + module F { + } +} +//// [file2.d.ts] +declare class I { +} +interface C1 { +} +declare function C2(): void; +declare class f { +} +declare var v: number; +declare module Foo { + var x: number; +} +declare module N { + function F(): any; +} diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index 48564baf796..ad1482e7f1a 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 5f62de9bfa1..42db5aeaa85 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index b54ac35ba78..453e04d7521 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index df900ac860e..b686dd19592 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 4d0887c1ff8..4ac60f9b429 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1691, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt index 7fe090395e3..06211ef771f 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt +++ b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } @@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' () => { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index cd1aa23f14d..9ecc7a1565e 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ==== @@ -94,26 +94,26 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T //super call in class member initializer of derived type t = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. fn() { //super call in class member function of derived type super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } //super call in class accessor (get and set) of derived type get foo() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return null; } set foo(n) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index b273b1b6f45..c34ed912046 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -9,30 +9,30 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(25,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(30,9): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class. @@ -119,13 +119,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.publicMember = 1; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -133,7 +133,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -141,18 +141,18 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn2() { function inner() { super.publicFunc(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } var x = { test: function () { return super.publicFunc(); } ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -165,13 +165,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.privateMember = 1; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -179,7 +179,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -187,7 +187,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -199,10 +199,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess static fn() { super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -212,10 +212,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -226,10 +226,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 833ea1d6875..08e5f4ff468 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 2c08338ce73..066d9534051 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 6be3c83964a..8c34f6f0d7a 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 97200f93f35..4e7aaf7e362 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index bbe3504294c..70c1132afbd 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 4f15b541356..46507255937 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 0f409605e28..8401de024d9 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 44cc83143af..93e918c4bcd 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 0218a8b9995..04445f50171 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 82918a19986..4c645d359dd 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index e4324b05779..6887b46a44d 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index 11de20174a7..a726b7eedc2 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 20af2cb65fb..11ff91e1162 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index eb77e578510..f6619ff753d 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index 9c6afa04adb..a9ea283d673 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index b9e5bbacbfa..1d447ea87cc 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index f3bd38be1df..6b8012c7929 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index 574d52e4c56..b8d01d3bd1b 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/functionConstraintSatisfaction3.types b/tests/baselines/reference/functionConstraintSatisfaction3.types index 04963c36519..c58e62f6995 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction3.types +++ b/tests/baselines/reference/functionConstraintSatisfaction3.types @@ -37,12 +37,12 @@ var c: { (): string; (x): string }; >x : any var r1 = foo((x) => x); ->r1 : (x: any) => any ->foo((x) => x) : (x: any) => any +>r1 : (x: string) => string +>foo((x) => x) : (x: string) => string >foo : string>(x: T) => T ->(x) => x : (x: any) => any ->x : any ->x : any +>(x) => x : (x: string) => string +>x : string +>x : string var r2 = foo((x: string) => x); >r2 : (x: string) => string @@ -53,12 +53,12 @@ var r2 = foo((x: string) => x); >x : string var r3 = foo(function (x) { return x }); ->r3 : (x: any) => any ->foo(function (x) { return x }) : (x: any) => any +>r3 : (x: string) => string +>foo(function (x) { return x }) : (x: string) => string >foo : string>(x: T) => T ->function (x) { return x } : (x: any) => any ->x : any ->x : any +>function (x) { return x } : (x: string) => string +>x : string +>x : string var r4 = foo(function (x: string) { return x }); >r4 : (x: string) => string @@ -130,8 +130,8 @@ var c2: { (x: T): T; (x: T, y: T): T }; >T : T var r9 = foo(function (x: U) { return x; }); ->r9 : (x: U) => U ->foo(function (x: U) { return x; }) : (x: U) => U +>r9 : (x: string) => string +>foo(function (x: U) { return x; }) : (x: string) => string >foo : string>(x: T) => T >function (x: U) { return x; } : (x: U) => U >U : U @@ -140,8 +140,8 @@ var r9 = foo(function (x: U) { return x; }); >x : U var r10 = foo((x: U) => x); ->r10 : (x: U) => U ->foo((x: U) => x) : (x: U) => U +>r10 : (x: string) => string +>foo((x: U) => x) : (x: string) => string >foo : string>(x: T) => T >(x: U) => x : (x: U) => U >U : U diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 4cdac0f12c5..7f30b4f6797 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index afae1c1a808..c4fb9401517 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 0a14548d197..509ed22d197 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index 58ee2aa66f8..79cc3e275ad 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index c6eeb6b4a3d..6247bd7b85c 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index b904dfb446b..dce2524d1ba 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index e596203b9eb..f9c9b7b6e22 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index 84e42a06cfd..bc43ea8c8f9 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index 9e689d9df42..789eb22347c 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index 2edec8fd21a..e7a5898099f 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index e0668786598..5a0aec4d592 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index 4d3ad862565..08cc7289ef8 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index bfff5f9e10a..fcee922d1e9 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index e1bbbd96b40..27b246515f6 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index 57790d5b700..260137dd1cf 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index 2f5d2405507..a149a592e3d 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1672, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index 49c43ce135f..086c65685a8 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index 06340925fec..89c01ff0203 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1662, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index aa0b237d1f2..72d8ebf57a1 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index bcf580320e5..d03f8d5e68a 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -9,9 +9,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{ [x: number]: undefined; }' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -55,9 +55,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup !!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ -!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. +!!! error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. !!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{ [x: number]: undefined; }' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt index a07fbea75d8..1d3d2e7c275 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/illegalSuperCallsInConstructor.ts (8 errors) ==== @@ -19,15 +19,15 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup var r2 = () => super(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r3 = () => { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r4 = function () { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r5 = { ~~~~~~~~~~~~~~~~~~ get foo() { @@ -37,7 +37,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; ~~~~~~~~~~~~~~~~~~~~~~~~~ }, @@ -49,7 +49,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~~~~~~~~~ } diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.js b/tests/baselines/reference/inferentialTypingUsingApparentType1.js new file mode 100644 index 00000000000..02161a98695 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType1.ts] +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); + +//// [inferentialTypingUsingApparentType1.js] +function foo(x) { + return undefined; +} +foo(function (x) { return x.length; }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols new file mode 100644 index 00000000000..4babc614183 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType1.ts, 0, 24)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 0, 46)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType1.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo(x => x.length); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType1.ts, 0, 0)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType1.ts, 4, 4)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType1.types b/tests/baselines/reference/inferentialTypingUsingApparentType1.types new file mode 100644 index 00000000000..b56f3670ddc --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType1.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType1.ts === +function foo number>(x: T): T { +>foo : number>(x: T) => T +>T : T +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo(x => x.length); +>foo(x => x.length) : (x: string) => number +>foo : number>(x: T) => T +>x => x.length : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.js b/tests/baselines/reference/inferentialTypingUsingApparentType2.js new file mode 100644 index 00000000000..7cb7e49cd62 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.js @@ -0,0 +1,12 @@ +//// [inferentialTypingUsingApparentType2.ts] +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); + +//// [inferentialTypingUsingApparentType2.js] +function foo(x) { + return undefined; +} +foo({ m: function (x) { return x.length; } }); diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols new file mode 100644 index 00000000000..3c47eb4c697 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 0, 24)) +>p : Symbol(p, Decl(inferentialTypingUsingApparentType2.ts, 0, 27)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 0, 49)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType2.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo({ m(x) { return x.length } }); +>foo : Symbol(foo, Decl(inferentialTypingUsingApparentType2.ts, 0, 0)) +>m : Symbol(m, Decl(inferentialTypingUsingApparentType2.ts, 4, 5)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>x.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>x : Symbol(x, Decl(inferentialTypingUsingApparentType2.ts, 4, 8)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType2.types b/tests/baselines/reference/inferentialTypingUsingApparentType2.types new file mode 100644 index 00000000000..597f5885f5a --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType2.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType2.ts === +function foo(x: T): T { +>foo : (x: T) => T +>T : T +>m : (p: string) => number +>p : string +>x : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo({ m(x) { return x.length } }); +>foo({ m(x) { return x.length } }) : { } +>foo : (x: T) => T +>{ m(x) { return x.length } } : { m(x: string): number; } +>m : (x: string) => number +>x : string +>x.length : number +>x : string +>length : number + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.js b/tests/baselines/reference/inferentialTypingUsingApparentType3.js new file mode 100644 index 00000000000..819ca05098d --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.js @@ -0,0 +1,56 @@ +//// [inferentialTypingUsingApparentType3.ts] +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; + +//// [inferentialTypingUsingApparentType3.js] +var CharField = (function () { + function CharField() { + } + CharField.prototype.clean = function (input) { + return "Yup"; + }; + return CharField; +})(); +var NumberField = (function () { + function NumberField() { + } + NumberField.prototype.clean = function (input) { + return 123; + }; + return NumberField; +})(); +var ObjectField = (function () { + function ObjectField(fields) { + this.fields = fields; + } + return ObjectField; +})(); +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); +person.fields.id; diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols new file mode 100644 index 00000000000..ac3058e8649 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) + + clean(input: T): T +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 0, 20)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 1, 10)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 0, 16)) +} + +class CharField implements Field { +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: string) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 4, 42)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 5, 10)) + + return "Yup"; + } +} + +class NumberField implements Field { +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + clean(input: number) { +>clean : Symbol(clean, Decl(inferentialTypingUsingApparentType3.ts, 10, 44)) +>input : Symbol(input, Decl(inferentialTypingUsingApparentType3.ts, 11, 10)) + + return 123; + } +} + +class ObjectField }> { +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) +>A : Symbol(A, Decl(inferentialTypingUsingApparentType3.ts, 16, 18)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 16, 34)) +>Field : Symbol(Field, Decl(inferentialTypingUsingApparentType3.ts, 0, 0)) + + constructor(public fields: T) { } +>fields : Symbol(fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>T : Symbol(T, Decl(inferentialTypingUsingApparentType3.ts, 16, 20)) +} + +var person = new ObjectField({ +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>ObjectField : Symbol(ObjectField, Decl(inferentialTypingUsingApparentType3.ts, 14, 1)) + + id: new NumberField(), +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>NumberField : Symbol(NumberField, Decl(inferentialTypingUsingApparentType3.ts, 8, 1)) + + name: new CharField() +>name : Symbol(name, Decl(inferentialTypingUsingApparentType3.ts, 21, 26)) +>CharField : Symbol(CharField, Decl(inferentialTypingUsingApparentType3.ts, 2, 1)) + +}); + +person.fields.id; +>person.fields.id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) +>person.fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>person : Symbol(person, Decl(inferentialTypingUsingApparentType3.ts, 20, 3)) +>fields : Symbol(ObjectField.fields, Decl(inferentialTypingUsingApparentType3.ts, 17, 16)) +>id : Symbol(id, Decl(inferentialTypingUsingApparentType3.ts, 20, 30)) + diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types new file mode 100644 index 00000000000..7d0da8f4b06 --- /dev/null +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -0,0 +1,75 @@ +=== tests/cases/compiler/inferentialTypingUsingApparentType3.ts === +interface Field { +>Field : Field +>T : T + + clean(input: T): T +>clean : (input: T) => T +>input : T +>T : T +>T : T +} + +class CharField implements Field { +>CharField : CharField +>Field : Field + + clean(input: string) { +>clean : (input: string) => string +>input : string + + return "Yup"; +>"Yup" : string + } +} + +class NumberField implements Field { +>NumberField : NumberField +>Field : Field + + clean(input: number) { +>clean : (input: number) => number +>input : number + + return 123; +>123 : number + } +} + +class ObjectField }> { +>ObjectField : ObjectField +>A : A +>T : T +>name : string +>Field : Field + + constructor(public fields: T) { } +>fields : T +>T : T +} + +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; }> +>ObjectField : typeof ObjectField +>{ id: new NumberField(), name: new CharField()} : { [x: string]: CharField | NumberField; id: NumberField; name: CharField; } + + id: new NumberField(), +>id : NumberField +>new NumberField() : NumberField +>NumberField : typeof NumberField + + name: new CharField() +>name : CharField +>new CharField() : CharField +>CharField : typeof CharField + +}); + +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; } +>id : NumberField + diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 9739d946bc5..db525e6f21f 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2300: Duplicate identifier 'I2'. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate identifier 'I2'. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate iden interface I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2518: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt new file mode 100644 index 00000000000..4f26cc63ba3 --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -0,0 +1,162 @@ +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(19,1): error TS2322: Type 'A' is not assignable to type 'A & B'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(20,1): error TS2322: Type 'B' is not assignable to type 'A & B'. + Type 'B' is not assignable to type 'A'. + Property 'a' is missing in type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(23,1): error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type '(A & B) | (C & D)'. + Type 'A' is not assignable to type 'C & D'. + Type 'A' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(25,1): error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type '(A & B) | (C & D)'. + Type 'C' is not assignable to type 'C & D'. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(26,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A & B'. + Type 'C & D' is not assignable to type 'A'. + Type 'D' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(27,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C & D'. + Type 'A & B' is not assignable to type 'C'. + Type 'B' is not assignable to type 'C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. + Type 'A & B' is not assignable to type 'C | D'. + Type 'A & B' is not assignable to type 'D'. + Type 'B' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type '(A | B) & (C | D)'. + Type 'A' is not assignable to type 'C | D'. + Type 'A' is not assignable to type 'D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. + Type 'C & D' is not assignable to type 'A | B'. + Type 'C & D' is not assignable to type 'B'. + Type 'D' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type '(A | B) & (C | D)'. + Type 'C' is not assignable to type 'A | B'. + Type 'C' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. + Type '(A | B) & (C | D)' is not assignable to type 'A'. + Type 'C | D' is not assignable to type 'A'. + Type 'C' is not assignable to type 'A'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. + Type '(A | B) & (C | D)' is not assignable to type 'C'. + Type 'C | D' is not assignable to type 'C'. + Type 'D' is not assignable to type 'C'. + + +==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ==== + interface A { a: string } + interface B { b: string } + interface C { c: string } + interface D { d: string } + + var a: A; + var b: B; + var c: C; + var d: D; + var anb: A & B; + var aob: A | B; + var cnd: C & D; + var cod: C | D; + var x: A & B | C & D; + var y: (A | B) & (C | D); + + a = anb; // Ok + b = anb; // Ok + anb = a; + ~~~ +!!! error TS2322: Type 'A' is not assignable to type 'A & B'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + anb = b; + ~~~ +!!! error TS2322: Type 'B' is not assignable to type 'A & B'. +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type 'B'. + + x = anb; // Ok + x = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A' is not assignable to type 'C'. + x = cnd; // Ok + x = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A & B) | (C & D)'. +!!! error TS2322: Type 'C' is not assignable to type 'C & D'. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + anb = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A & B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A'. +!!! error TS2322: Type 'D' is not assignable to type 'A'. + aob = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + cnd = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C'. +!!! error TS2322: Type 'B' is not assignable to type 'C'. + cod = x; + ~~~ +!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + + y = anb; + ~ +!!! error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type 'D'. +!!! error TS2322: Type 'B' is not assignable to type 'D'. + y = aob; + ~ +!!! error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'A' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A' is not assignable to type 'D'. + y = cnd; + ~ +!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B'. +!!! error TS2322: Type 'D' is not assignable to type 'B'. + y = cod; + ~ +!!! error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'. +!!! error TS2322: Type 'C' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C' is not assignable to type 'B'. + anb = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'. +!!! error TS2322: Type 'C | D' is not assignable to type 'A'. +!!! error TS2322: Type 'C' is not assignable to type 'A'. + aob = y; // Ok + cnd = y; + ~~~ +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. +!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'. +!!! error TS2322: Type 'C | D' is not assignable to type 'C'. +!!! error TS2322: Type 'D' is not assignable to type 'C'. + cod = y; // Ok + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionAndUnionTypes.js b/tests/baselines/reference/intersectionAndUnionTypes.js new file mode 100644 index 00000000000..ec0adaab8b8 --- /dev/null +++ b/tests/baselines/reference/intersectionAndUnionTypes.js @@ -0,0 +1,72 @@ +//// [intersectionAndUnionTypes.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok + + +//// [intersectionAndUnionTypes.js] +var a; +var b; +var c; +var d; +var anb; +var aob; +var cnd; +var cod; +var x; +var y; +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/baselines/reference/intersectionTypeAssignment.errors.txt b/tests/baselines/reference/intersectionTypeAssignment.errors.txt new file mode 100644 index 00000000000..11ea91d8f0e --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(8,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(9,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ a: string; }' is not assignable to type '{ b: string; }'. + Property 'b' is missing in type '{ a: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(13,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. + Property 'a' is missing in type '{ b: string; }'. +tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(14,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. + Type '{ b: string; }' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{ b: string; }'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts (4 errors) ==== + var a: { a: string }; + var b: { b: string }; + var x: { a: string, b: string }; + var y: { a: string } & { b: string }; + + a = x; + a = y; + x = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + y = a; // Error + ~ +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ b: string; }'. +!!! error TS2322: Property 'b' is missing in type '{ a: string; }'. + + b = x; + b = y; + x = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + y = b; // Error + ~ +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'. +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{ b: string; }'. + + x = y; + y = x; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeAssignment.js b/tests/baselines/reference/intersectionTypeAssignment.js new file mode 100644 index 00000000000..f1cddbf3b2a --- /dev/null +++ b/tests/baselines/reference/intersectionTypeAssignment.js @@ -0,0 +1,35 @@ +//// [intersectionTypeAssignment.ts] +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; + + +//// [intersectionTypeAssignment.js] +var a; +var b; +var x; +var y; +a = x; +a = y; +x = a; // Error +y = a; // Error +b = x; +b = y; +x = b; // Error +y = b; // Error +x = y; +y = x; diff --git a/tests/baselines/reference/intersectionTypeEquivalence.js b/tests/baselines/reference/intersectionTypeEquivalence.js new file mode 100644 index 00000000000..be04bfe7947 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.js @@ -0,0 +1,31 @@ +//// [intersectionTypeEquivalence.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; + + +//// [intersectionTypeEquivalence.js] +// A & B is equivalent to B & A. +var y; +var y; +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z; +var z; +var z; +var ab; +var bc; +var z1; +var z1; diff --git a/tests/baselines/reference/intersectionTypeEquivalence.symbols b/tests/baselines/reference/intersectionTypeEquivalence.symbols new file mode 100644 index 00000000000..2bec452c44e --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeEquivalence.ts, 0, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>b : Symbol(b, Decl(intersectionTypeEquivalence.ts, 1, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) +>c : Symbol(c, Decl(intersectionTypeEquivalence.ts, 2, 13)) + +// A & B is equivalent to B & A. +var y: A & B; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var y : B & A; +>y : Symbol(y, Decl(intersectionTypeEquivalence.ts, 5, 3), Decl(intersectionTypeEquivalence.ts, 6, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : (A & B) & C; +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z : A & (B & C); +>z : Symbol(z, Decl(intersectionTypeEquivalence.ts, 9, 3), Decl(intersectionTypeEquivalence.ts, 10, 3), Decl(intersectionTypeEquivalence.ts, 11, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var ab : A & B; +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) + +var bc : B & C; +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) +>B : Symbol(B, Decl(intersectionTypeEquivalence.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: typeof ab & C; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>ab : Symbol(ab, Decl(intersectionTypeEquivalence.ts, 12, 3)) +>C : Symbol(C, Decl(intersectionTypeEquivalence.ts, 1, 25)) + +var z1: A & typeof bc; +>z1 : Symbol(z1, Decl(intersectionTypeEquivalence.ts, 14, 3), Decl(intersectionTypeEquivalence.ts, 15, 3)) +>A : Symbol(A, Decl(intersectionTypeEquivalence.ts, 0, 0)) +>bc : Symbol(bc, Decl(intersectionTypeEquivalence.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeEquivalence.types b/tests/baselines/reference/intersectionTypeEquivalence.types new file mode 100644 index 00000000000..25e175275d7 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeEquivalence.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts === +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +// A & B is equivalent to B & A. +var y: A & B; +>y : A & B +>A : A +>B : B + +var y : B & A; +>y : A & B +>B : B +>A : A + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : (A & B) & C; +>z : A & B & C +>A : A +>B : B +>C : C + +var z : A & (B & C); +>z : A & B & C +>A : A +>B : B +>C : C + +var ab : A & B; +>ab : A & B +>A : A +>B : B + +var bc : B & C; +>bc : B & C +>B : B +>C : C + +var z1: typeof ab & C; +>z1 : A & B & C +>ab : A & B +>C : C + +var z1: A & typeof bc; +>z1 : A & B & C +>A : A +>bc : B & C + diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt new file mode 100644 index 00000000000..af0b1b447bc --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(5,5): error TS2322: Type 'T' is not assignable to type 'T & U'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): error TS2322: Type 'U' is not assignable to type 'T & U'. + Type 'U' is not assignable to type 'T'. + + +==== tests/cases/conformance/types/intersection/intersectionTypeInference.ts (2 errors) ==== + function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + ~~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'T & U'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + result = obj2; // Error + ~~~~~~ +!!! error TS2322: Type 'U' is not assignable to type 'T & U'. +!!! error TS2322: Type 'U' is not assignable to type 'T'. + return result; + } + + var x = extend({ a: "hello" }, { b: 42 }); + var s = x.a; + var n = x.b; + + interface A { + a: T; + } + + interface B { + b: U; + } + + function foo(obj: A & B): T | U { + return undefined; + } + + var z = foo({ a: "hello", b: 42 }); + var z: string | number; + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.js b/tests/baselines/reference/intersectionTypeInference.js new file mode 100644 index 00000000000..8e7f1238c07 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference.js @@ -0,0 +1,47 @@ +//// [intersectionTypeInference.ts] +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; + + +//// [intersectionTypeInference.js] +function extend(obj1, obj2) { + var result; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; +function foo(obj) { + return undefined; +} +var z = foo({ a: "hello", b: 42 }); +var z; diff --git a/tests/baselines/reference/intersectionTypeMembers.js b/tests/baselines/reference/intersectionTypeMembers.js new file mode 100644 index 00000000000..9c1cd75d601 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.js @@ -0,0 +1,44 @@ +//// [intersectionTypeMembers.ts] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); + + +//// [intersectionTypeMembers.js] +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types +var abc; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; +var xyz; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; +var f; +var s = f("hello"); +var n = f(42); diff --git a/tests/baselines/reference/intersectionTypeMembers.symbols b/tests/baselines/reference/intersectionTypeMembers.symbols new file mode 100644 index 00000000000..ebec69b4ebe --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.symbols @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeMembers.ts, 3, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>b : Symbol(b, Decl(intersectionTypeMembers.ts, 4, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) +>c : Symbol(c, Decl(intersectionTypeMembers.ts, 5, 13)) + +var abc: A & B & C; +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +abc.a = "hello"; +>abc.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +abc.b = "hello"; +>abc.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +abc.c = "hello"; +>abc.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>abc : Symbol(abc, Decl(intersectionTypeMembers.ts, 7, 3)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +interface X { x: A } +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13)) +>A : Symbol(A, Decl(intersectionTypeMembers.ts, 0, 0)) + +interface Y { x: B } +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 13, 13)) +>B : Symbol(B, Decl(intersectionTypeMembers.ts, 3, 25)) + +interface Z { x: C } +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 14, 13)) +>C : Symbol(C, Decl(intersectionTypeMembers.ts, 4, 25)) + +var xyz: X & Y & Z; +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>X : Symbol(X, Decl(intersectionTypeMembers.ts, 10, 16)) +>Y : Symbol(Y, Decl(intersectionTypeMembers.ts, 12, 20)) +>Z : Symbol(Z, Decl(intersectionTypeMembers.ts, 13, 20)) + +xyz.x.a = "hello"; +>xyz.x.a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>a : Symbol(A.a, Decl(intersectionTypeMembers.ts, 3, 13)) + +xyz.x.b = "hello"; +>xyz.x.b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>b : Symbol(B.b, Decl(intersectionTypeMembers.ts, 4, 13)) + +xyz.x.c = "hello"; +>xyz.x.c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) +>xyz.x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>xyz : Symbol(xyz, Decl(intersectionTypeMembers.ts, 16, 3)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 12, 13), Decl(intersectionTypeMembers.ts, 13, 13), Decl(intersectionTypeMembers.ts, 14, 13)) +>c : Symbol(C.c, Decl(intersectionTypeMembers.ts, 5, 13)) + +type F1 = (x: string) => string; +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 21, 11)) + +type F2 = (x: number) => number; +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) +>x : Symbol(x, Decl(intersectionTypeMembers.ts, 22, 11)) + +var f: F1 & F2; +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) +>F1 : Symbol(F1, Decl(intersectionTypeMembers.ts, 19, 18)) +>F2 : Symbol(F2, Decl(intersectionTypeMembers.ts, 21, 32)) + +var s = f("hello"); +>s : Symbol(s, Decl(intersectionTypeMembers.ts, 25, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + +var n = f(42); +>n : Symbol(n, Decl(intersectionTypeMembers.ts, 26, 3)) +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 24, 3)) + diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types new file mode 100644 index 00000000000..a97a54c7a81 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeMembers.ts === +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +var abc: A & B & C; +>abc : A & B & C +>A : A +>B : B +>C : C + +abc.a = "hello"; +>abc.a = "hello" : string +>abc.a : string +>abc : A & B & C +>a : string +>"hello" : string + +abc.b = "hello"; +>abc.b = "hello" : string +>abc.b : string +>abc : A & B & C +>b : string +>"hello" : string + +abc.c = "hello"; +>abc.c = "hello" : string +>abc.c : string +>abc : A & B & C +>c : string +>"hello" : string + +interface X { x: A } +>X : X +>x : A +>A : A + +interface Y { x: B } +>Y : Y +>x : B +>B : B + +interface Z { x: C } +>Z : Z +>x : C +>C : C + +var xyz: X & Y & Z; +>xyz : X & Y & Z +>X : X +>Y : Y +>Z : Z + +xyz.x.a = "hello"; +>xyz.x.a = "hello" : string +>xyz.x.a : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>a : string +>"hello" : string + +xyz.x.b = "hello"; +>xyz.x.b = "hello" : string +>xyz.x.b : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>b : string +>"hello" : string + +xyz.x.c = "hello"; +>xyz.x.c = "hello" : string +>xyz.x.c : string +>xyz.x : A & B & C +>xyz : X & Y & Z +>x : A & B & C +>c : string +>"hello" : string + +type F1 = (x: string) => string; +>F1 : (x: string) => string +>x : string + +type F2 = (x: number) => number; +>F2 : (x: number) => number +>x : number + +var f: F1 & F2; +>f : ((x: string) => string) & ((x: number) => number) +>F1 : (x: string) => string +>F2 : (x: number) => number + +var s = f("hello"); +>s : string +>f("hello") : string +>f : ((x: string) => string) & ((x: number) => number) +>"hello" : string + +var n = f(42); +>n : number +>f(42) : number +>f : ((x: string) => string) & ((x: number) => number) +>42 : number + diff --git a/tests/baselines/reference/intersectionTypeOverloading.js b/tests/baselines/reference/intersectionTypeOverloading.js new file mode 100644 index 00000000000..b7080e449b7 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.js @@ -0,0 +1,26 @@ +//// [intersectionTypeOverloading.ts] +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; + + +//// [intersectionTypeOverloading.js] +// Check that order is preserved in intersection types for purposes of +// overload resolution +var fg; +var gf; +var x = fg("abc"); +var x; +var y = gf("abc"); +var y; diff --git a/tests/baselines/reference/intersectionTypeOverloading.symbols b/tests/baselines/reference/intersectionTypeOverloading.symbols new file mode 100644 index 00000000000..c8503345041 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>s : Symbol(s, Decl(intersectionTypeOverloading.ts, 3, 10)) + +type G = (x: any) => any; +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 4, 10)) + +var fg: F & G; +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) + +var gf: G & F; +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) +>G : Symbol(G, Decl(intersectionTypeOverloading.ts, 3, 31)) +>F : Symbol(F, Decl(intersectionTypeOverloading.ts, 0, 0)) + +var x = fg("abc"); +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) +>fg : Symbol(fg, Decl(intersectionTypeOverloading.ts, 6, 3)) + +var x: string; +>x : Symbol(x, Decl(intersectionTypeOverloading.ts, 9, 3), Decl(intersectionTypeOverloading.ts, 10, 3)) + +var y = gf("abc"); +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) +>gf : Symbol(gf, Decl(intersectionTypeOverloading.ts, 7, 3)) + +var y: any; +>y : Symbol(y, Decl(intersectionTypeOverloading.ts, 12, 3), Decl(intersectionTypeOverloading.ts, 13, 3)) + diff --git a/tests/baselines/reference/intersectionTypeOverloading.types b/tests/baselines/reference/intersectionTypeOverloading.types new file mode 100644 index 00000000000..c478b6a08cb --- /dev/null +++ b/tests/baselines/reference/intersectionTypeOverloading.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts === +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +>F : (s: string) => string +>s : string + +type G = (x: any) => any; +>G : (x: any) => any +>x : any + +var fg: F & G; +>fg : ((s: string) => string) & ((x: any) => any) +>F : (s: string) => string +>G : (x: any) => any + +var gf: G & F; +>gf : ((x: any) => any) & ((s: string) => string) +>G : (x: any) => any +>F : (s: string) => string + +var x = fg("abc"); +>x : string +>fg("abc") : string +>fg : ((s: string) => string) & ((x: any) => any) +>"abc" : string + +var x: string; +>x : string + +var y = gf("abc"); +>y : any +>gf("abc") : any +>gf : ((x: any) => any) & ((s: string) => string) +>"abc" : string + +var y: any; +>y : any + diff --git a/tests/baselines/reference/isArray.types b/tests/baselines/reference/isArray.types index 8865ff73bc0..bc452b12bef 100644 --- a/tests/baselines/reference/isArray.types +++ b/tests/baselines/reference/isArray.types @@ -5,9 +5,9 @@ var maybeArray: number | number[]; if (Array.isArray(maybeArray)) { >Array.isArray(maybeArray) : boolean ->Array.isArray : (arg: any) => boolean +>Array.isArray : (arg: any) => arg is any[] >Array : ArrayConstructor ->isArray : (arg: any) => boolean +>isArray : (arg: any) => arg is any[] >maybeArray : number | number[] maybeArray.length; // OK diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index c6025123179..3920dc1cef4 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 07b1fb52af8..06e38c57af4 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 001cb99b486..e16fe5255e4 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index 7085fd224f4..b8709197829 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 09a6984cb3c..17ac6a1feac 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 4ee65a10825..468866ca324 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 38dacc59cc2..6f0d347d9b4 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1864, 1), Decl(lib.d.ts, 1887, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index aa5ce5783a0..10225e183e6 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 01cfba0f09e..86c46812688 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index a900c56ecab..ae99a4b5255 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index f53e8266baa..c4a2459e262 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index 548e026744a..c2fce062fb0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1668, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index db8da1bac9d..cdc7bb3e2bc 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index bdc200c25ec..e4d1b508bb5 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index c49ea74dc23..bd6760dd0aa 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index e7fbdac2264..d0bc9790752 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index 54ac770c5df..a7e5d7b8919 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 8b24ba5d1b7..67b9e9e500d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index d43a7f9b4fc..0c3c11c84f4 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 9d86858eb8e..03faf4b593e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.js b/tests/baselines/reference/mergeClassInterfaceAndModule.js new file mode 100644 index 00000000000..5b7315031cd --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.js @@ -0,0 +1,19 @@ +//// [mergeClassInterfaceAndModule.ts] + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} + +//// [mergeClassInterfaceAndModule.js] diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.symbols b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols new file mode 100644 index 00000000000..a10227ed461 --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +module C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +module C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +declare class C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +interface C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +interface C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.types b/tests/baselines/reference/mergeClassInterfaceAndModule.types new file mode 100644 index 00000000000..a91691e5bac --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : C1 + +declare class C1 {} +>C1 : C1 + +module C1 {} +>C1 : typeof C1 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +module C2 {} +>C2 : typeof C2 + +declare class C3 {} +>C3 : C3 + +module C3 {} +>C3 : typeof C3 + +interface C3 {} +>C3 : C3 + +module C4 {} +>C4 : typeof C4 + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : C4 + +interface C4 {} +>C4 : C4 + diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt new file mode 100644 index 00000000000..5b23b046db7 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== + + + declare class C1 { } + + interface C1 { } + + interface C2 { } + + declare class C2 { } + + class C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + class C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2518: Only an ambient class can be merged with an interface. + + interface C5 { + x1: number; + } + + declare class C5 { + x2: number; + } + + interface C5 { + x3: number; + } + + interface C5 { + x4: number; + } + + // checks if properties actually were merged + var c5 : C5; + c5.x1; + c5.x2; + c5.x3; + c5.x4; + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ==== + + declare class C6 { } + + interface C7 { } + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ==== + + interface C6 { } + + declare class C7 { } \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js new file mode 100644 index 00000000000..7176255655d --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.js @@ -0,0 +1,117 @@ +//// [tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts] //// + +//// [file1.ts] + + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +//// [file2.ts] + +declare class C6 { } + +interface C7 { } + +//// [file3.ts] + +interface C6 { } + +declare class C7 { } + +//// [file1.js] +var C3 = (function () { + function C3() { + } + return C3; +})(); // error -- cannot merge non-ambient class and interface +var C4 = (function () { + function C4() { + } + return C4; +})(); // error -- cannot merge non-ambient class and interface +// checks if properties actually were merged +var c5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; +//// [file2.js] +//// [file3.js] + + +//// [file1.d.ts] +declare class C1 { +} +interface C1 { +} +interface C2 { +} +declare class C2 { +} +declare class C3 { +} +interface C3 { +} +interface C4 { +} +declare class C4 { +} +interface C5 { + x1: number; +} +declare class C5 { + x2: number; +} +interface C5 { + x3: number; +} +interface C5 { + x4: number; +} +declare var c5: C5; +//// [file2.d.ts] +declare class C6 { +} +interface C7 { +} +//// [file3.d.ts] +interface C6 { +} +declare class C7 { +} diff --git a/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.js b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.js new file mode 100644 index 00000000000..d571a4143ee --- /dev/null +++ b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.js @@ -0,0 +1,25 @@ +//// [modifierOnClassDeclarationMemberInFunction.ts] + +function f() { + class C { + public baz = 1; + static foo() { } + public bar() { } + } +} + +//// [modifierOnClassDeclarationMemberInFunction.js] +function f() { + var C = (function () { + function C() { + this.baz = 1; + } + C.foo = function () { }; + C.prototype.bar = function () { }; + return C; + })(); +} + + +//// [modifierOnClassDeclarationMemberInFunction.d.ts] +declare function f(): void; diff --git a/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.symbols b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.symbols new file mode 100644 index 00000000000..a411bee09cb --- /dev/null +++ b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts === + +function f() { +>f : Symbol(f, Decl(modifierOnClassDeclarationMemberInFunction.ts, 0, 0)) + + class C { +>C : Symbol(C, Decl(modifierOnClassDeclarationMemberInFunction.ts, 1, 14)) + + public baz = 1; +>baz : Symbol(baz, Decl(modifierOnClassDeclarationMemberInFunction.ts, 2, 13)) + + static foo() { } +>foo : Symbol(C.foo, Decl(modifierOnClassDeclarationMemberInFunction.ts, 3, 23)) + + public bar() { } +>bar : Symbol(bar, Decl(modifierOnClassDeclarationMemberInFunction.ts, 4, 24)) + } +} diff --git a/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types new file mode 100644 index 00000000000..dfd482a6bc8 --- /dev/null +++ b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts === + +function f() { +>f : () => void + + class C { +>C : C + + public baz = 1; +>baz : number +>1 : number + + static foo() { } +>foo : () => void + + public bar() { } +>bar : () => void + } +} diff --git a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js new file mode 100644 index 00000000000..e43e8dd8203 --- /dev/null +++ b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js @@ -0,0 +1,25 @@ +//// [modifierOnClassExpressionMemberInFunction.ts] + +function g() { + var x = class C { + public prop1 = 1; + private foo() { } + static prop2 = 43; + } +} + +//// [modifierOnClassExpressionMemberInFunction.js] +function g() { + var x = (function () { + function C() { + this.prop1 = 1; + } + C.prototype.foo = function () { }; + C.prop2 = 43; + return C; + })(); +} + + +//// [modifierOnClassExpressionMemberInFunction.d.ts] +declare function g(): void; diff --git a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.symbols b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.symbols new file mode 100644 index 00000000000..d603d96dcda --- /dev/null +++ b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts === + +function g() { +>g : Symbol(g, Decl(modifierOnClassExpressionMemberInFunction.ts, 0, 0)) + + var x = class C { +>x : Symbol(x, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 7)) +>C : Symbol(C, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 11)) + + public prop1 = 1; +>prop1 : Symbol(C.prop1, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 21)) + + private foo() { } +>foo : Symbol(C.foo, Decl(modifierOnClassExpressionMemberInFunction.ts, 3, 25)) + + static prop2 = 43; +>prop2 : Symbol(C.prop2, Decl(modifierOnClassExpressionMemberInFunction.ts, 4, 25)) + } +} diff --git a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types new file mode 100644 index 00000000000..87a200ee56e --- /dev/null +++ b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts === + +function g() { +>g : () => void + + var x = class C { +>x : typeof C +>class C { public prop1 = 1; private foo() { } static prop2 = 43; } : typeof C +>C : typeof C + + public prop1 = 1; +>prop1 : number +>1 : number + + private foo() { } +>foo : () => void + + static prop2 = 43; +>prop2 : number +>43 : number + } +} diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 5eb7ea2cf80..5c32d464070 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2300: Duplicate identifier 'cli2'. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifier 'cli2'. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifie class cli { } ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2518: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2518: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/noErrorsInCallback.errors.txt b/tests/baselines/reference/noErrorsInCallback.errors.txt index f0bfe00199e..90fdbbd77a5 100644 --- a/tests/baselines/reference/noErrorsInCallback.errors.txt +++ b/tests/baselines/reference/noErrorsInCallback.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. -tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/noErrorsInCallback.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type } var one = new Bar({}); // Error ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. [].forEach(() => { var two = new Bar({}); // No error? ~~ -!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. }); \ No newline at end of file diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 9697dcbc128..648929e974e 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(79,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ==== @@ -129,7 +129,7 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(10); this.p1 = super.c2_p1; ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } /** c3 p1*/ public p1: number; @@ -241,6 +241,6 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(); this.d = super.b; ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 54d674ea0a8..5d97b2d7a01 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 51fdb40efd4..69764d70b45 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index 11b6d8de94f..c42bb3abb83 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index b2ffc2c89d2..ba93afde837 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index e896ebbd2a2..4829677f516 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 1859c954ba4..793b925b382 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index a91a8227ae4..e1b85f2a3b9 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index dee98ed1e77..05b002eb569 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index cffbded17e6..774eb2dcc4b 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index f29ee917ea7..7893100b5a5 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'foo' is private and only accessible within class 'Base'. @@ -14,17 +14,17 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces class Derived extends Base { x = super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. y() { return super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } z: typeof super.foo; // error ~~~~~ !!! error TS1003: Identifier expected. ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. a: this.foo; // error ~~~~ diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index d9e329885aa..27e7df62ab1 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4770, 1), Decl(lib.d.ts, 4855, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4837, 39), Decl(lib.d.ts, 4844, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4775, 22), Decl(lib.d.ts, 4782, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt index f2b19d043c2..897636b6d90 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce this.x; // OK, accessed within a subclass of the declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt index 03671925feb..4b950c70019 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(14,23): error TS2339: Property 'z' does not exist on type 'B'. -tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(18,24): error TS2339: Property 'y' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(19,24): error TS2339: Property 'z' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(22,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAcc var s1 = super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var s2 = super.f(); var s3 = super.y; // error ~ diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt index 1f1bd72617c..b6fa239f291 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts (2 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -25,6 +25,6 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/recursiveIntersectionTypes.errors.txt b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt new file mode 100644 index 00000000000..bac97470e55 --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts(19,1): error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. + Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. + Type '{ next: Entity & any; }' is not assignable to type 'Product'. + Property 'price' is missing in type '{ next: Entity & any; }'. + + +==== tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts (1 errors) ==== + type LinkedList = T & { next: LinkedList }; + + interface Entity { + name: string; + } + + interface Product extends Entity { + price: number; + } + + var entityList: LinkedList; + var s = entityList.name; + var s = entityList.next.name; + var s = entityList.next.next.name; + var s = entityList.next.next.next.name; + + var productList: LinkedList; + entityList = productList; + productList = entityList; // Error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product & { next: Product & any; }'. +!!! error TS2322: Type 'Entity & { next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Type '{ next: Entity & any; }' is not assignable to type 'Product'. +!!! error TS2322: Property 'price' is missing in type '{ next: Entity & any; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveIntersectionTypes.js b/tests/baselines/reference/recursiveIntersectionTypes.js new file mode 100644 index 00000000000..88b7e6f831b --- /dev/null +++ b/tests/baselines/reference/recursiveIntersectionTypes.js @@ -0,0 +1,31 @@ +//// [recursiveIntersectionTypes.ts] +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error + + +//// [recursiveIntersectionTypes.js] +var entityList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; +var productList; +entityList = productList; +productList = entityList; // Error diff --git a/tests/baselines/reference/restParamModifier.errors.txt b/tests/baselines/reference/restParamModifier.errors.txt new file mode 100644 index 00000000000..87c73fcdc71 --- /dev/null +++ b/tests/baselines/reference/restParamModifier.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/restParamModifier.ts(2,17): error TS2370: A rest parameter must be of an array type. +tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: '=' expected. +tests/cases/compiler/restParamModifier.ts(2,27): error TS2304: Cannot find name 'rest'. +tests/cases/compiler/restParamModifier.ts(2,31): error TS1005: ',' expected. +tests/cases/compiler/restParamModifier.ts(2,39): error TS1005: '=' expected. + + +==== tests/cases/compiler/restParamModifier.ts (5 errors) ==== + class C { + constructor(...public rest: string[]) {} + ~~~~~~~~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'rest'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier.js b/tests/baselines/reference/restParamModifier.js new file mode 100644 index 00000000000..9a780321dc9 --- /dev/null +++ b/tests/baselines/reference/restParamModifier.js @@ -0,0 +1,12 @@ +//// [restParamModifier.ts] +class C { + constructor(...public rest: string[]) {} +} + +//// [restParamModifier.js] +var C = (function () { + function C(public, string) { + if (string === void 0) { string = []; } + } + return C; +})(); diff --git a/tests/baselines/reference/restParamModifier2.errors.txt b/tests/baselines/reference/restParamModifier2.errors.txt new file mode 100644 index 00000000000..773592fa9bf --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/restParamModifier2.ts(2,24): error TS1005: ',' expected. + + +==== tests/cases/compiler/restParamModifier2.ts (1 errors) ==== + class C { + constructor(public ...rest: string[]) {} + ~~~ +!!! error TS1005: ',' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier2.js b/tests/baselines/reference/restParamModifier2.js new file mode 100644 index 00000000000..c588c945ce4 --- /dev/null +++ b/tests/baselines/reference/restParamModifier2.js @@ -0,0 +1,15 @@ +//// [restParamModifier2.ts] +class C { + constructor(public ...rest: string[]) {} +} + +//// [restParamModifier2.js] +var C = (function () { + function C(public) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return C; +})(); diff --git a/tests/baselines/reference/superAccess.errors.txt b/tests/baselines/reference/superAccess.errors.txt index 64c921e0e7f..f506bb9f136 100644 --- a/tests/baselines/reference/superAccess.errors.txt +++ b/tests/baselines/reference/superAccess.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superAccess.ts(9,24): error TS2339: Property 'S1' does not exist on type 'MyBase'. -tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superAccess.ts (3 errors) ==== @@ -17,9 +17,9 @@ tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protec !!! error TS2339: Property 'S1' does not exist on type 'MyBase'. var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index eda3e29bb0a..d8b39284f65 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. @@ -25,7 +25,7 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not !!! error TS1034: 'super' must be followed by an argument list or member access. static yy = super; // error for static initializer accessing super ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. diff --git a/tests/baselines/reference/superCallOutsideConstructor.errors.txt b/tests/baselines/reference/superCallOutsideConstructor.errors.txt index 2cdcaad1891..c22c4d33b5d 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.errors.txt +++ b/tests/baselines/reference/superCallOutsideConstructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/superCallOutsideConstructor.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super class D extends C { x = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. constructor() { super(); @@ -19,13 +19,13 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super var y = () => { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } var y2 = function() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } } diff --git a/tests/baselines/reference/superErrors.errors.txt b/tests/baselines/reference/superErrors.errors.txt index fad592b490c..26e0ba3a6c4 100644 --- a/tests/baselines/reference/superErrors.errors.txt +++ b/tests/baselines/reference/superErrors.errors.txt @@ -4,12 +4,12 @@ tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be ref tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access. @@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in an inner function in a constructor function inner2() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } @@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superInLambdas.errors.txt b/tests/baselines/reference/superInLambdas.errors.txt index 7587ed82ef1..a3863d00c02 100644 --- a/tests/baselines/reference/superInLambdas.errors.txt +++ b/tests/baselines/reference/superInLambdas.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superInLambdas.ts(61,34): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument list or member access. @@ -53,13 +53,13 @@ tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be fol // super property in a nested lambda in a constructor var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } sayHello(): void { // super property in a nested lambda in a method var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } diff --git a/tests/baselines/reference/superPropertyAccess.errors.txt b/tests/baselines/reference/superPropertyAccess.errors.txt index 4880bf66f17..41e0a0adac5 100644 --- a/tests/baselines/reference/superPropertyAccess.errors.txt +++ b/tests/baselines/reference/superPropertyAccess.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/superPropertyAccess.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess.ts(24,9): error TS2341: Property 'p1' is private and only accessible within class 'MyBase'. -tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess.ts (8 errors) ==== @@ -36,7 +36,7 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an super.m2.bind(this); // Should error, instance property, not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.p1(); // Should error, private not public instance member function ~~~~~~~~ @@ -44,20 +44,20 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an var l1 = super.d1; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l1 = super.d2; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.m1 = function (a: string) { return ""; }; // Should be allowed, we will not restrict assignment super.value = 0; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var z = super.value; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess1.errors.txt b/tests/baselines/reference/superPropertyAccess1.errors.txt index b256860ec72..aed25fd6a92 100644 --- a/tests/baselines/reference/superPropertyAccess1.errors.txt +++ b/tests/baselines/reference/superPropertyAccess1.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/superPropertyAccess1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess1.ts (5 errors) ==== @@ -22,7 +22,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } constructor() { @@ -30,7 +30,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public get y() { @@ -39,7 +39,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess2.errors.txt b/tests/baselines/reference/superPropertyAccess2.errors.txt index 475705f1506..2512ad91fae 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(13,15): error TS2339: Property 'x' does not exist on type 'typeof C'. tests/cases/compiler/superPropertyAccess2.ts(18,15): error TS2339: Property 'bar' does not exist on type 'C'. -tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' does not exist on type 'typeof C'. @@ -33,7 +33,7 @@ tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' !!! error TS2339: Property 'bar' does not exist on type 'C'. super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public static get y() { diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt index 44332e6e567..4f1faf78a78 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): e tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ==== @@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return super.test(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index f24cfe2b783..9fae9d57c4f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 375bcf2174a..5dba2268d26 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index 90290569e07..a6019a364e4 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index 66f540a8cae..e16ec738489 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index 5927b8a6a29..b2f520351f2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 3c214bd9c25..7e9d06cd332 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index d3a3a313223..177180b5bca 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index d552300b70e..98cb277ad47 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 7f5fc3cf51b..17bda345253 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index fe60e2ecc31..c4b046cc146 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index b044c5264d8..58a661412da 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 797b422c7fc..7879d28b02f 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index deaf1c1bb62..17901fb713a 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index f8b758cbf68..4028da455a6 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 246ca2f0851..07e9b6bae26 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index 4531b13dca1..d4e79a064a9 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 6027f5e797e..2a83145da03 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index f7700e3b777..1b4b23e9511 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index bc23c468a22..89df72d6543 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index a0274f2c762..3ee9ed595c2 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index c6bb74bef31..b52c4087d71 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index 04c76275b55..ad4f0c79523 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.symbols b/tests/baselines/reference/symbolProperty21.symbols index 544813c3056..09997f687d5 100644 --- a/tests/baselines/reference/symbolProperty21.symbols +++ b/tests/baselines/reference/symbolProperty21.symbols @@ -5,15 +5,15 @@ interface I { >U : Symbol(U, Decl(symbolProperty21.ts, 0, 14)) [Symbol.unscopables]: T; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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)) } @@ -34,18 +34,18 @@ foo({ >foo : Symbol(foo, Decl(symbolProperty21.ts, 3, 1)) [Symbol.isConcatSpreadable]: "", ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1230, 24)) +>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, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index e9f6761e121..b62037e32a5 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index d220f80c0f7..da9d07ffeed 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 819b93e6147..46babb69a87 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 7ead7b14b34..69fe473e17c 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index 9f57cd1e2e3..cf6ab1f5edb 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index a6594f5146b..4e17e561bce 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index 1f0fdaf91a7..e3e469764a8 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index d50401a637a..622d1b693e8 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 4c3d2595c13..5aba3b8c104 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1222, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index a759e09588e..7b57003e607 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index ee785ae606d..4beb1f6d9e2 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 825f73ebcd1..32240efd986 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } } diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index e76ad43f43d..05eeace3b86 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1196, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index caca4686bbf..a4e335cc7d7 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 4e0ce420388..249545872b1 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index cedcfe69a9f..78be14d0862 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1278, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 269a8412d95..64452f49c9c 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1284, 24)) +>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)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1272, 18)) +>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)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index 4bf91a6112e..d40e0e72724 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1208, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 1d87ae6a1a4..4b61749b898 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index 4d7c4d6ac4e..baa4613d26b 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 7c796d47398..69d686c3156 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,14 +1,13 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +15,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 4b9cb63d9aa..02ccd7f2413 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,14 +1,13 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +15,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt index 54666f46aba..7503c5f5969 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -1,17 +1,19 @@ -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(22,8): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (6 errors) ==== +==== tests/cases/conformance/jsx/tsxAttributeResolution1.tsx (7 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -40,8 +42,9 @@ tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Typ ; // Error, "32" is not number ~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - // TODO attribute 'var' should be parseable - // ; // Error, no 'var' property + ; // Error, no 'var' property + ~~~ +!!! error TS2339: Property 'var' does not exist on type 'Attribs1'. ; // Error, missing reqd ~~~~~~~~~ @@ -50,4 +53,6 @@ tests/cases/conformance/jsx/tsxAttributeResolution1.tsx(30,8): error TS2322: Typ ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. + // Should be OK + ; \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution1.js b/tests/baselines/reference/tsxAttributeResolution1.js index 011ac8034e2..1e1efb7ea22 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.js +++ b/tests/baselines/reference/tsxAttributeResolution1.js @@ -4,6 +4,7 @@ declare module JSX { interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -24,12 +25,13 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; //// [tsxAttributeResolution1.jsx] @@ -44,7 +46,8 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; diff --git a/tests/baselines/reference/tsxAttributeResolution9.errors.txt b/tests/baselines/reference/tsxAttributeResolution9.errors.txt new file mode 100644 index 00000000000..c25532eaa0a --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution9.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } + } + + interface Props { + foo: string; + } + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + export class MyComponent { + render() { + } + + props: { foo: string; } + } + + ; // ok + ; // should be an error + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution9.js b/tests/baselines/reference/tsxAttributeResolution9.js new file mode 100644 index 00000000000..bfc19a7ba4f --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution9.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/jsx/tsxAttributeResolution9.tsx] //// + +//// [react.d.ts] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } +} + +interface Props { + foo: string; +} + +//// [file.tsx] +export class MyComponent { + render() { + } + + props: { foo: string; } +} + +; // ok +; // should be an error + + +//// [file.jsx] +define(["require", "exports"], function (require, exports) { + var MyComponent = (function () { + function MyComponent() { + } + MyComponent.prototype.render = function () { + }; + return MyComponent; + })(); + exports.MyComponent = MyComponent; + ; // ok + ; // should be an error +}); diff --git a/tests/baselines/reference/tsxAttributeResolution9.symbols b/tests/baselines/reference/tsxAttributeResolution9.symbols new file mode 100644 index 00000000000..081482d5d47 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution9.symbols @@ -0,0 +1,47 @@ +=== 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 new file mode 100644 index 00000000000..1b2c6d42389 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution9.types @@ -0,0 +1,49 @@ +=== 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/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js new file mode 100644 index 00000000000..72612e8ce54 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxElementResolution19.tsx] //// + +//// [react.d.ts] + +declare module "react" { + +} + +//// [file1.tsx] +declare module JSX { + interface Element { } +} +export class MyClass { } + +//// [file2.tsx] + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; + + +//// [file1.js] +define(["require", "exports"], function (require, exports) { + var MyClass = (function () { + function MyClass() { + } + return MyClass; + })(); + exports.MyClass = MyClass; +}); +//// [file2.js] +define(["require", "exports", 'react', './file1'], function (require, exports, React, file1_1) { + React.createElement(file1_1.MyClass, null); +}); diff --git a/tests/baselines/reference/tsxElementResolution19.symbols b/tests/baselines/reference/tsxElementResolution19.symbols new file mode 100644 index 00000000000..48aa4f962b6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(file1.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file1.tsx, 0, 20)) +} +export class MyClass { } +>MyClass : Symbol(MyClass, Decl(file1.tsx, 2, 1)) + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : Symbol(React, Decl(file2.tsx, 2, 6)) + +import {MyClass} from './file1'; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + +; +>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8)) + diff --git a/tests/baselines/reference/tsxElementResolution19.types b/tests/baselines/reference/tsxElementResolution19.types new file mode 100644 index 00000000000..0fa1eefe5f6 --- /dev/null +++ b/tests/baselines/reference/tsxElementResolution19.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +No type information for this code.declare module "react" { +No type information for this code. +No type information for this code.} +No type information for this code. +No type information for this code.=== tests/cases/conformance/jsx/file1.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element +} +export class MyClass { } +>MyClass : MyClass + +=== tests/cases/conformance/jsx/file2.tsx === + +// Should not elide React import +import * as React from 'react'; +>React : typeof React + +import {MyClass} from './file1'; +>MyClass : typeof MyClass + +; +> : any +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index b6c5fd96183..f1799e5bb77 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 60fa5e70b0a..c9e819c82d3 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -12,133 +12,135 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit1.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit1.tsx, 6, 11)) var p; ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var selfClosed1 =
; ->selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 8, 3)) +>selfClosed1 : Symbol(selfClosed1, Decl(tsxReactEmit1.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var selfClosed2 =
; ->selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 9, 3)) +>selfClosed2 : Symbol(selfClosed2, Decl(tsxReactEmit1.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed3 =
; ->selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 10, 3)) +>selfClosed3 : Symbol(selfClosed3, Decl(tsxReactEmit1.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) var selfClosed4 =
; ->selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 11, 3)) +>selfClosed4 : Symbol(selfClosed4, Decl(tsxReactEmit1.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed5 =
; ->selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 12, 3)) +>selfClosed5 : Symbol(selfClosed5, Decl(tsxReactEmit1.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed6 =
; ->selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 13, 3)) +>selfClosed6 : Symbol(selfClosed6, Decl(tsxReactEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) var selfClosed7 =
; ->selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 14, 3)) +>selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) >b : Symbol(unknown) var openClosed1 =
; ->openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 16, 3)) +>openClosed1 : Symbol(openClosed1, Decl(tsxReactEmit1.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed2 =
foo
; ->openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 17, 3)) +>openClosed2 : Symbol(openClosed2, Decl(tsxReactEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed3 =
{p}
; ->openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 18, 3)) +>openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) var openClosed4 =
{p < p}
; ->openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 19, 3)) +>openClosed4 : Symbol(openClosed4, Decl(tsxReactEmit1.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var openClosed5 =
{p > p}
; ->openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 20, 3)) +>openClosed5 : Symbol(openClosed5, Decl(tsxReactEmit1.tsx, 21, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) >b : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) class SomeClass { ->SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>SomeClass : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) f() { ->f : Symbol(f, Decl(tsxReactEmit1.tsx, 22, 17)) +>f : Symbol(f, Decl(tsxReactEmit1.tsx, 23, 17)) var rewrites1 =
{() => this}
; ->rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 24, 5)) +>rewrites1 : Symbol(rewrites1, Decl(tsxReactEmit1.tsx, 25, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites2 =
{[p, ...p, p]}
; ->rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 25, 5)) +>rewrites2 : Symbol(rewrites2, Decl(tsxReactEmit1.tsx, 26, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites3 =
{{p}}
; ->rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 26, 5)) +>rewrites3 : Symbol(rewrites3, Decl(tsxReactEmit1.tsx, 27, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 26, 25)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 27, 25)) var rewrites4 =
this}>
; ->rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 28, 5)) +>rewrites4 : Symbol(rewrites4, Decl(tsxReactEmit1.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 20, 45)) +>this : Symbol(SomeClass, Decl(tsxReactEmit1.tsx, 21, 45)) var rewrites5 =
; ->rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 29, 5)) +>rewrites5 : Symbol(rewrites5, Decl(tsxReactEmit1.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 7, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) var rewrites6 =
; ->rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 30, 5)) +>rewrites6 : Symbol(rewrites6, Decl(tsxReactEmit1.tsx, 31, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >a : Symbol(unknown) ->p : Symbol(p, Decl(tsxReactEmit1.tsx, 30, 27)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 31, 27)) } } var whitespace1 =
; ->whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 34, 3)) +>whitespace1 : Symbol(whitespace1, Decl(tsxReactEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace2 =
{p}
; ->whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 35, 3)) +>whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
->whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 36, 3)) +>whitespace3 : Symbol(whitespace3, Decl(tsxReactEmit1.tsx, 37, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index d23cad4560a..0b6e03c5742 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p; >p : any diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index f4a12946ed9..4b2b4695561 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 9607d9330da..9cf739c960c 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -12,32 +12,34 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmit2.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit2.tsx, 6, 11)) var p1, p2, p3; ->p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 7, 7)) ->p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 7, 11)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) var spreads1 =
{p2}
; ->spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 8, 3)) +>spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; ->spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 9, 3)) +>spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; ->spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 10, 3)) +>spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads4 =
{p2}
; ->spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 11, 3)) +>spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) var spreads5 =
{p2}
; ->spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 12, 3)) +>spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) >y : Symbol(unknown) diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types index 9f8d6e494d0..e28910b62c7 100644 --- a/tests/baselines/reference/tsxReactEmit2.types +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any var p1, p2, p3; >p1 : any diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index d31fec1c550..1a6ba037230 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -1,6 +1,7 @@ //// [tsxReactEmit3.tsx] declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/baselines/reference/tsxReactEmit3.symbols b/tests/baselines/reference/tsxReactEmit3.symbols index 8ef0ccab241..857647400a9 100644 --- a/tests/baselines/reference/tsxReactEmit3.symbols +++ b/tests/baselines/reference/tsxReactEmit3.symbols @@ -4,15 +4,18 @@ declare module JSX { interface Element { } } >JSX : Symbol(JSX, Decl(tsxReactEmit3.tsx, 0, 0)) >Element : Symbol(Element, Decl(tsxReactEmit3.tsx, 1, 20)) +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmit3.tsx, 2, 11)) + declare var Foo, Bar, baz; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 3, 21)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>baz : Symbol(baz, Decl(tsxReactEmit3.tsx, 4, 21)) q s ; ->Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 3, 11)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) ->Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 3, 16)) +>Foo : Symbol(Foo, Decl(tsxReactEmit3.tsx, 4, 11)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) +>Bar : Symbol(Bar, Decl(tsxReactEmit3.tsx, 4, 16)) diff --git a/tests/baselines/reference/tsxReactEmit3.types b/tests/baselines/reference/tsxReactEmit3.types index 9e5d9fece56..8babe724fa1 100644 --- a/tests/baselines/reference/tsxReactEmit3.types +++ b/tests/baselines/reference/tsxReactEmit3.types @@ -4,6 +4,9 @@ declare module JSX { interface Element { } } >JSX : any >Element : Element +declare var React: any; +>React : any + declare var Foo, Bar, baz; >Foo : any >Bar : any diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt index 00b7cb8d019..fca2b028237 100644 --- a/tests/baselines/reference/tsxReactEmit4.errors.txt +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find name 'blah'. +tests/cases/conformance/jsx/tsxReactEmit4.tsx(12,5): error TS2304: Cannot find name 'blah'. ==== tests/cases/conformance/jsx/tsxReactEmit4.tsx (1 errors) ==== @@ -8,6 +8,7 @@ tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find n [s: string]: any; } } + declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index 2254c4dd651..dcbfafcef2f 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index 2f32295c279..a124ce73312 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -5,6 +5,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index afbb6944981..06c8258a2c2 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -12,12 +12,14 @@ declare module JSX { >s : Symbol(s, Decl(tsxReactEmitWhitespace.tsx, 3, 3)) } } +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace.tsx, 6, 11)) // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; ->p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 10, 3)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) // Emit " "
; diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index e0e3639fa9b..603dc4ca6c1 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -12,6 +12,8 @@ declare module JSX { >s : string } } +declare var React: any; +>React : any // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js new file mode 100644 index 00000000000..25ce3743fa2 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js @@ -0,0 +1,22 @@ +//// [typeArgumentInferenceWithClassExpression1.ts] +function foo(x = class { static prop: T }): T { + return undefined; +} + +foo(class { static prop = "hello" }).length; + +//// [typeArgumentInferenceWithClassExpression1.js] +function foo(x) { + if (x === void 0) { x = (function () { + function class_1() { + } + return class_1; + })(); } + return undefined; +} +foo((function () { + function class_2() { + } + class_2.prop = "hello"; + return class_2; +})()).length; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.symbols b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.symbols new file mode 100644 index 00000000000..ceb97a73af8 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts === +function foo(x = class { static prop: T }): T { +>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 0)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13)) +>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 16)) +>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 27)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo(class { static prop = "hello" }).length; +>foo(class { static prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 0)) +>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression1.ts, 4, 11)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types new file mode 100644 index 00000000000..63ee1309383 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts === +function foo(x = class { static prop: T }): T { +>foo : (x?: typeof (Anonymous class)) => T +>T : T +>x : typeof (Anonymous class) +>class { static prop: T } : typeof (Anonymous class) +>prop : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo(class { static prop = "hello" }).length; +>foo(class { static prop = "hello" }).length : number +>foo(class { static prop = "hello" }) : string +>foo : (x?: typeof (Anonymous class)) => T +>class { static prop = "hello" } : typeof (Anonymous class) +>prop : string +>"hello" : string +>length : number + diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt new file mode 100644 index 00000000000..c630944306b --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts(6,5): error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'. + Type '(Anonymous class)' is not assignable to type 'foo<{}>.'. + Property 'prop' is missing in type '(Anonymous class)'. + + +==== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts (1 errors) ==== + function foo(x = class { prop: T }): T { + return undefined; + } + + // Should not infer string because it is a static property + foo(class { static prop = "hello" }).length; + ~~~~~ +!!! error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'. +!!! error TS2345: Type '(Anonymous class)' is not assignable to type 'foo<{}>.'. +!!! error TS2345: Property 'prop' is missing in type '(Anonymous class)'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js new file mode 100644 index 00000000000..c4a7872b016 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js @@ -0,0 +1,24 @@ +//// [typeArgumentInferenceWithClassExpression2.ts] +function foo(x = class { prop: T }): T { + return undefined; +} + +// Should not infer string because it is a static property +foo(class { static prop = "hello" }).length; + +//// [typeArgumentInferenceWithClassExpression2.js] +function foo(x) { + if (x === void 0) { x = (function () { + function class_1() { + } + return class_1; + })(); } + return undefined; +} +// Should not infer string because it is a static property +foo((function () { + function class_2() { + } + class_2.prop = "hello"; + return class_2; +})()).length; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.js b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.js new file mode 100644 index 00000000000..f3a3470e1c3 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.js @@ -0,0 +1,22 @@ +//// [typeArgumentInferenceWithClassExpression3.ts] +function foo(x = class { prop: T }): T { + return undefined; +} + +foo(class { prop = "hello" }).length; + +//// [typeArgumentInferenceWithClassExpression3.js] +function foo(x) { + if (x === void 0) { x = (function () { + function class_1() { + } + return class_1; + })(); } + return undefined; +} +foo((function () { + function class_2() { + this.prop = "hello"; + } + return class_2; +})()).length; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.symbols b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.symbols new file mode 100644 index 00000000000..aedb0230fd6 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts === +function foo(x = class { prop: T }): T { +>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 0)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13)) +>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 16)) +>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 27)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13)) +>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13)) + + return undefined; +>undefined : Symbol(undefined) +} + +foo(class { prop = "hello" }).length; +>foo(class { prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) +>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 0)) +>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression3.ts, 4, 11)) +>length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types new file mode 100644 index 00000000000..9a2bddd9296 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts === +function foo(x = class { prop: T }): T { +>foo : (x?: typeof (Anonymous class)) => T +>T : T +>x : typeof (Anonymous class) +>class { prop: T } : typeof (Anonymous class) +>prop : T +>T : T +>T : T + + return undefined; +>undefined : undefined +} + +foo(class { prop = "hello" }).length; +>foo(class { prop = "hello" }).length : number +>foo(class { prop = "hello" }) : string +>foo : (x?: typeof (Anonymous class)) => T +>class { prop = "hello" } : typeof (Anonymous class) +>prop : string +>"hello" : string +>length : number + diff --git a/tests/baselines/reference/typeGuardFunction.types b/tests/baselines/reference/typeGuardFunction.types index cf673f965f9..6cc278f122f 100644 --- a/tests/baselines/reference/typeGuardFunction.types +++ b/tests/baselines/reference/typeGuardFunction.types @@ -23,19 +23,19 @@ class C extends A { } declare function isA(p1: any): p1 is A; ->isA : (p1: any) => boolean +>isA : (p1: any) => p1 is A >p1 : any >p1 : any >A : A declare function isB(p1: any): p1 is B; ->isB : (p1: any) => boolean +>isB : (p1: any) => p1 is B >p1 : any >p1 : any >B : B declare function isC(p1: any): p1 is C; ->isC : (p1: any) => boolean +>isC : (p1: any) => p1 is C >p1 : any >p1 : any >C : C @@ -55,7 +55,7 @@ var b: B; // Basic if (isC(a)) { >isC(a) : boolean ->isC : (p1: any) => boolean +>isC : (p1: any) => p1 is C >a : A a.propC; @@ -71,7 +71,7 @@ var subType: C; if(isA(subType)) { >isA(subType) : boolean ->isA : (p1: any) => boolean +>isA : (p1: any) => p1 is A >subType : C subType.propC; @@ -88,7 +88,7 @@ var union: A | B; if(isA(union)) { >isA(union) : boolean ->isA : (p1: any) => boolean +>isA : (p1: any) => p1 is A >union : A | B union.propA; @@ -111,7 +111,7 @@ interface I1 { // The parameter index and argument index for the type guard target is matching. // The type predicate type is assignable to the parameter type. declare function isC_multipleParams(p1, p2): p1 is C; ->isC_multipleParams : (p1: any, p2: any) => boolean +>isC_multipleParams : (p1: any, p2: any) => p1 is C >p1 : any >p2 : any >p1 : any @@ -119,7 +119,7 @@ declare function isC_multipleParams(p1, p2): p1 is C; if (isC_multipleParams(a, 0)) { >isC_multipleParams(a, 0) : boolean ->isC_multipleParams : (p1: any, p2: any) => boolean +>isC_multipleParams : (p1: any, p2: any) => p1 is C >a : A >0 : number @@ -131,10 +131,10 @@ if (isC_multipleParams(a, 0)) { // Methods var obj: { ->obj : { func1(p1: A): boolean; } +>obj : { func1(p1: A): p1 is C; } func1(p1: A): p1 is C; ->func1 : (p1: A) => boolean +>func1 : (p1: A) => p1 is C >p1 : A >A : A >p1 : any @@ -144,7 +144,7 @@ class D { >D : D method1(p1: A): p1 is C { ->method1 : (p1: A) => boolean +>method1 : (p1: A) => p1 is C >p1 : A >A : A >p1 : any @@ -157,8 +157,8 @@ class D { // Arrow function let f1 = (p1: A): p1 is C => false; ->f1 : (p1: A) => boolean ->(p1: A): p1 is C => false : (p1: A) => boolean +>f1 : (p1: A) => p1 is C +>(p1: A): p1 is C => false : (p1: A) => p1 is C >p1 : A >A : A >p1 : any @@ -167,8 +167,8 @@ let f1 = (p1: A): p1 is C => false; // Function type declare function f2(p1: (p1: A) => p1 is C); ->f2 : (p1: (p1: A) => boolean) => any ->p1 : (p1: A) => boolean +>f2 : (p1: (p1: A) => p1 is C) => any +>p1 : (p1: A) => p1 is C >p1 : A >A : A >p1 : any @@ -177,8 +177,8 @@ declare function f2(p1: (p1: A) => p1 is C); // Function expressions f2(function(p1: A): p1 is C { >f2(function(p1: A): p1 is C { return true;}) : any ->f2 : (p1: (p1: A) => boolean) => any ->function(p1: A): p1 is C { return true;} : (p1: A) => boolean +>f2 : (p1: (p1: A) => p1 is C) => any +>function(p1: A): p1 is C { return true;} : (p1: A) => p1 is C >p1 : A >A : A >p1 : any @@ -198,21 +198,21 @@ acceptingBoolean(isA(a)); >acceptingBoolean(isA(a)) : any >acceptingBoolean : (a: boolean) => any >isA(a) : boolean ->isA : (p1: any) => boolean +>isA : (p1: any) => p1 is A >a : A // Type predicates with different parameter name. declare function acceptingTypeGuardFunction(p1: (item) => item is A); ->acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any ->p1 : (item: any) => boolean +>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any +>p1 : (item: any) => item is A >item : any >item : any >A : A acceptingTypeGuardFunction(isA); >acceptingTypeGuardFunction(isA) : any ->acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any ->isA : (p1: any) => boolean +>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any +>isA : (p1: any) => p1 is A // Binary expressions let union2: C | B; @@ -225,7 +225,7 @@ let union3: boolean | B = isA(union2) || union2; >B : B >isA(union2) || union2 : boolean | B >isA(union2) : boolean ->isA : (p1: any) => boolean +>isA : (p1: any) => p1 is A >union2 : B | C >union2 : B diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 499a51035f2..b178b02c6b4 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -12,15 +12,15 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'. Type predicate 'p1 is C' is not assignable to 'p1 is B'. Type 'C' is not assignable to type 'B'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'. Signature '(p1: any, p2: any): boolean' must have a type predicate. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. Type predicate 'p2 is A' is not assignable to 'p1 is A'. Parameter 'p2' is not in the same position as parameter 'p1'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. @@ -141,7 +141,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 declare function acceptingDifferentSignatureTypeGuardFunction(p1: (p1) => p1 is B); acceptingDifferentSignatureTypeGuardFunction(isC); ~~~ -!!! error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'. +!!! error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'. !!! error TS2345: Type predicate 'p1 is C' is not assignable to 'p1 is B'. !!! error TS2345: Type 'C' is not assignable to type 'B'. @@ -149,7 +149,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 var assign1: (p1, p2) => p1 is A; assign1 = function(p1, p2): boolean { ~~~~~~~ -!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'. !!! error TS2322: Signature '(p1: any, p2: any): boolean' must have a type predicate. return true; }; @@ -158,7 +158,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 var assign2: (p1, p2) => p1 is A; assign2 = function(p1, p2): p2 is A { ~~~~~~~ -!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +!!! error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. !!! error TS2322: Type predicate 'p2 is A' is not assignable to 'p1 is A'. !!! error TS2322: Parameter 'p2' is not in the same position as parameter 'p1'. return true; @@ -168,7 +168,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 var assign3: (p1, p2) => p1 is A; assign3 = function(p1, p2, p3): p1 is A { ~~~~~~~ -!!! error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'. +!!! error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. return true; }; diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.types b/tests/baselines/reference/typeGuardFunctionGenerics.types index 77162e55a40..c4655e71f0c 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.types +++ b/tests/baselines/reference/typeGuardFunctionGenerics.types @@ -23,13 +23,13 @@ class C extends A { } declare function isB(p1): p1 is B; ->isB : (p1: any) => boolean +>isB : (p1: any) => p1 is B >p1 : any >p1 : any >B : B declare function isC(p1): p1 is C; ->isC : (p1: any) => boolean +>isC : (p1: any) => p1 is C >p1 : any >p1 : any >C : C @@ -48,7 +48,7 @@ declare function funA(p1: (p1) => T): T; >T : T declare function funB(p1: (p1) => T, p2: any): p2 is T; ->funB : (p1: (p1: any) => T, p2: any) => boolean +>funB : (p1: (p1: any) => T, p2: any) => p2 is T >T : T >p1 : (p1: any) => T >p1 : any @@ -58,18 +58,18 @@ declare function funB(p1: (p1) => T, p2: any): p2 is T; >T : T declare function funC(p1: (p1) => p1 is T): T; ->funC : (p1: (p1: any) => boolean) => T +>funC : (p1: (p1: any) => p1 is T) => T >T : T ->p1 : (p1: any) => boolean +>p1 : (p1: any) => p1 is T >p1 : any >p1 : any >T : T >T : T declare function funD(p1: (p1) => p1 is T, p2: any): p2 is T; ->funD : (p1: (p1: any) => boolean, p2: any) => boolean +>funD : (p1: (p1: any) => p1 is T, p2: any) => p2 is T >T : T ->p1 : (p1: any) => boolean +>p1 : (p1: any) => p1 is T >p1 : any >p1 : any >T : T @@ -78,10 +78,10 @@ declare function funD(p1: (p1) => p1 is T, p2: any): p2 is T; >T : T declare function funE(p1: (p1) => p1 is T, p2: U): T; ->funE : (p1: (p1: any) => boolean, p2: U) => T +>funE : (p1: (p1: any) => p1 is T, p2: U) => T >T : T >U : U ->p1 : (p1: any) => boolean +>p1 : (p1: any) => p1 is T >p1 : any >p1 : any >T : T @@ -97,11 +97,11 @@ let test1: boolean = funA(isB); >test1 : boolean >funA(isB) : boolean >funA : (p1: (p1: any) => T) => T ->isB : (p1: any) => boolean +>isB : (p1: any) => p1 is B if (funB(retC, a)) { >funB(retC, a) : boolean ->funB : (p1: (p1: any) => T, p2: any) => boolean +>funB : (p1: (p1: any) => T, p2: any) => p2 is T >retC : (x: any) => C >a : A @@ -114,13 +114,13 @@ let test2: B = funC(isB); >test2 : B >B : B >funC(isB) : B ->funC : (p1: (p1: any) => boolean) => T ->isB : (p1: any) => boolean +>funC : (p1: (p1: any) => p1 is T) => T +>isB : (p1: any) => p1 is B if (funD(isC, a)) { >funD(isC, a) : boolean ->funD : (p1: (p1: any) => boolean, p2: any) => boolean ->isC : (p1: any) => boolean +>funD : (p1: (p1: any) => p1 is T, p2: any) => p2 is T +>isC : (p1: any) => p1 is C >a : A a.propC; @@ -132,7 +132,7 @@ let test3: B = funE(isB, 1); >test3 : B >B : B >funE(isB, 1) : B ->funE : (p1: (p1: any) => boolean, p2: U) => T ->isB : (p1: any) => boolean +>funE : (p1: (p1: any) => p1 is T, p2: U) => T +>isB : (p1: any) => p1 is B >1 : number diff --git a/tests/baselines/reference/typeGuardOfFormIsType.types b/tests/baselines/reference/typeGuardOfFormIsType.types index b14e5e22910..e2059be7b63 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.types +++ b/tests/baselines/reference/typeGuardOfFormIsType.types @@ -29,7 +29,7 @@ var strOrNum: string | number; >strOrNum : string | number function isC1(x: any): x is C1 { ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >x : any >x : any >C1 : C1 @@ -39,7 +39,7 @@ function isC1(x: any): x is C1 { } function isC2(x: any): x is C2 { ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >x : any >x : any >C2 : C2 @@ -49,7 +49,7 @@ function isC2(x: any): x is C2 { } function isD1(x: any): x is D1 { ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >x : any >x : any >D1 : D1 @@ -68,7 +68,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1 >str : string >isC1(c1Orc2) && c1Orc2.p1 : string >isC1(c1Orc2) : boolean ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string >c1Orc2 : C1 @@ -79,7 +79,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2 >num : number >isC2(c1Orc2) && c1Orc2.p2 : number >isC2(c1Orc2) : boolean ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >c1Orc2 : C1 | C2 >c1Orc2.p2 : number >c1Orc2 : C2 @@ -90,7 +90,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1 >str : string >isD1(c1Orc2) && c1Orc2.p1 : string >isD1(c1Orc2) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string >c1Orc2 : D1 @@ -101,7 +101,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1 >num : number >isD1(c1Orc2) && c1Orc2.p3 : number >isD1(c1Orc2) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p3 : number >c1Orc2 : D1 @@ -117,7 +117,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2 >num : number >isC2(c2Ord1) && c2Ord1.p2 : number >isC2(c2Ord1) : boolean ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >c2Ord1 : C2 | D1 >c2Ord1.p2 : number >c2Ord1 : C2 @@ -128,7 +128,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1 >num : number >isD1(c2Ord1) && c2Ord1.p3 : number >isD1(c2Ord1) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p3 : number >c2Ord1 : D1 @@ -139,7 +139,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1 >str : string >isD1(c2Ord1) && c2Ord1.p1 : string >isD1(c2Ord1) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p1 : string >c2Ord1 : D1 @@ -151,7 +151,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 >D1 : D1 >isC1(c2Ord1) && c2Ord1 : D1 >isC1(c2Ord1) : boolean ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >c2Ord1 : C2 | D1 >c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types index 3a659d71163..ea169e95413 100644 --- a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types +++ b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types @@ -48,7 +48,7 @@ var strOrNum: string | number; function isC1(x: any): x is C1 { ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >x : any >x : any >C1 : C1 @@ -58,7 +58,7 @@ function isC1(x: any): x is C1 { } function isC2(x: any): x is C2 { ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >x : any >x : any >C2 : C2 @@ -68,7 +68,7 @@ function isC2(x: any): x is C2 { } function isD1(x: any): x is D1 { ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >x : any >x : any >D1 : D1 @@ -99,7 +99,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1 >str : string >isC1(c1Orc2) && c1Orc2.p1 : string >isC1(c1Orc2) : boolean ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string >c1Orc2 : C1 @@ -110,7 +110,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2 >num : number >isC2(c1Orc2) && c1Orc2.p2 : number >isC2(c1Orc2) : boolean ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >c1Orc2 : C1 | C2 >c1Orc2.p2 : number >c1Orc2 : C2 @@ -121,7 +121,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1 >str : string >isD1(c1Orc2) && c1Orc2.p1 : string >isD1(c1Orc2) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string >c1Orc2 : D1 @@ -132,7 +132,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1 >num : number >isD1(c1Orc2) && c1Orc2.p3 : number >isD1(c1Orc2) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p3 : number >c1Orc2 : D1 @@ -148,7 +148,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2 >num : number >isC2(c2Ord1) && c2Ord1.p2 : number >isC2(c2Ord1) : boolean ->isC2 : (x: any) => boolean +>isC2 : (x: any) => x is C2 >c2Ord1 : C2 | D1 >c2Ord1.p2 : number >c2Ord1 : C2 @@ -159,7 +159,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1 >num : number >isD1(c2Ord1) && c2Ord1.p3 : number >isD1(c2Ord1) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p3 : number >c2Ord1 : D1 @@ -170,7 +170,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1 >str : string >isD1(c2Ord1) && c2Ord1.p1 : string >isD1(c2Ord1) : boolean ->isD1 : (x: any) => boolean +>isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p1 : string >c2Ord1 : D1 @@ -182,7 +182,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 >D1 : D1 >isC1(c2Ord1) && c2Ord1 : D1 >isC1(c2Ord1) : boolean ->isC1 : (x: any) => boolean +>isC1 : (x: any) => x is C1 >c2Ord1 : C2 | D1 >c2Ord1 : D1 diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index 39b67e6428c..97d900b5d5e 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index 44d47692a82..21866b3df92 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types index 64876952852..22d294f9d2e 100644 --- a/tests/baselines/reference/typeParameterFixingWithConstraints.types +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -31,17 +31,17 @@ var foo: IFoo; >IFoo : IFoo foo.foo({ bar: null }, bar => null, bar => null); ->foo.foo({ bar: null }, bar => null, bar => null) : IBar +>foo.foo({ bar: null }, bar => null, bar => null) : { [x: string]: any; bar: any; } >foo.foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >foo : IFoo >foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >{ bar: null } : { [x: string]: null; bar: null; } >bar : null >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null ->bar => null : (bar: IBar) => any ->bar : IBar +>bar => null : (bar: { [x: string]: any; bar: any; }) => any +>bar : { [x: string]: any; bar: any; } >null : null diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index a6b8cb52a86..6b9842f6c81 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2382, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2382, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2672, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2672, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3252, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3252, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3542, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3542, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3832, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3832, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4122, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4122, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4412, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4412, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4702, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4702, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2962, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2962, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1434, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2108, 42), Decl(lib.d.ts, 2398, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2388, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2398, 44), Decl(lib.d.ts, 2688, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2678, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2978, 60), Decl(lib.d.ts, 3268, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3258, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3268, 46), Decl(lib.d.ts, 3558, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3548, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3558, 48), Decl(lib.d.ts, 3848, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3838, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3848, 46), Decl(lib.d.ts, 4138, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4128, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4138, 48), Decl(lib.d.ts, 4428, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4418, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4428, 50), Decl(lib.d.ts, 4718, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4708, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2688, 46), Decl(lib.d.ts, 2978, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2968, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 47e8e6ff4f2..60602351b46 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -16,4 +16,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/cases/compiler/abstractIdentifierNameStrict.ts b/tests/cases/compiler/abstractIdentifierNameStrict.ts new file mode 100644 index 00000000000..c75fbf43043 --- /dev/null +++ b/tests/cases/compiler/abstractIdentifierNameStrict.ts @@ -0,0 +1,6 @@ +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} \ No newline at end of file diff --git a/tests/cases/compiler/abstractInterfaceIdentifierName.ts b/tests/cases/compiler/abstractInterfaceIdentifierName.ts new file mode 100644 index 00000000000..c7bdc100ccf --- /dev/null +++ b/tests/cases/compiler/abstractInterfaceIdentifierName.ts @@ -0,0 +1,4 @@ + +interface abstract { + abstract(): void; +} diff --git a/tests/cases/compiler/class1.ts b/tests/cases/compiler/class1.ts deleted file mode 100644 index c7b2115b88b..00000000000 --- a/tests/cases/compiler/class1.ts +++ /dev/null @@ -1,2 +0,0 @@ -interface foo{ } // error -class foo{ } // error \ No newline at end of file diff --git a/tests/cases/compiler/classAndInterface1.ts b/tests/cases/compiler/classAndInterface1.ts deleted file mode 100644 index 79b02915857..00000000000 --- a/tests/cases/compiler/classAndInterface1.ts +++ /dev/null @@ -1,2 +0,0 @@ - class cli { } // error -interface cli { } // error \ No newline at end of file diff --git a/tests/cases/compiler/declFileFunctions.ts b/tests/cases/compiler/declFileFunctions.ts index e7ce3d07f82..7b9c55e9214 100644 --- a/tests/cases/compiler/declFileFunctions.ts +++ b/tests/cases/compiler/declFileFunctions.ts @@ -28,6 +28,19 @@ export function fooWithSingleOverload(a: any) { return a; } +export function fooWithTypePredicate(a: any): a is number { + return true; +} +export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number { + return true; +} +export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { + return true; +} +export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number { + return true; +} + /** This comment should appear for nonExportedFoo*/ function nonExportedFoo() { } diff --git a/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts new file mode 100644 index 00000000000..94e5cd94ab1 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts @@ -0,0 +1,33 @@ +// @declaration: true + +// @Filename: file1.ts +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +// @Filename: file2.ts +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType1.ts b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts new file mode 100644 index 00000000000..98920cf693f --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType1.ts @@ -0,0 +1,5 @@ +function foo number>(x: T): T { + return undefined; +} + +foo(x => x.length); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType2.ts b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts new file mode 100644 index 00000000000..8290b14927d --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType2.ts @@ -0,0 +1,5 @@ +function foo(x: T): T { + return undefined; +} + +foo({ m(x) { return x.length } }); \ No newline at end of file diff --git a/tests/cases/compiler/inferentialTypingUsingApparentType3.ts b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts new file mode 100644 index 00000000000..d1734b0d100 --- /dev/null +++ b/tests/cases/compiler/inferentialTypingUsingApparentType3.ts @@ -0,0 +1,26 @@ +interface Field { + clean(input: T): T +} + +class CharField implements Field { + clean(input: string) { + return "Yup"; + } +} + +class NumberField implements Field { + clean(input: number) { + return 123; + } +} + +class ObjectField }> { + constructor(public fields: T) { } +} + +var person = new ObjectField({ + id: new NumberField(), + name: new CharField() +}); + +person.fields.id; \ No newline at end of file diff --git a/tests/cases/compiler/restParamModifier.ts b/tests/cases/compiler/restParamModifier.ts new file mode 100644 index 00000000000..220b7d36d5e --- /dev/null +++ b/tests/cases/compiler/restParamModifier.ts @@ -0,0 +1,3 @@ +class C { + constructor(...public rest: string[]) {} +} \ No newline at end of file diff --git a/tests/cases/compiler/restParamModifier2.ts b/tests/cases/compiler/restParamModifier2.ts new file mode 100644 index 00000000000..e007bc56d7c --- /dev/null +++ b/tests/cases/compiler/restParamModifier2.ts @@ -0,0 +1,3 @@ +class C { + constructor(public ...rest: string[]) {} +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts new file mode 100644 index 00000000000..bb9f8a54e44 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async foo(): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts new file mode 100644 index 00000000000..45e686fd280 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction1_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (): Promise => { +}; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts new file mode 100644 index 00000000000..8d792fdff9c --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction2_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var f = (await) => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts new file mode 100644 index 00000000000..9ca200f8d76 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts new file mode 100644 index 00000000000..4946592c45b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction4_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var await = () => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts new file mode 100644 index 00000000000..53052368b31 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts new file mode 100644 index 00000000000..69768429ecf --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (a = await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts new file mode 100644 index 00000000000..a034381ba57 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts new file mode 100644 index 00000000000..397e06f703d --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true + +var foo = async (): Promise => { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts new file mode 100644 index 00000000000..3f961c9d595 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var foo = async (a = await => await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts new file mode 100644 index 00000000000..f00d0d16545 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es6.ts @@ -0,0 +1,9 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts new file mode 100644 index 00000000000..a90f08cb9f7 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunctionCapturesThis_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts new file mode 100644 index 00000000000..52694f24118 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts @@ -0,0 +1,42 @@ +// @target: ES6 +// @isolatedModules: true +// @experimentalAsyncFunctions: true +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncAwait_es6.ts b/tests/cases/conformance/async/es6/asyncAwait_es6.ts new file mode 100644 index 00000000000..eee2e73d023 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncAwait_es6.ts @@ -0,0 +1,41 @@ +// @target: ES6 +// @experimentalAsyncFunctions: true +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncClass_es6.ts b/tests/cases/conformance/async/es6/asyncClass_es6.ts new file mode 100644 index 00000000000..c4a444ca909 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncClass_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async class C { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncConstructor_es6.ts b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts new file mode 100644 index 00000000000..998156f19f4 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncConstructor_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async constructor() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncDeclare_es6.ts b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts new file mode 100644 index 00000000000..d83c25a421a --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncDeclare_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncEnum_es6.ts b/tests/cases/conformance/async/es6/asyncEnum_es6.ts new file mode 100644 index 00000000000..d9569bef9d1 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncEnum_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async enum E { + Value +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncGetter_es6.ts b/tests/cases/conformance/async/es6/asyncGetter_es6.ts new file mode 100644 index 00000000000..fe5751ece0b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncGetter_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async get foo() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncInterface_es6.ts b/tests/cases/conformance/async/es6/asyncInterface_es6.ts new file mode 100644 index 00000000000..c7bb460ea2b --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncInterface_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async interface I { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncModule_es6.ts b/tests/cases/conformance/async/es6/asyncModule_es6.ts new file mode 100644 index 00000000000..cf660d25d1f --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncModule_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async module M { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncSetter_es6.ts b/tests/cases/conformance/async/es6/asyncSetter_es6.ts new file mode 100644 index 00000000000..2ca1c805a45 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncSetter_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +class C { + async set foo(value) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts new file mode 100644 index 00000000000..df0d0e459d4 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression1_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p || a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts new file mode 100644 index 00000000000..7678c4b17ab --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression2_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p && a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts new file mode 100644 index 00000000000..0b441f063dd --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression3_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: number; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p + a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts new file mode 100644 index 00000000000..a0bdf58710f --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression4_es6.ts @@ -0,0 +1,10 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var b = await p, a; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts new file mode 100644 index 00000000000..3276d24ee4b --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitBinaryExpression/awaitBinaryExpression5_es6.ts @@ -0,0 +1,11 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "before"; + var o: { a: boolean; }; + o.a = await p; + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts new file mode 100644 index 00000000000..02de646112c --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression1_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts new file mode 100644 index 00000000000..5d2e4046349 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression2_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts new file mode 100644 index 00000000000..702e1f4cbcc --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression3_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts new file mode 100644 index 00000000000..aeeb192b4ba --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression4_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await pfn)(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts new file mode 100644 index 00000000000..82bb1f88ad2 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression5_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts new file mode 100644 index 00000000000..d5778df71ba --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression6_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(await p, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts new file mode 100644 index 00000000000..db01f34c825 --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression7_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = o.fn(a, await p, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts new file mode 100644 index 00000000000..b0b10a02a6f --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitCallExpression/awaitCallExpression8_es6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +async function func(): Promise { + "before"; + var b = (await po).fn(a, a, a); + "after"; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/awaitUnion_es6.ts b/tests/cases/conformance/async/es6/awaitUnion_es6.ts new file mode 100644 index 00000000000..59c5285556c --- /dev/null +++ b/tests/cases/conformance/async/es6/awaitUnion_es6.ts @@ -0,0 +1,15 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts new file mode 100644 index 00000000000..d543e424a38 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(a = await => await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts new file mode 100644 index 00000000000..23e40a0e5ba --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function await(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts new file mode 100644 index 00000000000..a457d27073f --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts new file mode 100644 index 00000000000..83b6a99579c --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts new file mode 100644 index 00000000000..b837e6618d1 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts new file mode 100644 index 00000000000..3a792140011 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts new file mode 100644 index 00000000000..e75ef1d36a3 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration2_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts new file mode 100644 index 00000000000..9ca200f8d76 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts new file mode 100644 index 00000000000..ac4447a0e4d --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration4_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +function await() { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts new file mode 100644 index 00000000000..60a0a8f4b74 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts new file mode 100644 index 00000000000..a3ab64b9d29 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(a = await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts new file mode 100644 index 00000000000..cde12c7dbe3 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts @@ -0,0 +1,8 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts new file mode 100644 index 00000000000..52b6dba2792 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts new file mode 100644 index 00000000000..662fa017606 --- /dev/null +++ b/tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @noEmitHelpers: true +// @experimentalAsyncFunctions: true +async function foo(): Promise { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts new file mode 100644 index 00000000000..4c251a03c36 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts @@ -0,0 +1,5 @@ +class abstract { + foo() { return 1; } +} + +new abstract; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts new file mode 100644 index 00000000000..f53b1a3a937 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract constructor() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts new file mode 100644 index 00000000000..747b8dafe6e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts @@ -0,0 +1,10 @@ +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts new file mode 100644 index 00000000000..14dfd1d86d8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts @@ -0,0 +1,25 @@ +declare abstract class A { + abstract constructor() {} +} + +declare abstract class AA { + abstract foo(); +} + +declare abstract class BB extends AA {} + +declare class CC extends AA {} + +declare class DD extends BB {} + +declare abstract class EE extends BB {} + +declare class FF extends CC {} + +declare abstract class GG extends CC {} + +declare abstract class AAA {} + +declare abstract class BBB extends AAA {} + +declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts new file mode 100644 index 00000000000..f69ea30d0d6 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts @@ -0,0 +1,25 @@ +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts new file mode 100644 index 00000000000..165a3d7a2e6 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts @@ -0,0 +1,9 @@ +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts new file mode 100644 index 00000000000..f31dd41436e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts @@ -0,0 +1,7 @@ +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts new file mode 100644 index 00000000000..ced15607f84 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts @@ -0,0 +1,21 @@ +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts new file mode 100644 index 00000000000..4daf27b53e4 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -0,0 +1,19 @@ + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new A(1); // should report 1 error +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts new file mode 100644 index 00000000000..3b68b898b94 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -0,0 +1,51 @@ +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts new file mode 100644 index 00000000000..2a6fd46a08d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts @@ -0,0 +1,4 @@ +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts new file mode 100644 index 00000000000..6e5686feb25 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -0,0 +1,40 @@ +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts new file mode 100644 index 00000000000..432613ca04b --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts new file mode 100644 index 00000000000..d3c2546ac90 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts @@ -0,0 +1,15 @@ +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts new file mode 100644 index 00000000000..374a3c089ef --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts @@ -0,0 +1,12 @@ +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts new file mode 100644 index 00000000000..c30a03f8217 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts @@ -0,0 +1,24 @@ +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts new file mode 100644 index 00000000000..e6dc355adb9 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts @@ -0,0 +1,13 @@ +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts new file mode 100644 index 00000000000..e93a670b55f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts @@ -0,0 +1,26 @@ + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts new file mode 100644 index 00000000000..8561fa2ce15 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts @@ -0,0 +1,17 @@ +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts new file mode 100644 index 00000000000..e333811c67f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts @@ -0,0 +1,27 @@ +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts new file mode 100644 index 00000000000..17b89868943 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts @@ -0,0 +1 @@ +abstract interface I {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts new file mode 100644 index 00000000000..1ef7724f81d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts @@ -0,0 +1,25 @@ + +interface C { } + +declare class C { } + +interface C { } + +interface C { } + +declare module M { + + interface C1 { } + + class C1 { } + + interface C1 { } + + interface C1 { } + + export class C2 { } +} + +declare module M { + export interface C2 { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts new file mode 100644 index 00000000000..d11d67c3fea --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts @@ -0,0 +1,23 @@ +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts new file mode 100644 index 00000000000..d5ac1b005bf --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts @@ -0,0 +1,23 @@ +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts new file mode 100644 index 00000000000..7445104e228 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -0,0 +1,20 @@ + +// @Filename: file1.ts + +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +// @Filename: file2.ts + +declare class C3 { } + +// @Filename: file3.ts + +declare class C3 { } \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts new file mode 100644 index 00000000000..4dc733d28c0 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts @@ -0,0 +1,16 @@ + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts new file mode 100644 index 00000000000..29400c63808 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -0,0 +1,54 @@ +// @declaration: true + +// @Filename: file1.ts + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +// @Filename: file2.ts + +declare class C6 { } + +interface C7 { } + +// @Filename: file3.ts + +interface C6 { } + +declare class C7 { } \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts b/tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts new file mode 100644 index 00000000000..f0d7c355e3b --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts @@ -0,0 +1,9 @@ +// @declaration: true + +function f() { + class C { + public baz = 1; + static foo() { } + public bar() { } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts b/tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts new file mode 100644 index 00000000000..100c04a1d31 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts @@ -0,0 +1,10 @@ +// @declaration: true +// @declaration: true + +function g() { + var x = class C { + public prop1 = 1; + private foo() { } + static prop2 = 43; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts new file mode 100644 index 00000000000..21ca07ea2a2 --- /dev/null +++ b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts @@ -0,0 +1,5 @@ +function foo(x = class { static prop: T }): T { + return undefined; +} + +foo(class { static prop = "hello" }).length; \ No newline at end of file diff --git a/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts new file mode 100644 index 00000000000..d7a901ae951 --- /dev/null +++ b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts @@ -0,0 +1,6 @@ +function foo(x = class { prop: T }): T { + return undefined; +} + +// Should not infer string because it is a static property +foo(class { static prop = "hello" }).length; \ No newline at end of file diff --git a/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts new file mode 100644 index 00000000000..d29b7007664 --- /dev/null +++ b/tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts @@ -0,0 +1,5 @@ +function foo(x = class { prop: T }): T { + return undefined; +} + +foo(class { prop = "hello" }).length; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx deleted file mode 100644 index fb54f9d7c82..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution1.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// OK -; // OK -; // OK -; // OK -; // OK -; // OK -// Errors -; // Error, '0' is not number -; // Error, no property "y" -; // Error, no property "y" -; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property -; // Error, missing reqd -; // Error, reqd is not string diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx index edb203655ef..eff3f3a8f43 100644 --- a/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeResolution1.tsx @@ -5,6 +5,7 @@ declare module JSX { interface IntrinsicElements { test1: Attribs1; test2: { reqd: string }; + var: { var: string }; } } interface Attribs1 { @@ -25,9 +26,10 @@ interface Attribs1 { ; // Error, no property "y" ; // Error, no property "y" ; // Error, "32" is not number -// TODO attribute 'var' should be parseable -// ; // Error, no 'var' property +; // Error, no 'var' property ; // Error, missing reqd ; // Error, reqd is not string +// Should be OK +; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx deleted file mode 100644 index 7c47046dcde..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution2.jsx +++ /dev/null @@ -1,5 +0,0 @@ -// OK -; // OK -; // OK -// Errors -; // Error, no leng on 'string' diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx deleted file mode 100644 index 46cb5d8ff69..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution3.jsx +++ /dev/null @@ -1,21 +0,0 @@ -// OK -var obj1 = { x: 'foo' }; -; -// Error, x is not string -var obj2 = { x: 32 }; -; -// Error, x is missing -var obj3 = { y: 32 }; -; -// OK -var obj4 = { x: 32, y: 32 }; -; -// Error -var obj5 = { x: 32, y: 32 }; -; -// OK -var obj6 = { x: 'ok', y: 32, extra: 100 }; -; -// Error -var obj7 = { x: 'foo' }; -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx deleted file mode 100644 index da2e1d12038..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution4.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -; -// Error, no member 'len' on 'string' -; diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx deleted file mode 100644 index 3e4c89d06fb..00000000000 --- a/tests/cases/conformance/jsx/tsxAttributeResolution5.jsx +++ /dev/null @@ -1,11 +0,0 @@ -function make1(obj) { - return ; // OK -} -function make2(obj) { - return ; // Error (x is number, not string) -} -function make3(obj) { - return ; // Error, missing x -} -; // Error, missing x -; // OK diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution9.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution9.tsx new file mode 100644 index 00000000000..9768d65d000 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution9.tsx @@ -0,0 +1,27 @@ +//@jsx: preserve +//@module: amd + +//@filename: react.d.ts +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } +} + +interface Props { + foo: string; +} + +//@filename: file.tsx +export class MyComponent { + render() { + } + + props: { foo: string; } +} + +; // ok +; // should be an error diff --git a/tests/cases/conformance/jsx/tsxElementResolution1.jsx b/tests/cases/conformance/jsx/tsxElementResolution1.jsx deleted file mode 100644 index 97357dbba8e..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution1.jsx +++ /dev/null @@ -1,4 +0,0 @@ -// OK -
; -// Fail -; diff --git a/tests/cases/conformance/jsx/tsxElementResolution11.jsx b/tests/cases/conformance/jsx/tsxElementResolution11.jsx deleted file mode 100644 index 6349906508c..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution11.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var Obj1; -; // OK -var Obj2; -; // Error -var Obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution12.jsx b/tests/cases/conformance/jsx/tsxElementResolution12.jsx deleted file mode 100644 index ef137fd0e29..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution12.jsx +++ /dev/null @@ -1,9 +0,0 @@ -var obj1; -; // OK -var obj2; -; // OK -var obj3; -; // Error -var obj4; -; // OK -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution13.jsx b/tests/cases/conformance/jsx/tsxElementResolution13.jsx deleted file mode 100644 index 6a55efa612d..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution13.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution14.jsx b/tests/cases/conformance/jsx/tsxElementResolution14.jsx deleted file mode 100644 index 29df7710af1..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution14.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // OK diff --git a/tests/cases/conformance/jsx/tsxElementResolution15.jsx b/tests/cases/conformance/jsx/tsxElementResolution15.jsx deleted file mode 100644 index 6a55efa612d..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution15.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution16.jsx b/tests/cases/conformance/jsx/tsxElementResolution16.jsx deleted file mode 100644 index e1987489bbb..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution16.jsx +++ /dev/null @@ -1,2 +0,0 @@ -var obj1; -; // Error (JSX.Element is missing) diff --git a/tests/cases/conformance/jsx/tsxElementResolution19.tsx b/tests/cases/conformance/jsx/tsxElementResolution19.tsx new file mode 100644 index 00000000000..23e503ae962 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxElementResolution19.tsx @@ -0,0 +1,21 @@ +//@jsx: react +//@module: amd + +//@filename: react.d.ts +declare module "react" { + +} + +//@filename: file1.tsx +declare module JSX { + interface Element { } +} +export class MyClass { } + +//@filename: file2.tsx + +// Should not elide React import +import * as React from 'react'; +import {MyClass} from './file1'; + +; diff --git a/tests/cases/conformance/jsx/tsxElementResolution7.jsx b/tests/cases/conformance/jsx/tsxElementResolution7.jsx deleted file mode 100644 index e95505539ab..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution7.jsx +++ /dev/null @@ -1,14 +0,0 @@ -var my; -(function (my) { -})(my || (my = {})); -// OK -; -// Error -; -var q; -(function (q) { - // OK - ; - // Error - ; -})(q || (q = {})); diff --git a/tests/cases/conformance/jsx/tsxElementResolution8.jsx b/tests/cases/conformance/jsx/tsxElementResolution8.jsx deleted file mode 100644 index e0f95dc6d22..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution8.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// Error -var div = 3; -
; -// OK -function fact() { return null; } -; -// Error -function fnum() { return 42; } -; -var obj1; -; // OK, prefer construct signatures -var obj2; -; // Error -var obj3; -; // Error diff --git a/tests/cases/conformance/jsx/tsxElementResolution9.jsx b/tests/cases/conformance/jsx/tsxElementResolution9.jsx deleted file mode 100644 index 2b62d86eac5..00000000000 --- a/tests/cases/conformance/jsx/tsxElementResolution9.jsx +++ /dev/null @@ -1,6 +0,0 @@ -var obj1; -; // Error, return type is not an object type -var obj2; -; // Error, return type is not an object type -var obj3; -; // OK diff --git a/tests/cases/conformance/jsx/tsxEmit1.jsx b/tests/cases/conformance/jsx/tsxEmit1.jsx deleted file mode 100644 index 45ca6e2469f..00000000000 --- a/tests/cases/conformance/jsx/tsxEmit1.jsx +++ /dev/null @@ -1,34 +0,0 @@ -var p; -/* -var selfClosed1 =
; -var selfClosed2 =
; -var selfClosed3 =
; -var selfClosed4 =
; -var selfClosed5 =
; -var selfClosed6 =
; -var selfClosed7 =
; - -var openClosed1 =
; -var openClosed2 =
foo
; -var openClosed3 =
{p}
; -var openClosed4 =
{p < p}
; -var openClosed5 =
{p > p}
; -*/ -var SomeClass = (function () { - function SomeClass() { - } - SomeClass.prototype.f = function () { - var _this = this; - var rewrites1 =
{function () { return _this; }}
; - var rewrites4 =
; - }; - return SomeClass; -})(); -/* -var q = () => this; -var rewrites2 =
{[p, ...p, p]}
; -var rewrites3 =
{{p}}
; - -var rewrites5 =
; -var rewrites6 =
; -*/ diff --git a/tests/cases/conformance/jsx/tsxEmit3.jsx b/tests/cases/conformance/jsx/tsxEmit3.jsx deleted file mode 100644 index 7c979051d00..00000000000 --- a/tests/cases/conformance/jsx/tsxEmit3.jsx +++ /dev/null @@ -1,41 +0,0 @@ -var M; -(function (M) { - var Foo = (function () { - function Foo() { - } - return Foo; - })(); - M.Foo = Foo; - var S; - (function (S) { - var Bar = (function () { - function Bar() { - } - return Bar; - })(); - S.Bar = Bar; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.Foo - M.Foo, ; - var S; - (function (S) { - // Emit M.Foo - M.Foo, ; - // Emit S.Bar - S.Bar, ; - })(S = M.S || (M.S = {})); -})(M || (M = {})); -var M; -(function (M) { - // Emit M.S.Bar - M.S.Bar, ; -})(M || (M = {})); -var M; -(function (M_1) { - var M = 100; - // Emit M_1.Foo - M_1.Foo, ; -})(M || (M = {})); diff --git a/tests/cases/conformance/jsx/tsxReactEmit1.tsx b/tests/cases/conformance/jsx/tsxReactEmit1.tsx index b8f14b0ba22..15ece4153a8 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit1.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit1.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var selfClosed1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit2.tsx b/tests/cases/conformance/jsx/tsxReactEmit2.tsx index 39a78a7da87..96ab8c6046b 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit2.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit2.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p1, p2, p3; var spreads1 =
{p2}
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit3.tsx b/tests/cases/conformance/jsx/tsxReactEmit3.tsx index eb63be44f3b..12adcd3c2b6 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit3.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit3.tsx @@ -2,6 +2,7 @@ //@filename: test.tsx declare module JSX { interface Element { } } +declare var React: any; declare var Foo, Bar, baz; diff --git a/tests/cases/conformance/jsx/tsxReactEmit4.tsx b/tests/cases/conformance/jsx/tsxReactEmit4.tsx index f007c35c24a..a032a5a3985 100644 --- a/tests/cases/conformance/jsx/tsxReactEmit4.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmit4.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; var p; var openClosed1 =
diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 38c966fa700..34fd158eab1 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -6,6 +6,7 @@ declare module JSX { [s: string]: any; } } +declare var React: any; // THIS FILE HAS TEST-SIGNIFICANT LEADING/TRAILING // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT diff --git a/tests/cases/conformance/types/intersection/contextualIntersectionType.ts b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts new file mode 100644 index 00000000000..580827992ac --- /dev/null +++ b/tests/cases/conformance/types/intersection/contextualIntersectionType.ts @@ -0,0 +1,5 @@ +var x: { a: (s: string) => string } & { b: (n: number) => number }; +x = { + a: s => s, + b: n => n +}; diff --git a/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts new file mode 100644 index 00000000000..e6bd671c6b2 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts @@ -0,0 +1,38 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +var a: A; +var b: B; +var c: C; +var d: D; +var anb: A & B; +var aob: A | B; +var cnd: C & D; +var cod: C | D; +var x: A & B | C & D; +var y: (A | B) & (C | D); + +a = anb; // Ok +b = anb; // Ok +anb = a; +anb = b; + +x = anb; // Ok +x = aob; +x = cnd; // Ok +x = cod; +anb = x; +aob = x; +cnd = x; +cod = x; + +y = anb; +y = aob; +y = cnd; +y = cod; +anb = y; +aob = y; // Ok +cnd = y; +cod = y; // Ok diff --git a/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts new file mode 100644 index 00000000000..00a299ea244 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts @@ -0,0 +1,17 @@ +var a: { a: string }; +var b: { b: string }; +var x: { a: string, b: string }; +var y: { a: string } & { b: string }; + +a = x; +a = y; +x = a; // Error +y = a; // Error + +b = x; +b = y; +x = b; // Error +y = b; // Error + +x = y; +y = x; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts new file mode 100644 index 00000000000..fce399eff94 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeEquivalence.ts @@ -0,0 +1,16 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } + +// A & B is equivalent to B & A. +var y: A & B; +var y : B & A; + +// AB & C is equivalent to A & BC, where AB is A & B and BC is B & C. +var z : A & B & C; +var z : (A & B) & C; +var z : A & (B & C); +var ab : A & B; +var bc : B & C; +var z1: typeof ab & C; +var z1: A & typeof bc; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts new file mode 100644 index 00000000000..32a419ff03a --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference.ts @@ -0,0 +1,27 @@ +function extend(obj1: T, obj2: U): T & U { + var result: T & U; + obj1 = result; + obj2 = result; + result = obj1; // Error + result = obj2; // Error + return result; +} + +var x = extend({ a: "hello" }, { b: 42 }); +var s = x.a; +var n = x.b; + +interface A { + a: T; +} + +interface B { + b: U; +} + +function foo(obj: A & B): T | U { + return undefined; +} + +var z = foo({ a: "hello", b: 42 }); +var z: string | number; diff --git a/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts new file mode 100644 index 00000000000..a8c92647f47 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts @@ -0,0 +1,27 @@ +// An intersection type has those members that are present in any of its constituent types, +// with types that are intersections of the respective members in the constituent types + +interface A { a: string } +interface B { b: string } +interface C { c: string } + +var abc: A & B & C; +abc.a = "hello"; +abc.b = "hello"; +abc.c = "hello"; + +interface X { x: A } +interface Y { x: B } +interface Z { x: C } + +var xyz: X & Y & Z; +xyz.x.a = "hello"; +xyz.x.b = "hello"; +xyz.x.c = "hello"; + +type F1 = (x: string) => string; +type F2 = (x: number) => number; + +var f: F1 & F2; +var s = f("hello"); +var n = f(42); diff --git a/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts new file mode 100644 index 00000000000..0a0d30d8dbb --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeOverloading.ts @@ -0,0 +1,14 @@ +// Check that order is preserved in intersection types for purposes of +// overload resolution + +type F = (s: string) => string; +type G = (x: any) => any; + +var fg: F & G; +var gf: G & F; + +var x = fg("abc"); +var x: string; + +var y = gf("abc"); +var y: any; diff --git a/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts new file mode 100644 index 00000000000..d741d30ac1f --- /dev/null +++ b/tests/cases/conformance/types/intersection/recursiveIntersectionTypes.ts @@ -0,0 +1,19 @@ +type LinkedList = T & { next: LinkedList }; + +interface Entity { + name: string; +} + +interface Product extends Entity { + price: number; +} + +var entityList: LinkedList; +var s = entityList.name; +var s = entityList.next.name; +var s = entityList.next.next.name; +var s = entityList.next.next.next.name; + +var productList: LinkedList; +entityList = productList; +productList = entityList; // Error diff --git a/tests/cases/fourslash/completionForExports.ts b/tests/cases/fourslash/completionForExports.ts deleted file mode 100644 index 57c0f75efc1..00000000000 --- a/tests/cases/fourslash/completionForExports.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -// @Filename: m1.ts -////export var foo: number = 1; -////export function bar() { return 10; } -////export function baz() { return 10; } - -// @Filename: m2.ts -////import {/*1*/, /*2*/ from "m1" -////import {/*3*/} from "m1" -////import {foo,/*4*/ from "m1" -////import {bar as /*5*/, /*6*/ from "m1" -////import {foo, bar, baz as b,/*7*/} from "m1" -function verifyCompletionAtMarker(marker: string, ...completions: string[]) { - goTo.marker(marker); - if (completions.length) { - for (var i = 0; i < completions.length; ++i) { - verify.completionListContains(completions[i]); - } - } - else { - verify.completionListIsEmpty(); - } -} - -verifyCompletionAtMarker("1", "foo", "bar", "baz"); -verifyCompletionAtMarker("2", "foo", "bar", "baz"); -verifyCompletionAtMarker("3", "foo", "bar", "baz"); -verifyCompletionAtMarker("4", "bar", "baz"); -verifyCompletionAtMarker("5"); -verifyCompletionAtMarker("6", "foo", "baz"); -verifyCompletionAtMarker("7"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts new file mode 100644 index 00000000000..48a50124daf --- /dev/null +++ b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts @@ -0,0 +1,7 @@ +/// + +////let v = [1,2,3,4]; +////let x = [.../**/ + +goTo.marker(); +verify.completionListContains("v"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index eac7085ab66..0552e540a7e 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -5,9 +5,8 @@ ////module A./*moduleName2*/ +goTo.marker("moduleName1"); +verify.not.completionListIsEmpty(); -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +goTo.marker("moduleName2"); +verify.completionListIsEmpty(); diff --git a/tests/cases/fourslash/completionListForUnicodeEscapeName.ts b/tests/cases/fourslash/completionListForUnicodeEscapeName.ts new file mode 100644 index 00000000000..afafd18a58b --- /dev/null +++ b/tests/cases/fourslash/completionListForUnicodeEscapeName.ts @@ -0,0 +1,27 @@ +/// + +////function \u0042 () { /*0*/ } +////export default function \u0043 () { /*1*/ } +////class \u0041 { /*2*/ } +/////*3*/ + +goTo.marker("0"); +verify.not.completionListContains("B"); +verify.not.completionListContains("\u0042"); + +goTo.marker("2"); +verify.not.completionListContains("C"); +verify.not.completionListContains("\u0043"); + +goTo.marker("2"); +verify.not.completionListContains("A"); +verify.not.completionListContains("\u0041"); + +goTo.marker("3"); +verify.not.completionListContains("B"); +verify.not.completionListContains("\u0042"); +verify.not.completionListContains("A"); +verify.not.completionListContains("\u0041"); +verify.not.completionListContains("C"); +verify.not.completionListContains("\u0043"); + diff --git a/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts b/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts new file mode 100644 index 00000000000..6f016b73a76 --- /dev/null +++ b/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts @@ -0,0 +1,14 @@ +/// + +//// var x = class myClass { +//// getClassName (){ +//// /*0*/ +//// } +//// prop: Ty/*1*/ +//// } + +goTo.marker("0"); +verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass", /*documentation*/ undefined, "type parameter"); + +goTo.marker("1"); +verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass", /*documentation*/ undefined, "type parameter"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts new file mode 100644 index 00000000000..1191216baf1 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -0,0 +1,39 @@ +/// + +// @Filename: m1.ts +////export var foo: number = 1; +////export function bar() { return 10; } +////export function baz() { return 10; } + +// @Filename: m2.ts +////import {/*1*/, /*2*/ from "m1" +////import {/*3*/} from "m1" +////import {foo,/*4*/ from "m1" +////import {bar as /*5*/, /*6*/ from "m1" +////import {foo, bar, baz as b,/*7*/} from "m1" +function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { + goTo.marker(marker); + if (completions.length) { + for (let completion of completions) { + verify.completionListContains(completion); + } + } + else { + verify.completionListIsEmpty(); + } + + if (showBuilder) { + verify.completionListAllowsNewIdentifier(); + } + else { + verify.not.completionListAllowsNewIdentifier(); + } +} + +verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); +verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); +verifyCompletionAtMarker("5", /*showBuilder*/ true); +verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); +verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts new file mode 100644 index 00000000000..9cf216f4578 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -0,0 +1,13 @@ +/// + +////declare module "M1" { +//// export var V; +////} +//// +////declare module "M2" { +//// import { /**/ } from "M1" +////} + +goTo.marker(); +verify.completionListContains("V"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/completionListInImportClause03.ts b/tests/cases/fourslash/completionListInImportClause03.ts new file mode 100644 index 00000000000..7461c83022b --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause03.ts @@ -0,0 +1,16 @@ +/// + +////declare module "M1" { +//// export var abc: number; +//// export var def: string; +////} +//// +////declare module "M2" { +//// import { abc/**/ } from "M1"; +////} + +// Ensure we don't filter out the current item. +goTo.marker(); +verify.completionListContains("abc"); +verify.completionListContains("def"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts new file mode 100644 index 00000000000..2db28505b3e --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// [/*1*/]: T; +//// [/*2*/]: T; +////} +//// +////class C { +//// [/*3*/]: string; +//// [str/*4*/: string]: number; +////} +//// +////type T = { +//// [x/*5*/yz: number]: boolean; +//// [/*6*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts new file mode 100644 index 00000000000..d3b65dc7759 --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [x: /*1*/]: T; +//// [: /*2*/]: T +////} +//// +////class C { +//// [a: /*3*/]: string; +//// [str: string/*4*/]: number; +////} +//// +////type T = { +//// [xyz: /*5*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.not.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInNamedClassExpression.ts b/tests/cases/fourslash/completionListInNamedClassExpression.ts new file mode 100644 index 00000000000..cf0d170f6a5 --- /dev/null +++ b/tests/cases/fourslash/completionListInNamedClassExpression.ts @@ -0,0 +1,14 @@ +/// + +//// var x = class myClass { +//// getClassName (){ +//// m/*0*/ +//// } +//// /*1*/ +//// } + +goTo.marker("0"); +verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); + +goTo.marker("1"); +verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts b/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts new file mode 100644 index 00000000000..e1274e6f592 --- /dev/null +++ b/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts @@ -0,0 +1,40 @@ +/// + +//// class myClass { /*0*/ } +//// /*1*/ +//// var x = class myClass { +//// getClassName (){ +//// m/*2*/ +//// } +//// /*3*/ +//// } +//// var y = class { +//// getSomeName() { +//// /*4*/ +//// } +//// /*5*/ +//// } + +goTo.marker("0"); +verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); +verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); + +goTo.marker("1"); +verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); +verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); + +goTo.marker("2"); +verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); +verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); + +goTo.marker("3"); +verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); +verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); + +goTo.marker("4"); +verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); +verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); + +goTo.marker("5"); +verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); +verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); diff --git a/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts b/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts new file mode 100644 index 00000000000..bb64e04b93b --- /dev/null +++ b/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts @@ -0,0 +1,8 @@ +/// + +//// var x = function foo() { +//// /*1*/ +//// } + +goTo.marker("1"); +verify.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts b/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts new file mode 100644 index 00000000000..14965253e84 --- /dev/null +++ b/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts @@ -0,0 +1,22 @@ +/// + +//// function foo() {} +//// /*0*/ +//// var x = function foo() { +//// /*1*/ +//// } +//// var y = function () { +//// /*2*/ +//// } + +goTo.marker("0"); +verify.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function"); +verify.not.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function");; + +goTo.marker("1"); +verify.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function"); +verify.not.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function");; + +goTo.marker("2"); +verify.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function") +verify.not.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function");; \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts index 128e95b8ed3..99188457e6f 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts index 6d2b7a6b516..0cd86c8d1a6 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts index 92b202a1b37..e6057ec0fae 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts @@ -10,4 +10,5 @@ goTo.marker(); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts index d17e11810df..d0876ed6a34 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts @@ -9,4 +9,5 @@ ////var { property1/**/ } = foo; goTo.marker(); -verify.completionListContains("property1"); \ No newline at end of file +verify.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts index a3015346aa3..4db3fc383d4 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_1"); verify.completionListContains("propertyOfI_2"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts index 6d6be330b83..b062ca702a2 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts @@ -15,4 +15,5 @@ goTo.marker(); verify.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListContains("property2"); \ No newline at end of file +verify.not.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts index 2698e78667b..61b31385b35 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts @@ -16,4 +16,5 @@ goTo.marker(); verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); \ No newline at end of file +verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts index fcc09d1ead4..836e12fd8a3 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts @@ -17,7 +17,9 @@ verify.completionListContains("property2"); verify.not.completionListContains("property1"); verify.not.completionListContains("propertyOfI_2"); verify.not.completionListContains("propertyOfI_1"); +verify.not.completionListAllowsNewIdentifier(); goTo.marker("2"); verify.completionListContains("property1"); -verify.completionListContains("property2"); \ No newline at end of file +verify.completionListContains("property2"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts index 25d6651a038..57a32578026 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); verify.not.completionListContains("property1"); -verify.not.completionListContains("prop1"); \ No newline at end of file +verify.not.completionListContains("prop1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts index f31206a21b6..59af2da38d2 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts @@ -10,4 +10,5 @@ goTo.marker(""); verify.completionListContains("property2"); -verify.not.completionListContains("property1"); \ No newline at end of file +verify.not.completionListContains("property1"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts new file mode 100644 index 00000000000..8081d2ee23b --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// x: number; +//// y: string; +//// z: boolean; +////} +//// +////interface J { +//// x: string; +//// y: string; +////} +//// +////let { /**/ }: I | J = { x: 10 }; + +goTo.marker(); +verify.completionListContains("x"); +verify.completionListContains("y"); +verify.not.completionListContains("z"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInvalidMemberNames.ts b/tests/cases/fourslash/completionListInvalidMemberNames.ts index 7fff46e2a81..0928f8b9d8c 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames.ts @@ -19,7 +19,6 @@ verify.completionListContains("bar"); verify.completionListContains("break"); verify.completionListContains("any"); verify.completionListContains("$"); -verify.completionListContains("b"); // Nothing else should show up -verify.memberListCount(5); +verify.memberListCount(4); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 07a1fc4de40..a0463073d8c 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -169,7 +169,7 @@ module FourSlashInterface { // completion list is brought up if necessary public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { if (this.negative) { - FourSlash.currentTestState.verifyCompletionListDoesNotContain(symbol); + FourSlash.currentTestState.verifyCompletionListDoesNotContain(symbol, text, documentation, kind); } else { FourSlash.currentTestState.verifyCompletionListContains(symbol, text, documentation, kind); } diff --git a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts index 930c0511ffb..b5deb361056 100644 --- a/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts +++ b/tests/cases/fourslash/incrementalParsingInsertIntoMethod1.ts @@ -8,6 +8,5 @@ //// public foo3() { } ////} -debugger; goTo.marker("1"); edit.insert(" + 1"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterDoubleDot.ts b/tests/cases/fourslash/memberListAfterDoubleDot.ts new file mode 100644 index 00000000000..21a1ad913ea --- /dev/null +++ b/tests/cases/fourslash/memberListAfterDoubleDot.ts @@ -0,0 +1,6 @@ +/// + +////../**/ + +goTo.marker(); +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index 0bc5107f2c1..62edf3b8c9e 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -3,4 +3,4 @@ ////./**/ goTo.marker(); -verify.not.memberListIsEmpty(); \ No newline at end of file +verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index a1174d503ed..b95040085c9 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -3,13 +3,13 @@ ////class Foo { ////} //// -////var x = class /**/Foo { +////var x = class [|Foo|] { //// doIt() { -//// return Foo; +//// return [|Foo|]; //// } //// //// static doItStatically() { -//// return Foo; +//// return [|Foo|].y; //// } ////} //// @@ -18,17 +18,10 @@ //// return Foo //// } ////} +////var z = class Foo {} - -// TODO (yuit): Fix up this test when class expressions are supported. -// Just uncomment the below, remove the marker, and add the -// appropriate ranges in the test itself. -goTo.marker(); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); - -////let ranges = test.ranges() -////for (let range of ranges) { -//// goTo.position(range.start); -//// -//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////} \ No newline at end of file +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationsCancellation1.ts b/tests/cases/fourslash/semanticClassificationsCancellation1.ts new file mode 100644 index 00000000000..9381bef5e86 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationsCancellation1.ts @@ -0,0 +1,15 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.semanticClassificationsAre()); +cancellation.resetCancelled(); + +verify.semanticClassificationsAre( + c.moduleName("M"), + c.moduleName("N")); diff --git a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts b/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts deleted file mode 100644 index 09f580bb965..00000000000 --- a/tests/cases/fourslash/shims/cancellationWhenfindingAllRefsOnDefinition.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -//@Filename: findAllRefsOnDefinition-import.ts -////export class Test{ -//// -//// constructor(){ -//// -//// } -//// -//// public /*1*/start(){ -//// return this; -//// } -//// -//// public stop(){ -//// return this; -//// } -////} - -//@Filename: findAllRefsOnDefinition.ts -////import Second = require("findAllRefsOnDefinition-import"); -//// -////var second = new Second.Test() -////second.start(); -////second.stop(); - -goTo.file("findAllRefsOnDefinition-import.ts"); -goTo.marker("1"); - -verify.referencesCountIs(2); - -cancellation.setCancelled(); -goTo.marker("1"); -verifyOperationIsCancelled(() => verify.referencesCountIs(0) ); - -// verify that internal state is still correct -cancellation.resetCancelled(); -goTo.marker("1"); -verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpOnTypePredicates.ts b/tests/cases/fourslash/signatureHelpOnTypePredicates.ts new file mode 100644 index 00000000000..bfaa7df2502 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpOnTypePredicates.ts @@ -0,0 +1,20 @@ +/// + +//// function f1(a: any): a is number {} +//// function f2(a: any): a is T {} +//// function f3(a: any, ...b): a is number {} +//// f1(/*1*/) +//// f2(/*2*/) +//// f3(/*3*/) + +goTo.marker("1"); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("f1(a: any): a is number"); + +goTo.marker("2"); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("f2(a: any): a is T"); + +goTo.marker("3"); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("f3(a: any, ...b: any[]): a is number"); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsCancellation1.ts b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts new file mode 100644 index 00000000000..f15ce5f9984 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsCancellation1.ts @@ -0,0 +1,21 @@ +/// + +////module M { +////} +////module N { +////} + +var c = classification; +cancellation.setCancelled(1); +verifyOperationIsCancelled(() => verify.syntacticClassificationsAre()); +cancellation.resetCancelled(); + +verify.syntacticClassificationsAre( + c.keyword("module"), + c.moduleName("M"), + c.punctuation("{"), + c.punctuation("}"), + c.keyword("module"), + c.moduleName("N"), + c.punctuation("{"), + c.punctuation("}")); diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts index e381856c41e..7f26038c33e 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts @@ -7,7 +7,7 @@ //// v = 2; ////>>>>>>> Branch - a ////} -debugger; + var c = classification; verify.syntacticClassificationsAre( c.keyword("class"), c.className("C"), c.punctuation("{"), diff --git a/tests/cases/fourslash/tsxCompletion3.ts b/tests/cases/fourslash/tsxCompletion3.ts new file mode 100644 index 00000000000..5ee712f7e96 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion3.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +////
; + +goTo.marker(); +verify.completionListContains('two'); +verify.not.completionListContains('one'); diff --git a/tests/cases/fourslash/tsxCompletion4.ts b/tests/cases/fourslash/tsxCompletion4.ts new file mode 100644 index 00000000000..6a66c4a898f --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion4.ts @@ -0,0 +1,14 @@ +/// + +//@Filename: file.tsx +//// declare namespace JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { one; two; } +//// } +//// } +//// let bag = { x: 100, y: 200 }; +////
+ +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.completionListContains("ONE"); +verify.completionListContains("TWO"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000000..16a69b81f83 --- /dev/null +++ b/tslint.json @@ -0,0 +1,23 @@ +{ + "rules": { + "class-name": true, + "comment-format": [true, + "check-space" + ], + "indent": true, + "one-line": [true, + "check-open-brace" + ], + "no-unreachable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "quotemark": true, + "semicolon": true, + "whitespace": [true, + "check-branch", + "check-operator", + "check-separator", + "check-type" + ] + } +}