diff --git a/Jakefile.js b/Jakefile.js index 16f0645323c..c62a4ffd6ce 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -129,6 +129,7 @@ var servicesSources = [ "documentRegistry.ts", "findAllReferences.ts", "goToDefinition.ts", + "goToImplementation.ts", "jsDoc.ts", "jsTyping.ts", "navigateTo.ts", @@ -789,7 +790,7 @@ function cleanTestDirs() { // used to pass data from jake command line directly to run.js function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit) { - var testConfigContents = JSON.stringify({ + var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3bccf6b4a9b..49434e80aba 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -268,7 +268,7 @@ namespace ts { Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType); let functionType = node.parent; let index = indexOf(functionType.parameters, node); - return "p" + index; + return "arg" + index; case SyntaxKind.JSDocTypedefTag: const parentNode = node.parent && node.parent.parent; let nameFromParentNode: string; @@ -540,9 +540,7 @@ namespace ts { // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. if (isInJavaScriptFile(node) && node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - bind(jsDocComment); - } + forEach(node.jsDocComments, bind); } if (checkUnreachable(node)) { forEachChild(node, bind); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 29270628fb0..dc834c7f403 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -914,8 +914,8 @@ namespace ts { } } - // If we're in an external module, we can't reference symbols created from UMD export declarations - if (result && isInExternalModule) { + // If we're in an external module, we can't reference value symbols created from UMD export declarations + if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) { const decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) { error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name); @@ -1758,7 +1758,15 @@ namespace ts { return false; } - function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult { + /** + * Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested + * + * @param symbol a Symbol to check if accessible + * @param enclosingDeclaration a Node containing reference to the symbol + * @param meaning a SymbolFlags to check if such meaning of the symbol is accessible + * @param shouldComputeAliasToMakeVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible + */ + function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult { if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) { const initialSymbol = symbol; let meaningToLook = meaning; @@ -1766,7 +1774,7 @@ namespace ts { // Symbol is accessible if it by itself is accessible const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { - const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); + const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible); if (!hasAccessibleDeclarations) { return { accessibility: SymbolAccessibility.NotAccessible, @@ -1830,7 +1838,7 @@ namespace ts { return isAmbientModule(declaration) || (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(declaration)); } - function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult { + function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult { let aliasesToMakeVisible: AnyImportSyntax[]; if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) { return undefined; @@ -1846,14 +1854,19 @@ namespace ts { if (anyImportSyntax && !(getModifierFlags(anyImportSyntax) & ModifierFlags.Export) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); + // In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types, + // we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time + // since we will do the emitting later in trackSymbol. + if (shouldComputeAliasToMakeVisible) { + getNodeLinks(declaration).isVisible = true; + if (aliasesToMakeVisible) { + if (!contains(aliasesToMakeVisible, anyImportSyntax)) { + aliasesToMakeVisible.push(anyImportSyntax); + } + } + else { + aliasesToMakeVisible = [anyImportSyntax]; } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; } return true; } @@ -1888,7 +1901,7 @@ namespace ts { const symbol = resolveName(enclosingDeclaration, (firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible - return (symbol && hasVisibleDeclarations(symbol)) || { + return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: getTextOfNode(firstIdentifier), errorNode: firstIdentifier @@ -2163,7 +2176,9 @@ namespace ts { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } - else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) { + else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol && + isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { + // Only write out inferred type with its corresponding type-alias if type-alias is visible const typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } @@ -5653,12 +5668,13 @@ namespace ts { case SyntaxKind.JSDocThisType: case SyntaxKind.JSDocOptionalType: return getTypeFromTypeNode((node).type); + case SyntaxKind.JSDocRecordType: + return getTypeFromTypeNode((node as JSDocRecordType).literal); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: case SyntaxKind.JSDocTypeLiteral: case SyntaxKind.JSDocFunctionType: - case SyntaxKind.JSDocRecordType: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 68e488295e7..a015ad79b97 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -306,7 +306,7 @@ namespace ts { } function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); + handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6e6b372b1c1..1aec63bc588 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -379,7 +379,7 @@ namespace ts { case SyntaxKind.JSDocNullableType: return visitNode(cbNode, (node).type); case SyntaxKind.JSDocRecordType: - return visitNodes(cbNodes, (node).members); + return visitNode(cbNode, (node).literal); case SyntaxKind.JSDocTypeReference: return visitNode(cbNode, (node).name) || visitNodes(cbNodes, (node).typeArguments); @@ -398,7 +398,7 @@ namespace ts { return visitNode(cbNode, (node).name) || visitNode(cbNode, (node).type); case SyntaxKind.JSDocComment: - return visitNodes(cbNodes, (node).tags); + return visitNodes(cbNodes, (node).tags); case SyntaxKind.JSDocParameterTag: return visitNode(cbNode, (node).preParameterName) || visitNode(cbNode, (node).typeExpression) || @@ -453,10 +453,10 @@ namespace ts { /* @internal */ export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) { const result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - if (result && result.jsDocComment) { + if (result && result.jsDoc) { // because the jsDocComment was parsed out of the source file, it might // not be covered by the fixupParentReferences. - Parser.fixupParentReferences(result.jsDocComment); + Parser.fixupParentReferences(result.jsDoc); } return result; @@ -655,20 +655,18 @@ namespace ts { function addJSDocComment(node: T): T { - if (contextFlags & NodeFlags.JavaScriptFile) { - const comments = getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (const comment of comments) { - const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (!jsDocComment) { - continue; - } - - if (!node.jsDocComments) { - node.jsDocComments = []; - } - node.jsDocComments.push(jsDocComment); + const comments = getJsDocCommentsFromText(node, sourceFile.text); + if (comments) { + for (const comment of comments) { + const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (!jsDoc) { + continue; } + + if (!node.jsDocComments) { + node.jsDocComments = []; + } + node.jsDocComments.push(jsDoc); } } @@ -2204,7 +2202,7 @@ namespace ts { } fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function isIndexSignature(): boolean { @@ -2294,7 +2292,7 @@ namespace ts { // [Yield] nor [Await] fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); - return finishNode(method); + return addJSDocComment(finishNode(method)); } else { const property = createNode(SyntaxKind.PropertySignature, fullStart); @@ -2311,7 +2309,7 @@ namespace ts { } parseTypeMemberSemicolon(); - return finishNode(property); + return addJSDocComment(finishNode(property)); } } @@ -2898,7 +2896,7 @@ namespace ts { node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function tryParseParenthesizedArrowFunctionExpression(): Expression { @@ -2931,7 +2929,7 @@ namespace ts { ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); - return finishNode(arrowFunction); + return addJSDocComment(finishNode(arrowFunction)); } // True -> We definitely expect a parenthesized arrow function here. @@ -4114,7 +4112,7 @@ namespace ts { function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): AccessorDeclaration { if (parseContextualModifier(SyntaxKind.GetKeyword)) { - return addJSDocComment(parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers)); + return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers); } else if (parseContextualModifier(SyntaxKind.SetKeyword)) { return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers); @@ -4997,7 +4995,7 @@ namespace ts { : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer); parseSemicolon(); - return finishNode(property); + return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ClassElement { @@ -5026,7 +5024,7 @@ namespace ts { node.name = parsePropertyName(); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken: SyntaxKind) { @@ -5264,7 +5262,7 @@ namespace ts { node.members = createMissingList(); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseNameOfClassDeclarationOrExpression(): Identifier { @@ -5332,7 +5330,7 @@ namespace ts { node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): TypeAliasDeclaration { @@ -5356,7 +5354,7 @@ namespace ts { const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): EnumDeclaration { @@ -5372,7 +5370,7 @@ namespace ts { else { node.members = createMissingList(); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseModuleBlock(): ModuleBlock { @@ -5399,7 +5397,7 @@ namespace ts { node.body = parseOptional(SyntaxKind.DotToken) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag) : parseModuleBlock(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ModuleDeclaration { @@ -5488,7 +5486,7 @@ namespace ts { parseExpected(SyntaxKind.EqualsToken); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); - return finishNode(importEqualsDeclaration); + return addJSDocComment(finishNode(importEqualsDeclaration)); } } @@ -5809,6 +5807,7 @@ namespace ts { export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); + sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS); scanner.setText(content, start, length); currentToken = scanner.scan(); const jsDocTypeExpression = parseJSDocTypeExpression(); @@ -6027,22 +6026,7 @@ namespace ts { function parseJSDocRecordType(): JSDocRecordType { const result = createNode(SyntaxKind.JSDocRecordType); - nextToken(); - result.members = parseDelimitedList(ParsingContext.JSDocRecordMembers, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(SyntaxKind.CloseBraceToken); - return finishNode(result); - } - - function parseJSDocRecordMember(): JSDocRecordMember { - const result = createNode(SyntaxKind.JSDocRecordMember); - result.name = parseSimplePropertyName(); - - if (token() === SyntaxKind.ColonToken) { - nextToken(); - result.type = parseJSDocType(); - } - + result.literal = parseTypeLiteral(); return finishNode(result); } @@ -6140,14 +6124,14 @@ namespace ts { export function parseIsolatedJSDocComment(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); sourceFile = { languageVariant: LanguageVariant.Standard, text: content }; - const jsDocComment = parseJSDocCommentWorker(start, length); + const jsDoc = parseJSDocCommentWorker(start, length); const diagnostics = parseDiagnostics; clearState(); - return jsDocComment ? { jsDocComment, diagnostics } : undefined; + return jsDoc ? { jsDoc, diagnostics } : undefined; } - export function parseJSDocComment(parent: Node, start: number, length: number): JSDocComment { + export function parseJSDocComment(parent: Node, start: number, length: number): JSDoc { const saveToken = currentToken; const saveParseDiagnosticsLength = parseDiagnostics.length; const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; @@ -6164,7 +6148,13 @@ namespace ts { return comment; } - export function parseJSDocCommentWorker(start: number, length: number): JSDocComment { + const enum JSDocState { + BeginningOfLine, + SawAsterisk, + SavingComments, + } + + export function parseJSDocCommentWorker(start: number, length: number): JSDoc { const content = sourceText; start = start || 0; const end = length === undefined ? content.length : start + length; @@ -6175,76 +6165,134 @@ namespace ts { Debug.assert(end <= content.length); let tags: NodeArray; - let result: JSDocComment; + const comments: string[] = []; + let result: JSDoc; // Check for /** (JSDoc opening part) - if (content.charCodeAt(start) === CharacterCodes.slash && - content.charCodeAt(start + 1) === CharacterCodes.asterisk && - content.charCodeAt(start + 2) === CharacterCodes.asterisk && - content.charCodeAt(start + 3) !== CharacterCodes.asterisk) { + if (!isJsDocStart(content, start)) { + return result; + } + // + 3 for leading /**, - 5 in total for /** */ + scanner.scanRange(start + 3, length - 5, () => { + // Initially we can parse out a tag. We also have seen a starting asterisk. + // This is so that /** * @type */ doesn't parse. + let advanceToken = true; + let state = JSDocState.SawAsterisk; + let margin: number | undefined = undefined; + // + 4 for leading '/** ' + let indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4; + function pushComment(text: string) { + if (!margin) { + margin = indent; + } + comments.push(text); + indent += text.length; + } - // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, () => { - // Initially we can parse out a tag. We also have seen a starting asterisk. - // This is so that /** * @type */ doesn't parse. - let canParseTag = true; - let seenAsterisk = true; - + nextJSDocToken(); + while (token() === SyntaxKind.WhitespaceTrivia) { nextJSDocToken(); - while (token() !== SyntaxKind.EndOfFileToken) { - switch (token()) { - case SyntaxKind.AtToken: - if (canParseTag) { - parseTag(); - } - // This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop - seenAsterisk = false; - break; - - case SyntaxKind.NewLineTrivia: - // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet - canParseTag = true; - seenAsterisk = false; - break; - - case SyntaxKind.AsteriskToken: - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag on this line - canParseTag = false; - } + } + if (token() === SyntaxKind.NewLineTrivia) { + state = JSDocState.BeginningOfLine; + nextJSDocToken(); + } + while (token() !== SyntaxKind.EndOfFileToken) { + switch (token()) { + case SyntaxKind.AtToken: + if (state === JSDocState.BeginningOfLine || state === JSDocState.SawAsterisk) { + removeTrailingNewlines(comments); + parseTag(indent); + // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. + // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning + // for malformed examples like `/** @param {string} x @returns {number} the length */` + state = JSDocState.BeginningOfLine; + advanceToken = false; + margin = undefined; + indent++; + } + else { + pushComment(scanner.getTokenText()); + } + break; + case SyntaxKind.NewLineTrivia: + comments.push(scanner.getTokenText()); + state = JSDocState.BeginningOfLine; + indent = 0; + break; + case SyntaxKind.AsteriskToken: + const asterisk = scanner.getTokenText(); + if (state === JSDocState.SawAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag on this line + state = JSDocState.SavingComments; + pushComment(asterisk); + } + else { // Ignore the first asterisk on a line - seenAsterisk = true; - break; - - case SyntaxKind.Identifier: - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; - break; - - case SyntaxKind.EndOfFileToken: - break; - } - + state = JSDocState.SawAsterisk; + indent += asterisk.length; + } + break; + case SyntaxKind.Identifier: + // Anything else is doc comment text. We just save it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. + pushComment(scanner.getTokenText()); + state = JSDocState.SavingComments; + break; + case SyntaxKind.WhitespaceTrivia: + // only collect whitespace if we're already saving comments or have just crossed the comment indent margin + const whitespace = scanner.getTokenText(); + if (state === JSDocState.SavingComments || margin !== undefined && indent + whitespace.length > margin) { + comments.push(whitespace.slice(margin - indent - 1)); + } + indent += whitespace.length; + break; + case SyntaxKind.EndOfFileToken: + break; + default: + pushComment(scanner.getTokenText()); + break; + } + if (advanceToken) { nextJSDocToken(); } + else { + advanceToken = true; + } + } + removeLeadingNewlines(comments); + removeTrailingNewlines(comments); + result = createJSDocComment(); - result = createJSDocComment(); - - }); - } + }); return result; - function createJSDocComment(): JSDocComment { - if (!tags) { - return undefined; + function removeLeadingNewlines(comments: string[]) { + while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { + comments.shift(); } + } - const result = createNode(SyntaxKind.JSDocComment, start); + function removeTrailingNewlines(comments: string[]) { + while (comments.length && (comments[comments.length - 1] === "\n" || comments[comments.length - 1] === "\r")) { + comments.pop(); + } + } + + function isJsDocStart(content: string, start: number) { + return content.charCodeAt(start) === CharacterCodes.slash && + content.charCodeAt(start + 1) === CharacterCodes.asterisk && + content.charCodeAt(start + 2) === CharacterCodes.asterisk && + content.charCodeAt(start + 3) !== CharacterCodes.asterisk; + } + + function createJSDocComment(): JSDoc { + const result = createNode(SyntaxKind.JSDocComment, start); result.tags = tags; + result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -6254,78 +6302,154 @@ namespace ts { } } - function parseTag(): void { + function parseTag(indent: number) { Debug.assert(token() === SyntaxKind.AtToken); const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); const tagName = parseJSDocIdentifierName(); + skipWhitespace(); if (!tagName) { return; } - const tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - - function handleTag(atToken: Node, tagName: Identifier): JSDocTag { + let tag: JSDocTag; if (tagName) { switch (tagName.text) { case "param": - return handleParamTag(atToken, tagName); + tag = parseParamTag(atToken, tagName); + break; case "return": case "returns": - return handleReturnTag(atToken, tagName); + tag = parseReturnTag(atToken, tagName); + break; case "template": - return handleTemplateTag(atToken, tagName); + tag = parseTemplateTag(atToken, tagName); + break; case "type": - return handleTypeTag(atToken, tagName); + tag = parseTypeTag(atToken, tagName); + break; case "typedef": - return handleTypedefTag(atToken, tagName); + tag = parseTypedefTag(atToken, tagName); + break; + default: + tag = parseUnknownTag(atToken, tagName); + break; } } + else { + tag = parseUnknownTag(atToken, tagName); + } - return undefined; + if (!tag) { + // a badly malformed tag should not be added to the list of tags + return; + } + addTag(tag, parseTagComments(indent + tag.end - tag.pos)); } - function handleUnknownTag(atToken: Node, tagName: Identifier) { + function parseTagComments(indent: number) { + const comments: string[] = []; + let state = JSDocState.SawAsterisk; + let margin: number | undefined; + function pushComment(text: string) { + if (!margin) { + margin = indent; + } + comments.push(text); + indent += text.length; + } + while (token() !== SyntaxKind.AtToken && token() !== SyntaxKind.EndOfFileToken) { + switch (token()) { + case SyntaxKind.NewLineTrivia: + if (state >= JSDocState.SawAsterisk) { + state = JSDocState.BeginningOfLine; + comments.push(scanner.getTokenText()); + } + indent = 0; + break; + case SyntaxKind.AtToken: + // Done + break; + case SyntaxKind.WhitespaceTrivia: + if (state === JSDocState.SavingComments) { + pushComment(scanner.getTokenText()); + } + else { + const whitespace = scanner.getTokenText(); + // if the whitespace crosses the margin, take only the whitespace that passes the margin + if (margin !== undefined && indent + whitespace.length > margin) { + comments.push(whitespace.slice(margin - indent - 1)); + } + indent += whitespace.length; + } + break; + case SyntaxKind.AsteriskToken: + if (state === JSDocState.BeginningOfLine) { + // leading asterisks start recording on the *next* (non-whitespace) token + state = JSDocState.SawAsterisk; + indent += scanner.getTokenText().length; + break; + } + // FALLTHROUGH otherwise to record the * as a comment + default: + state = JSDocState.SavingComments; // leading identifiers start recording as well + pushComment(scanner.getTokenText()); + break; + } + if (token() === SyntaxKind.AtToken) { + // Done + break; + } + nextJSDocToken(); + } + + removeLeadingNewlines(comments); + removeTrailingNewlines(comments); + return comments; + } + + function parseUnknownTag(atToken: Node, tagName: Identifier) { const result = createNode(SyntaxKind.JSDocTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); } - function addTag(tag: JSDocTag): void { - if (tag) { - if (!tags) { - tags = createNodeArray([tag], tag.pos); - } - else { - tags.push(tag); - } - tags.end = tag.end; + function addTag(tag: JSDocTag, comments: string[]): void { + tag.comment = comments.join(""); + + if (!tags) { + tags = createNodeArray([tag], tag.pos); } + else { + tags.push(tag); + } + tags.end = tag.end; } function tryParseTypeExpression(): JSDocTypeExpression { - if (token() !== SyntaxKind.OpenBraceToken) { - return undefined; - } + return tryParse(() => { + skipWhitespace(); + if (token() !== SyntaxKind.OpenBraceToken) { + return undefined; + } - const typeExpression = parseJSDocTypeExpression(); - return typeExpression; + return parseJSDocTypeExpression(); + }); } - function handleParamTag(atToken: Node, tagName: Identifier) { + function parseParamTag(atToken: Node, tagName: Identifier) { let typeExpression = tryParseTypeExpression(); - skipWhitespace(); + let name: Identifier; let isBracketed: boolean; // Looking for something like '[foo]' or 'foo' if (parseOptionalToken(SyntaxKind.OpenBracketToken)) { name = parseJSDocIdentifierName(); + skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' @@ -6362,11 +6486,12 @@ namespace ts { result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; + result.parameterName = postName || preName; result.isBracketed = isBracketed; return finishNode(result); } - function handleReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag { + function parseReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6378,7 +6503,7 @@ namespace ts { return finishNode(result); } - function handleTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag { + function parseTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6390,10 +6515,11 @@ namespace ts { return finishNode(result); } - function handlePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag { + function parsePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); const name = parseJSDocIdentifierName(); + skipWhitespace(); if (!name) { parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, Diagnostics.Identifier_expected); return undefined; @@ -6407,7 +6533,7 @@ namespace ts { return finishNode(result); } - function handleTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag { + function parseTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); @@ -6416,6 +6542,7 @@ namespace ts { typedefTag.tagName = tagName; typedefTag.name = parseJSDocIdentifierName(); typedefTag.typeExpression = typeExpression; + skipWhitespace(); if (typeExpression) { if (typeExpression.type.kind === SyntaxKind.JSDocTypeReference) { @@ -6485,6 +6612,7 @@ namespace ts { nextJSDocToken(); const tagName = parseJSDocIdentifierName(); + skipWhitespace(); if (!tagName) { return false; } @@ -6495,21 +6623,21 @@ namespace ts { // already has a @type tag, terminate the parent tag now. return false; } - parentTag.jsDocTypeTag = handleTypeTag(atToken, tagName); + parentTag.jsDocTypeTag = parseTypeTag(atToken, tagName); return true; case "prop": case "property": if (!parentTag.jsDocPropertyTags) { parentTag.jsDocPropertyTags = >[]; } - const propertyTag = handlePropertyTag(atToken, tagName); + const propertyTag = parsePropertyTag(atToken, tagName); parentTag.jsDocPropertyTags.push(propertyTag); return true; } return false; } - function handleTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag { + function parseTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6519,6 +6647,7 @@ namespace ts { while (true) { const name = parseJSDocIdentifierName(); + skipWhitespace(); if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected); return undefined; @@ -6532,6 +6661,7 @@ namespace ts { if (token() === SyntaxKind.CommaToken) { nextJSDocToken(); + skipWhitespace(); } else { break; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index bfc9591baa7..e7b3872f2e3 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1759,40 +1759,46 @@ namespace ts { } startPos = pos; - - // Eat leading whitespace - let ch = text.charCodeAt(pos); - while (pos < end) { - ch = text.charCodeAt(pos); - if (isWhiteSpaceSingleLine(ch)) { - pos++; - } - else { - break; - } - } tokenPos = pos; + const ch = text.charCodeAt(pos); switch (ch) { + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = SyntaxKind.WhitespaceTrivia; case CharacterCodes.at: - return pos += 1, token = SyntaxKind.AtToken; + pos++; + return token = SyntaxKind.AtToken; case CharacterCodes.lineFeed: case CharacterCodes.carriageReturn: - return pos += 1, token = SyntaxKind.NewLineTrivia; + pos++; + return token = SyntaxKind.NewLineTrivia; case CharacterCodes.asterisk: - return pos += 1, token = SyntaxKind.AsteriskToken; + pos++; + return token = SyntaxKind.AsteriskToken; case CharacterCodes.openBrace: - return pos += 1, token = SyntaxKind.OpenBraceToken; + pos++; + return token = SyntaxKind.OpenBraceToken; case CharacterCodes.closeBrace: - return pos += 1, token = SyntaxKind.CloseBraceToken; + pos++; + return token = SyntaxKind.CloseBraceToken; case CharacterCodes.openBracket: - return pos += 1, token = SyntaxKind.OpenBracketToken; + pos++; + return token = SyntaxKind.OpenBracketToken; case CharacterCodes.closeBracket: - return pos += 1, token = SyntaxKind.CloseBracketToken; + pos++; + return token = SyntaxKind.CloseBracketToken; case CharacterCodes.equals: - return pos += 1, token = SyntaxKind.EqualsToken; + pos++; + return token = SyntaxKind.EqualsToken; case CharacterCodes.comma: - return pos += 1, token = SyntaxKind.CommaToken; + pos++; + return token = SyntaxKind.CommaToken; } if (isIdentifierStart(ch, ScriptTarget.Latest)) { diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index da7bf32f801..9abd91b47c8 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -804,17 +804,17 @@ namespace ts { * Adds a trailing VariableStatement for an enum or module declaration. */ function addVarForExportedEnumOrNamespaceDeclaration(statements: Statement[], node: EnumDeclaration | ModuleDeclaration) { - statements.push( - createVariableStatement( - /*modifiers*/ undefined, - [createVariableDeclaration( - getDeclarationName(node), + const transformedStatement = createVariableStatement( + /*modifiers*/ undefined, + [createVariableDeclaration( + getDeclarationName(node), /*type*/ undefined, - createPropertyAccess(createIdentifier("exports"), getDeclarationName(node)) - )], + createPropertyAccess(createIdentifier("exports"), getDeclarationName(node)) + )], /*location*/ node - ) ); + setNodeEmitFlags(transformedStatement, NodeEmitFlags.NoComments); + statements.push(transformedStatement); } function getDeclarationName(node: DeclarationStatement) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index e0765ed7025..d41a32d92c7 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -694,19 +694,21 @@ namespace ts { // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. + const transformedClassExpression = createVariableStatement( + /*modifiers*/ undefined, + createLetDeclarationList([ + createVariableDeclaration( + classAlias || declaredName, + /*type*/ undefined, + classExpression + ) + ]), + /*location*/ location + ); + setCommentRange(transformedClassExpression, node); statements.push( setOriginalNode( - createVariableStatement( - /*modifiers*/ undefined, - createLetDeclarationList([ - createVariableDeclaration( - classAlias || declaredName, - /*type*/ undefined, - classExpression - ) - ]), - /*location*/ location - ), + /*node*/ transformedClassExpression, /*original*/ node ) ); @@ -2859,7 +2861,6 @@ namespace ts { const moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = moveRangePos(moduleBlock.statements, -1); } - addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; @@ -2872,6 +2873,30 @@ namespace ts { /*location*/ blockLocation, /*multiLine*/ true ); + + // namespace hello.hi.world { + // function foo() {} + // + // // TODO, blah + // } + // + // should be emitted as + // + // var hello; + // (function (hello) { + // var hi; + // (function (hi) { + // var world; + // (function (world) { + // function foo() { } + // // TODO, blah + // })(world = hi.world || (hi.world = {})); + // })(hi = hello.hi || (hello.hi = {})); + // })(hello || (hello = {})); + // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. + if (body.kind !== SyntaxKind.ModuleBlock) { + setNodeEmitFlags(block, block.emitFlags | NodeEmitFlags.NoComments); + } return block; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 82844980ca7..e4bc9a29d5b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -487,7 +487,7 @@ namespace ts { parent?: Node; // Parent node (initialized by binding) /* @internal */ original?: Node; // The original node if this is an updated node. /* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms). - /* @internal */ jsDocComments?: JSDocComment[]; // JSDoc for the node, if it has any. Only for .js files. + /* @internal */ jsDocComments?: JSDoc[]; // JSDoc for the node, if it has any. /* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding) /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) @@ -1555,7 +1555,7 @@ namespace ts { // @kind(SyntaxKind.JSDocRecordType) export interface JSDocRecordType extends JSDocType, TypeLiteralNode { - members: NodeArray; + literal: TypeLiteralNode; } // @kind(SyntaxKind.JSDocTypeReference) @@ -1603,14 +1603,16 @@ namespace ts { } // @kind(SyntaxKind.JSDocComment) - export interface JSDocComment extends Node { - tags: NodeArray; + export interface JSDoc extends Node { + tags: NodeArray | undefined; + comment: string | undefined; } // @kind(SyntaxKind.JSDocTag) export interface JSDocTag extends Node { atToken: Node; tagName: Identifier; + comment: string | undefined; } // @kind(SyntaxKind.JSDocTemplateTag) @@ -1649,9 +1651,13 @@ namespace ts { // @kind(SyntaxKind.JSDocParameterTag) export interface JSDocParameterTag extends JSDocTag { + /** the parameter name, if provided *before* the type (TypeScript-style) */ preParameterName?: Identifier; typeExpression?: JSDocTypeExpression; + /** the parameter name, if provided *after* the type (JSDoc-standard) */ postParameterName?: Identifier; + /** the parameter name, regardless of the location it was provided */ + parameterName: Identifier; isBracketed: boolean; } @@ -2138,7 +2144,7 @@ namespace ts { writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8915bc6a891..43ac7b0c9e0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1426,39 +1426,75 @@ namespace ts { return undefined; } - const jsDocComments = getJSDocComments(node, checkParentVariableStatement); - if (!jsDocComments) { + const jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { return undefined; } - for (const jsDocComment of jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === kind) { - return tag; - } + for (const tag of jsDocTags) { + if (tag.kind === kind) { + return tag; } } } - function getJSDocComments(node: Node, checkParentVariableStatement: boolean): JSDocComment[] { - if (node.jsDocComments) { - return node.jsDocComments; + function append(previous: T[] | undefined, additional: T[] | undefined): T[] | undefined { + if (additional) { + if (!previous) { + previous = []; + } + for (const x of additional) { + previous.push(x); + } } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (checkParentVariableStatement) { - const isInitializerOfVariableDeclarationInStatement = - node.parent.kind === SyntaxKind.VariableDeclaration && - (node.parent).initializer === node && - node.parent.parent.parent.kind === SyntaxKind.VariableStatement; + return previous; + } - const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + export function getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[] { + return getJSDocs(node, checkParentVariableStatement, docs => map(docs, doc => doc.comment), tags => map(tags, tag => tag.comment)); + } + + function getJSDocTags(node: Node, checkParentVariableStatement: boolean): JSDocTag[] { + return getJSDocs(node, checkParentVariableStatement, docs => { + const result: JSDocTag[] = []; + for (const doc of docs) { + if (doc.tags) { + result.push(...doc.tags); + } + } + return result; + }, tags => tags); + } + + function getJSDocs(node: Node, checkParentVariableStatement: boolean, getDocs: (docs: JSDoc[]) => T[], getTags: (tags: JSDocTag[]) => T[]): T[] { + // TODO: Get rid of getJsDocComments and friends (note the lowercase 's' in Js) + // TODO: A lot of this work should be cached, maybe. I guess it's only used in services right now... + let result: T[] = undefined; + // prepend documentation from parent sources + if (checkParentVariableStatement) { + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + const isInitializerOfVariableDeclarationInStatement = + isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === SyntaxKind.VariableStatement; + const isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === SyntaxKind.VariableStatement; + + const variableStatementNode = + isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : + isVariableOfVariableDeclarationStatement ? node.parent.parent : + undefined; if (variableStatementNode) { - return variableStatementNode.jsDocComments; + result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === SyntaxKind.ModuleDeclaration && + node.parent && node.parent.kind === SyntaxKind.ModuleDeclaration) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression @@ -1469,16 +1505,62 @@ namespace ts { (parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && parent.parent.kind === SyntaxKind.ExpressionStatement; if (isSourceOfAssignmentExpressionStatement) { - return parent.parent.jsDocComments; + result = append(result, getJSDocs(parent.parent, checkParentVariableStatement, getDocs, getTags)); } const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment; if (isPropertyAssignmentExpression) { - return parent.jsDocComments; + result = append(result, getJSDocs(parent, checkParentVariableStatement, getDocs, getTags)); + } + + // Pull parameter comments from declaring function as well + if (node.kind === SyntaxKind.Parameter) { + const paramTags = getJSDocParameterTag(node as ParameterDeclaration, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } } } - return undefined; + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, /*checkParentVariableStatement*/ false, getDocs, getTags)); + } + + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); + } + else { + return getDocs(node.jsDocComments); + } + } + + return result; + } + + function getJSDocParameterTag(param: ParameterDeclaration, checkParentVariableStatement: boolean): JSDocTag[] { + const func = param.parent as FunctionLikeDeclaration; + const tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification + const i = func.parameters.indexOf(param); + const paramTags = filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === SyntaxKind.Identifier) { + const name = (param.name as Identifier).text; + const paramTags = filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && (tag as JSDocParameterTag).parameterName.text === name); + if (paramTags) { + return paramTags; + } + } + else { + // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines + // But multi-line object types aren't supported yet either + return undefined; + } } export function getJSDocTypeTag(node: Node): JSDocTypeTag { @@ -1499,17 +1581,15 @@ namespace ts { // annotation. const parameterName = (parameter.name).text; - const jsDocComments = getJSDocComments(parameter.parent, /*checkParentVariableStatement*/ true); - if (jsDocComments) { - for (const jsDocComment of jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === SyntaxKind.JSDocParameterTag) { - const parameterTag = tag; - const name = parameterTag.preParameterName || parameterTag.postParameterName; - if (name.text === parameterName) { - return parameterTag; - } - } + const jsDocTags = getJSDocTags(parameter.parent, /*checkParentVariableStatement*/ true); + if (!jsDocTags) { + return undefined; + } + for (const tag of jsDocTags) { + if (tag.kind === SyntaxKind.JSDocParameterTag) { + const parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; } } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5fd8194071a..a076812462e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -88,6 +88,10 @@ namespace FourSlash { marker?: Marker; } + interface ImplementationLocationInformation extends ts.ImplementationLocation { + matched?: boolean; + } + export interface TextSpan { start: number; end: number; @@ -1699,6 +1703,17 @@ namespace FourSlash { assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count")); } + public verifyImplementationListIsEmpty(negative: boolean) { + const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + + if (negative) { + assert.isTrue(implementations && implementations.length > 0, "Expected at least one implementation but got 0"); + } + else { + assert.isUndefined(implementations, "Expected implementation list to be empty but implementations returned"); + } + } + public verifyGoToDefinitionName(expectedName: string, expectedContainerName: string) { const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); const actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; @@ -1707,6 +1722,82 @@ namespace FourSlash { assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name")); } + public goToImplementation() { + const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + if (!implementations || !implementations.length) { + this.raiseError("goToImplementation failed - expected to find at least one implementation location but got 0"); + } + if (implementations.length > 1) { + this.raiseError(`goToImplementation failed - more than 1 implementation returned (${implementations.length})`); + } + + const implementation = implementations[0]; + this.openFile(implementation.fileName); + this.currentCaretPosition = implementation.textSpan.start; + } + + public verifyRangesInImplementationList(markerName: string) { + this.goToMarker(markerName); + const implementations: ImplementationLocationInformation[] = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + if (!implementations || !implementations.length) { + this.raiseError("verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0"); + } + + for (let i = 0; i < implementations.length; i++) { + for (let j = 0; j < implementations.length; j++) { + if (i !== j && implementationsAreEqual(implementations[i], implementations[j])) { + const { textSpan, fileName } = implementations[i]; + const end = textSpan.start + textSpan.length; + this.raiseError(`Duplicate implementations returned for range (${textSpan.start}, ${end}) in ${fileName}`); + } + } + } + + const ranges = this.getRanges(); + + if (!ranges || !ranges.length) { + this.raiseError("verifyRangesInImplementationList failed - expected to find at least one range in test source"); + } + + const unsatisfiedRanges: Range[] = []; + + for (const range of ranges) { + const length = range.end - range.start; + const matchingImpl = ts.find(implementations, impl => + range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length); + if (matchingImpl) { + matchingImpl.matched = true; + } + else { + unsatisfiedRanges.push(range); + } + } + + const unmatchedImplementations = implementations.filter(impl => !impl.matched); + if (unmatchedImplementations.length || unsatisfiedRanges.length) { + let error = "Not all ranges or implementations are satisfied"; + if (unsatisfiedRanges.length) { + error += "\nUnsatisfied ranges:"; + for (const range of unsatisfiedRanges) { + error += `\n (${range.start}, ${range.end}) in ${range.fileName}: ${this.rangeText(range)}`; + } + } + + if (unmatchedImplementations.length) { + error += "\nUnmatched implementations:"; + for (const impl of unmatchedImplementations) { + const end = impl.textSpan.start + impl.textSpan.length; + error += `\n (${impl.textSpan.start}, ${end}) in ${impl.fileName}: ${this.getFileContent(impl.fileName).slice(impl.textSpan.start, end)}`; + } + } + this.raiseError(error); + } + + function implementationsAreEqual(a: ImplementationLocationInformation, b: ImplementationLocationInformation) { + return a.fileName === b.fileName && TestState.textSpansEqual(a.textSpan, b.textSpan); + } + } + public getMarkers(): Marker[] { // Return a copy of the list return this.testData.markers.slice(0); @@ -2885,6 +2976,10 @@ namespace FourSlashInterface { this.state.goToTypeDefinition(definitionIndex); } + public implementation() { + this.state.goToImplementation(); + } + public position(position: number, fileIndex?: number): void; public position(position: number, fileName?: string): void; public position(position: number, fileNameOrIndex?: any): void { @@ -2985,6 +3080,10 @@ namespace FourSlashInterface { this.state.verifyTypeDefinitionsCount(this.negative, expectedCount); } + public implementationListIsEmpty() { + this.state.verifyImplementationListIsEmpty(this.negative); + } + public isValidBraceCompletionAtPosition(openingBrace: string) { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } @@ -3253,6 +3352,10 @@ namespace FourSlashInterface { public ProjectInfo(expected: string[]) { this.state.verifyProjectInfo(expected); } + + public allRangesAppearInImplementationList(markerName: string) { + this.state.verifyRangesInImplementationList(markerName); + } } export class Edit { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 3518174cc2d..a67f68eb1a9 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -435,6 +435,9 @@ namespace Harness.LanguageService { getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position)); } + getImplementationAtPosition(fileName: string, position: number): ts.ImplementationLocation[] { + return unwrapJSONCallResult(this.shim.getImplementationAtPosition(fileName, position)); + } getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] { return unwrapJSONCallResult(this.shim.getReferencesAtPosition(fileName, position)); } @@ -489,6 +492,9 @@ namespace Harness.LanguageService { getNonBoundSourceFile(fileName: string): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } + getSourceFile(fileName: string): ts.SourceFile { + throw new Error("SourceFile can not be marshaled across the shim layer."); + } dispose(): void { this.shim.dispose({}); } } diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 2de8cff7634..2c935439a9b 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -7,7 +7,7 @@ namespace ts { function parsesCorrectly(name: string, content: string) { it(name, () => { const typeAndDiagnostics = ts.parseJSDocTypeExpressionForTests(content); - assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0); + assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0, "no errors issued"); Harness.Baseline.runBaseline("JSDocParsing/TypeExpressions.parsesCorrectly." + name + ".json", () => Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type)); @@ -36,6 +36,9 @@ namespace ts { parsesCorrectly("recordType6", "{{foo, bar: number}}"); parsesCorrectly("recordType7", "{{foo: number, bar: number}}"); parsesCorrectly("recordType8", "{{function}}"); + parsesCorrectly("trailingCommaInRecordType", "{{a,}}"); + parsesCorrectly("callSignatureInRecordType", "{{(): number}}"); + parsesCorrectly("methodInRecordType", "{{foo(): number}}"); parsesCorrectly("unionType", "{(number|string)}"); parsesCorrectly("topLevelNoParenUnionType", "{number|string}"); parsesCorrectly("functionType1", "{function()}"); @@ -63,7 +66,6 @@ namespace ts { describe("parsesIncorrectly", () => { parsesIncorrectly("emptyType", "{}"); - parsesIncorrectly("trailingCommaInRecordType", "{{a,}}"); parsesIncorrectly("unionTypeWithTrailingBar", "{(a|)}"); parsesIncorrectly("unionTypeWithoutTypes", "{()}"); parsesIncorrectly("nullableTypeWithoutType", "{!}"); @@ -80,8 +82,6 @@ namespace ts { parsesIncorrectly("tsConstructoType", "{new () => string}"); parsesIncorrectly("typeOfType", "{typeof M}"); parsesIncorrectly("namedParameter", "{function(a: number)}"); - parsesIncorrectly("callSignatureInRecordType", "{{(): number}}"); - parsesIncorrectly("methodInRecordType", "{{foo(): number}}"); parsesIncorrectly("tupleTypeWithComma", "{[,]}"); parsesIncorrectly("tupleTypeWithTrailingComma", "{[number,]}"); parsesIncorrectly("tupleTypeWithLeadingComma", "{[,number]}"); @@ -100,7 +100,7 @@ namespace ts { } Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json", - () => JSON.stringify(comment.jsDocComment, + () => JSON.stringify(comment.jsDoc, (k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); }); } @@ -115,7 +115,6 @@ namespace ts { describe("parsesIncorrectly", () => { parsesIncorrectly("emptyComment", "/***/"); parsesIncorrectly("threeAsterisks", "/*** */"); - parsesIncorrectly("asteriskAfterPreamble", "/** * @type {number} */"); parsesIncorrectly("multipleTypes", `/** * @type {number} @@ -167,6 +166,7 @@ namespace ts { * @type {number} */`); + parsesCorrectly("asteriskAfterPreamble", "/** * @type {number} */"); parsesCorrectly("typeTag", `/** diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index bde1c6d5811..6a2c43cd050 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -1,7 +1,7 @@ interface Map { clear(): void; delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; set(key: K, value?: V): this; @@ -15,6 +15,13 @@ interface MapConstructor { } declare var Map: MapConstructor; +interface ReadonlyMap { + forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; + get(key: K): V|undefined; + has(key: K): boolean; + readonly size: number; +} + interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; @@ -33,7 +40,7 @@ interface Set { add(value: T): this; clear(): void; delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; has(value: T): boolean; readonly size: number; } @@ -45,6 +52,12 @@ interface SetConstructor { } declare var Set: SetConstructor; +interface ReadonlySet { + forEach(callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; + has(value: T): boolean; + readonly size: number; +} + interface WeakSet { add(value: T): this; delete(value: T): boolean; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 7550a02b15e..5d570bb0866 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -21,7 +21,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -368,7 +368,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; } interface RegExp { diff --git a/src/lib/es2015.reflect.d.ts b/src/lib/es2015.reflect.d.ts index eda8d352263..2dc92c3bddb 100644 --- a/src/lib/es2015.reflect.d.ts +++ b/src/lib/es2015.reflect.d.ts @@ -6,8 +6,7 @@ declare namespace Reflect { function get(target: any, propertyKey: PropertyKey, receiver?: any): any; function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: string): boolean; - function has(target: any, propertyKey: symbol): boolean; + function has(target: any, propertyKey: PropertyKey): boolean; function isExtensible(target: any): boolean; function ownKeys(target: any): Array; function preventExtensions(target: any): boolean; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 9421b4376e4..ce719668acf 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1576,7 +1576,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1849,7 +1849,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2123,7 +2123,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2396,7 +2396,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2670,7 +2670,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2943,7 +2943,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3216,7 +3216,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3489,7 +3489,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3763,7 +3763,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. diff --git a/src/server/client.ts b/src/server/client.ts index 8391300d468..5032056c2f3 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -368,6 +368,28 @@ namespace ts.server { }); } + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { + const lineOffset = this.positionToOneBasedLineOffset(fileName, position); + const args: protocol.FileLocationRequestArgs = { + file: fileName, + line: lineOffset.line, + offset: lineOffset.offset, + }; + + const request = this.processRequest(CommandNames.Implementation, args); + const response = this.processResponse(request); + + return response.body.map(entry => { + const fileName = entry.file; + const start = this.lineOffsetToPosition(fileName, entry.start); + const end = this.lineOffsetToPosition(fileName, entry.end); + return { + fileName, + textSpan: ts.createTextSpanFromBounds(start, end) + }; + }); + } + findReferences(fileName: string, position: number): ReferencedSymbol[] { // Not yet implemented. return []; @@ -656,6 +678,10 @@ namespace ts.server { throw new Error("SourceFile objects are not serializable through the server protocol."); } + getSourceFile(fileName: string): SourceFile { + throw new Error("SourceFile objects are not serializable through the server protocol."); + } + cleanupSemanticCache(): void { throw new Error("cleanupSemanticCache is not available through the server layer."); } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index f0539064280..ebf43cdbb9e 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -193,6 +193,14 @@ declare namespace ts.server.protocol { export interface TypeDefinitionRequest extends FileLocationRequest { } + /** + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ + export interface ImplementationRequest extends FileLocationRequest { + } + /** * Location in source code expressed as (one-based) line and character offset. */ @@ -240,6 +248,13 @@ declare namespace ts.server.protocol { body?: FileSpan[]; } + /** + * Implementation response message. Gives text range for implementations. + */ + export interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + /** * Get occurrences request; value of command field is * "occurrences". Return response giving spans that are relevant diff --git a/src/server/session.ts b/src/server/session.ts index ff4e9e2d29f..1cf971cf5cf 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -111,6 +111,7 @@ namespace ts.server { export const Formatonkey = "formatonkey"; export const Geterr = "geterr"; export const GeterrForProject = "geterrForProject"; + export const Implementation = "implementation"; export const SemanticDiagnosticsSync = "semanticDiagnosticsSync"; export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar = "navbar"; @@ -363,6 +364,28 @@ namespace ts.server { })); } + private getImplementation(line: number, offset: number, fileName: string): protocol.FileSpan[] { + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); + if (!project || project.languageServiceDiabled) { + throw Errors.NoProject; + } + + const compilerService = project.compilerService; + const implementations = compilerService.languageService.getImplementationAtPosition(file, + compilerService.host.lineOffsetToPosition(file, line, offset)); + + if (!implementations) { + return undefined; + } + + return implementations.map(impl => ({ + file: impl.fileName, + start: compilerService.host.positionToLineOffset(impl.fileName, impl.textSpan.start), + end: compilerService.host.positionToLineOffset(impl.fileName, ts.textSpanEnd(impl.textSpan)) + })); + } + private getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[] { fileName = ts.normalizePath(fileName); const project = this.projectService.getProjectForFile(fileName); @@ -1090,6 +1113,10 @@ namespace ts.server { const defArgs = request.arguments; return { response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, + [CommandNames.Implementation]: (request: protocol.Request) => { + const implArgs = request.arguments; + return { response: this.getImplementation(implArgs.line, implArgs.offset, implArgs.file), responseRequired: true }; + }, [CommandNames.References]: (request: protocol.Request) => { const defArgs = request.arguments; return { response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 0c19fbc74f9..29a878224cd 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -698,9 +698,9 @@ namespace ts { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. const docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { - docCommentAndDiagnostics.jsDocComment.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { + docCommentAndDiagnostics.jsDoc.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; } } @@ -713,37 +713,39 @@ namespace ts { pushClassification(start, width, ClassificationType.comment); } - function classifyJSDocComment(docComment: JSDocComment) { + function classifyJSDocComment(docComment: JSDoc) { let pos = docComment.pos; - for (const tag of docComment.tags) { - // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); + if (docComment.tags) { + for (const tag of docComment.tags) { + // As we walk through each tag, classify the portion of text from the end of + // the last tag (or the start of the entire doc comment) as 'comment'. + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } + + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName); + + pos = tag.tagName.end; + + switch (tag.kind) { + case SyntaxKind.JSDocParameterTag: + processJSDocParameterTag(tag); + break; + case SyntaxKind.JSDocTemplateTag: + processJSDocTemplateTag(tag); + break; + case SyntaxKind.JSDocTypeTag: + processElement((tag).typeExpression); + break; + case SyntaxKind.JSDocReturnTag: + processElement((tag).typeExpression); + break; + } + + pos = tag.end; } - - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName); - - pos = tag.tagName.end; - - switch (tag.kind) { - case SyntaxKind.JSDocParameterTag: - processJSDocParameterTag(tag); - break; - case SyntaxKind.JSDocTemplateTag: - processJSDocTemplateTag(tag); - break; - case SyntaxKind.JSDocTypeTag: - processElement((tag).typeExpression); - break; - case SyntaxKind.JSDocReturnTag: - processElement((tag).typeExpression); - break; - } - - pos = tag.end; } if (pos !== docComment.end) { @@ -982,4 +984,4 @@ namespace ts { } } } -} \ No newline at end of file +} diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 50e257370d3..0f18427e568 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -27,7 +27,7 @@ namespace ts.DocumentHighlights { node.kind === SyntaxKind.StringLiteral || isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false); + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); return convertReferencedSymbols(referencedSymbols); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index d8bb2929268..dcda3e40b1a 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -17,42 +17,45 @@ namespace ts.FindAllReferences { // case SyntaxKind.SuperKeyword: TODO:GH#9268 case SyntaxKind.ConstructorKeyword: case SyntaxKind.StringLiteral: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments); + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/false); } return undefined; } - export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { - // Labels - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - const labelDefinition = getTargetLabel((node.parent), (node).text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] { + if (!implementations) { + // Labels + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + const labelDefinition = getTargetLabel((node.parent), (node).text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); + + if (isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles); } - } - if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - - if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node); + if (node.kind === SyntaxKind.SuperKeyword) { + return getReferencesForSuperKeyword(node); + } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. const symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol && node.kind === SyntaxKind.StringLiteral) { + if (!implementations && !symbol && node.kind === SyntaxKind.StringLiteral) { return getReferencesForStringLiteral(node, sourceFiles); } + // Could not find a symbol e.g. unknown identifier if (!symbol) { // Can't have references to something that we have no symbol for. @@ -356,9 +359,9 @@ namespace ts.FindAllReferences { } /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ function getReferencesInNode(container: Node, searchSymbol: Symbol, searchText: string, @@ -374,6 +377,9 @@ namespace ts.FindAllReferences { const start = findInComments ? container.getFullStart() : container.getStart(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); + const parents = getParentSymbolsOfPropertyAccess(); + const inheritsFromCache: Map = createMap(); + if (possiblePositions.length) { // Build the set of symbols to search for, initially it has only the current symbol const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); @@ -386,8 +392,8 @@ namespace ts.FindAllReferences { // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(sourceFile, position)) || - (findInComments && isInNonReferenceComment(sourceFile, position))) { + if (!implementations && ((findInStrings && isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position)))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like @@ -415,11 +421,10 @@ namespace ts.FindAllReferences { const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword); + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache); if (relatedSymbol) { - const referencedSymbol = getReferencedSymbol(relatedSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment * has two meaning : property name and property value. Therefore when we do findAllReference at the position where @@ -428,8 +433,7 @@ namespace ts.FindAllReferences { * position of property accessing, the referenceEntry of such position will be handled in the first case. */ else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - const referencedSymbol = getReferencedSymbol(shorthandValueSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); @@ -437,9 +441,34 @@ namespace ts.FindAllReferences { } }); } - return; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { + if (implementations) { + const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & TypeFlags.UnionOrIntersection) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + } + } + } + + function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { + return isRightSideOfPropertyAccess(node) && node.parent; + } + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { Debug.assert(isClassLike(searchSymbol.valueDeclaration)); @@ -534,6 +563,200 @@ namespace ts.FindAllReferences { return result[index]; } + + function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { + const references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + + function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[]): void { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === SyntaxKind.Identifier) { + if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + + // Check if the node is within an extends or implements clause + const containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + const containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + const parent = containingTypeReference.parent; + if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === SyntaxKind.Block) { + forEachReturnStatement(parent.body, returnStatement => { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a: ReferenceEntry) { + if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { + result.push(a); + } + } + } + + function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { + for (const componentType of type.types) { + if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + + function getContainingTypeReference(node: Node): Node { + let topLevelTypeReference: Node = undefined; + + while (node) { + if (isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + + return topLevelTypeReference; + } + + function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { + if (node && node.parent) { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent.kind === SyntaxKind.HeritageClause + && isClassLike(node.parent.parent)) { + return node.parent.parent; + } + + else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node: Expression): boolean { + // Unwrap parentheses + if (node.kind === SyntaxKind.ParenthesizedExpression) { + return isImplementationExpression((node).expression); + } + + return node.kind === SyntaxKind.ArrowFunction || + node.kind === SyntaxKind.FunctionExpression || + node.kind === SyntaxKind.ObjectLiteralExpression || + node.kind === SyntaxKind.ClassExpression || + node.kind === SyntaxKind.ArrayLiteralExpression; + } + + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map): boolean { + const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; + return searchHierarchy(child); + + function searchHierarchy(symbol: Symbol): boolean { + if (symbol === parent) { + return true; + } + + const key = getSymbolId(symbol) + "," + getSymbolId(parent); + if (key in cachedResults) { + return cachedResults[key]; + } + + // Set the key so that we don't infinitely recurse + cachedResults[key] = false; + + const inherits = forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + if (parentIsInterface) { + const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (const typeReference of interfaceReferences) { + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (parentIsInterface) { + return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + + cachedResults[key] = inherits; + return inherits; + } + + function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } } function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { @@ -696,6 +919,7 @@ namespace ts.FindAllReferences { } } + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[]): ReferencedSymbol[] { const type = getStringLiteralTypeForNode(node, typeChecker); @@ -821,7 +1045,7 @@ namespace ts.FindAllReferences { } // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); @@ -888,7 +1112,7 @@ namespace ts.FindAllReferences { } } - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean): Symbol | undefined { + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map): Symbol { if (contains(searchSymbols, referenceSymbol)) { // If we are searching for constructor uses, they must be 'new' expressions. return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; @@ -898,7 +1122,7 @@ namespace ts.FindAllReferences { // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor); + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); } // If the reference location is in an object literal, try to get the contextual type for the @@ -941,8 +1165,16 @@ namespace ts.FindAllReferences { } // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache))) { + return undefined; + } + } + const result: Symbol[] = []; getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); @@ -1035,7 +1267,55 @@ namespace ts.FindAllReferences { return referenceEntries; } - function getReferenceEntryFromNode(node: Node): ReferenceEntry { + function isImplementation(node: Node): boolean { + if (!node) { + return false; + } + else if (isVariableLike(node)) { + if (node.initializer) { + return true; + } + else if (node.kind === SyntaxKind.VariableDeclaration) { + const parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient); + } + } + else if (isFunctionLike(node)) { + return !!node.body || hasModifier(node, ModifierFlags.Ambient); + } + else { + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.ModuleDeclaration: + return true; + } + } + return false; + } + + function getParentStatementOfVariableDeclaration(node: VariableDeclaration): VariableStatement { + if (node.parent && node.parent.parent && node.parent.parent.kind === SyntaxKind.VariableStatement) { + Debug.assert(node.parent.kind === SyntaxKind.VariableDeclarationList); + return node.parent.parent; + } + } + + export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void { + const refSymbol = typeChecker.getSymbolAtLocation(node); + const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + + if (shorthandSymbol) { + for (const declaration of shorthandSymbol.getDeclarations()) { + if (getMeaningFromDeclaration(declaration) & SemanticMeaning.Value) { + result.push(getReferenceEntryFromNode(declaration)); + } + } + } + } + + export function getReferenceEntryFromNode(node: Node): ReferenceEntry { let start = node.getStart(); let end = node.getEnd(); diff --git a/src/services/goToImplementation.ts b/src/services/goToImplementation.ts new file mode 100644 index 00000000000..123d29630ad --- /dev/null +++ b/src/services/goToImplementation.ts @@ -0,0 +1,27 @@ +/* @internal */ +namespace ts.GoToImplementation { + export function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[] { + // If invoked directly on a shorthand property assignment, then return + // the declaration of the symbol being assigned (not the symbol being assigned to). + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + const result: ReferenceEntry[] = []; + FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); + return result.length > 0 ? result : undefined; + } + else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) { + // References to and accesses on the super keyword only have one possible implementation, so no + // need to "Find all References" + const symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; + } + else { + // Perform "Find all References" and retrieve only those that are implementations + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, + node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); + const result = flatMap(referencedSymbols, symbol => + map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); + + return result && result.length > 0 ? result : undefined; + } + } +} diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index f40a8013426..feca406359c 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -44,349 +44,47 @@ namespace ts.JsDoc { let jsDocCompletionEntries: CompletionEntry[]; export function getJsDocCommentsFromDeclarations(declarations: Declaration[], name: string, canUseParsedParamTagComments: boolean) { + // Only collect doc comments from duplicate declarations once: + // In case of a union property there might be same declaration multiple times + // which only varies in type parameter + // Eg. const a: Array | Array; a.length + // The property length will have two declarations of property length coming + // from Array - Array and Array const documentationComment = []; - const docComments = getJsDocCommentsSeparatedByNewLines(); - ts.forEach(docComments, docComment => { - if (documentationComment.length) { - documentationComment.push(lineBreakPart()); + forEachUnique(declarations, declaration => { + const comments = getJSDocComments(declaration, /*checkParentVariableStatement*/ true); + if (!comments) { + return; + } + for (const comment of comments) { + if (comment) { + if (documentationComment.length) { + documentationComment.push(lineBreakPart()); + } + documentationComment.push(textPart(comment)); + } } - documentationComment.push(docComment); }); - return documentationComment; + } - function getJsDocCommentsSeparatedByNewLines() { - const paramTag = "@param"; - const jsDocCommentParts: SymbolDisplayPart[] = []; - - ts.forEach(declarations, (declaration, indexOfDeclaration) => { - // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times - // which only varies in type parameter - // Eg. const a: Array | Array; a.length - // The property length will have two declarations of property length coming - // from Array - Array and Array - if (indexOf(declarations, declaration) === indexOfDeclaration) { - const sourceFileOfDeclaration = getSourceFileOfNode(declaration); - // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === SyntaxKind.Parameter) { - if ((declaration.parent.kind === SyntaxKind.FunctionExpression || declaration.parent.kind === SyntaxKind.ArrowFunction) && - declaration.parent.parent.kind === SyntaxKind.VariableDeclaration) { - addCommentParts(declaration.parent.parent.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment); - } - addCommentParts(declaration.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment); - } - - // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).body && (declaration).body.kind === SyntaxKind.ModuleDeclaration) { - return; - } - - if ((declaration.kind === SyntaxKind.FunctionExpression || declaration.kind === SyntaxKind.ArrowFunction) && - declaration.parent.kind === SyntaxKind.VariableDeclaration) { - addCommentParts(declaration.parent.parent, sourceFileOfDeclaration, getCleanedJsDocComment); - } - - // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.parent.kind === SyntaxKind.ModuleDeclaration) { - declaration = declaration.parent; - } - addCommentParts(declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, - sourceFileOfDeclaration, - getCleanedJsDocComment); - - if (declaration.kind === SyntaxKind.VariableDeclaration) { - const init = (declaration as VariableDeclaration).initializer; - if (init && (init.kind === SyntaxKind.FunctionExpression || init.kind === SyntaxKind.ArrowFunction)) { - // Get the cleaned js doc comment text from the initializer - addCommentParts(init, sourceFileOfDeclaration, getCleanedJsDocComment); - } - } - } - }); - - return jsDocCommentParts; - - function addCommentParts(commented: Node, - sourceFileOfDeclaration: SourceFile, - getCommentPart: (pos: number, end: number, file: SourceFile) => SymbolDisplayPart[]): void { - const ranges = getJsDocCommentTextRange(commented, sourceFileOfDeclaration); - // Get the cleaned js doc comment text from the declaration - ts.forEach(ranges, jsDocCommentTextRange => { - const cleanedComment = getCommentPart(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedComment) { - addRange(jsDocCommentParts, cleanedComment); - } - }); - } - - function getJsDocCommentTextRange(node: Node, sourceFile: SourceFile): TextRange[] { - return ts.map(getJsDocComments(node, sourceFile), - jsDocComment => { - return { - pos: jsDocComment.pos + "/*".length, // Consume /* from the comment - end: jsDocComment.end - "*/".length // Trim off comment end indicator - }; - }); - } - - function consumeWhiteSpacesOnTheLine(pos: number, end: number, sourceFile: SourceFile, maxSpacesToRemove?: number) { - if (maxSpacesToRemove !== undefined) { - end = Math.min(end, pos + maxSpacesToRemove); - } - - for (; pos < end; pos++) { - const ch = sourceFile.text.charCodeAt(pos); - if (!isWhiteSpaceSingleLine(ch)) { - return pos; - } - } - - return end; - } - - function consumeLineBreaks(pos: number, end: number, sourceFile: SourceFile) { - while (pos < end && isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos++; - } - - return pos; - } - - function isName(pos: number, end: number, sourceFile: SourceFile, name: string) { - return pos + name.length < end && - sourceFile.text.substr(pos, name.length) === name && - isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)); - } - - function isParamTag(pos: number, end: number, sourceFile: SourceFile) { - // If it is @param tag - return isName(pos, end, sourceFile, paramTag); - } - - function pushDocCommentLineText(docComments: SymbolDisplayPart[], text: string, blankLineCount: number) { - // Add the empty lines in between texts - while (blankLineCount) { - blankLineCount--; - docComments.push(textPart("")); - } - - docComments.push(textPart(text)); - } - - function getCleanedJsDocComment(pos: number, end: number, sourceFile: SourceFile) { - let spacesToRemoveAfterAsterisk: number; - const docComments: SymbolDisplayPart[] = []; - let blankLineCount = 0; - let isInParamTag = false; - - while (pos < end) { - let docCommentTextOfLine = ""; - // First consume leading white space - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); - - // If the comment starts with '*' consume the spaces on this line - if (pos < end && sourceFile.text.charCodeAt(pos) === CharacterCodes.asterisk) { - const lineStartPos = pos + 1; - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); - - // Set the spaces to remove after asterisk as margin if not already set - if (spacesToRemoveAfterAsterisk === undefined && pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) { - spacesToRemoveAfterAsterisk = pos - lineStartPos; - } - } - else if (spacesToRemoveAfterAsterisk === undefined) { - spacesToRemoveAfterAsterisk = 0; - } - - // Analyze text on this line - while (pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) { - const ch = sourceFile.text.charAt(pos); - if (ch === "@") { - // If it is @param tag - if (isParamTag(pos, end, sourceFile)) { - isInParamTag = true; - pos += paramTag.length; - continue; - } - else { - isInParamTag = false; - } - } - - // Add the ch to doc text if we arent in param tag - if (!isInParamTag) { - docCommentTextOfLine += ch; - } - - // Scan next character - pos++; - } - - // Continue with next line - pos = consumeLineBreaks(pos, end, sourceFile); - if (docCommentTextOfLine) { - pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); - blankLineCount = 0; - } - else if (!isInParamTag && docComments.length) { - // This is blank line when there is text already parsed - blankLineCount++; - } - } - - return docComments; - } - - function getCleanedParamJsDocComment(pos: number, end: number, sourceFile: SourceFile) { - let paramHelpStringMargin: number; - const paramDocComments: SymbolDisplayPart[] = []; - while (pos < end) { - if (isParamTag(pos, end, sourceFile)) { - let blankLineCount = 0; - let recordedParamTag = false; - // Consume leading spaces - pos = consumeWhiteSpaces(pos + paramTag.length); - if (pos >= end) { - break; - } - - // Ignore type expression - if (sourceFile.text.charCodeAt(pos) === CharacterCodes.openBrace) { - pos++; - for (let curlies = 1; pos < end; pos++) { - const charCode = sourceFile.text.charCodeAt(pos); - - // { character means we need to find another } to match the found one - if (charCode === CharacterCodes.openBrace) { - curlies++; - continue; - } - - // } char - if (charCode === CharacterCodes.closeBrace) { - curlies--; - if (curlies === 0) { - // We do not have any more } to match the type expression is ignored completely - pos++; - break; - } - else { - // there are more { to be matched with } - continue; - } - } - - // Found start of another tag - if (charCode === CharacterCodes.at) { - break; - } - } - - // Consume white spaces - pos = consumeWhiteSpaces(pos); - if (pos >= end) { - break; - } - } - - // Parameter name - if (isName(pos, end, sourceFile, name)) { - // Found the parameter we are looking for consume white spaces - pos = consumeWhiteSpaces(pos + name.length); - if (pos >= end) { - break; - } - - let paramHelpString = ""; - const firstLineParamHelpStringPos = pos; - while (pos < end) { - const ch = sourceFile.text.charCodeAt(pos); - - // at line break, set this comment line text and go to next line - if (isLineBreak(ch)) { - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - paramHelpString = ""; - blankLineCount = 0; - recordedParamTag = true; - } - else if (recordedParamTag) { - blankLineCount++; - } - - // Get the pos after cleaning start of the line - setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); - continue; - } - - // Done scanning param help string - next tag found - if (ch === CharacterCodes.at) { - break; - } - - paramHelpString += sourceFile.text.charAt(pos); - - // Go to next character - pos++; - } - - // If there is param help text, add it top the doc comments - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - } - paramHelpStringMargin = undefined; - } - - // If this is the start of another tag, continue with the loop in search of param tag with symbol name - if (sourceFile.text.charCodeAt(pos) === CharacterCodes.at) { - continue; - } - } - - // Next character - pos++; - } - - return paramDocComments; - - function consumeWhiteSpaces(pos: number) { - while (pos < end && isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(pos))) { - pos++; - } - - return pos; - } - - function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos: number) { - // Get the pos after consuming line breaks - pos = consumeLineBreaks(pos, end, sourceFile); - if (pos >= end) { - return; - } - - if (paramHelpStringMargin === undefined) { - paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; - } - - // Now consume white spaces max - const startOfLinePos = pos; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); - if (pos >= end) { - return; - } - - const consumedSpaces = pos - startOfLinePos; - if (consumedSpaces < paramHelpStringMargin) { - const ch = sourceFile.text.charCodeAt(pos); - if (ch === CharacterCodes.asterisk) { - // Consume more spaces after asterisk - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); - } + /** + * 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. + */ + function forEachUnique(array: T[], callback: (element: T, index: number) => U): U { + if (array) { + for (let i = 0, len = array.length; i < len; i++) { + if (indexOf(array, array[i]) === i) { + const result = callback(array[i], i); + if (result) { + return result; } } } } + return undefined; } export function getAllJsDocCompletionEntries(): CompletionEntry[] { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index c2a5b745d3a..5c8c47e9666 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -218,15 +218,13 @@ namespace ts.NavigationBar { break; default: - if (node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } + forEach(node.jsDocComments, jsDocComment => { + forEach(jsDocComment.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); } - } - } + }); + }); forEachChild(node, addChildrenRecursively); } diff --git a/src/services/services.ts b/src/services/services.ts index f3e95e94868..ad071723083 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -10,6 +10,7 @@ /// /// /// +/// /// /// /// @@ -42,7 +43,7 @@ namespace ts { public end: number; public flags: NodeFlags; public parent: Node; - public jsDocComments: JSDocComment[]; + public jsDocComments: JSDoc[]; public original: Node; public transformFlags: TransformFlags; public excludeTransformFlags: TransformFlags; @@ -215,7 +216,7 @@ namespace ts { public end: number; public flags: NodeFlags; public parent: Node; - public jsDocComments: JSDocComment[]; + public jsDocComments: JSDoc[]; public __tokenTag: any; constructor(pos: number, end: number) { @@ -1271,6 +1272,13 @@ namespace ts { return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } + /// Goto implementation + function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { + synchronizeHostData(); + return GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, + program.getSourceFiles(), getTouchingPropertyName(getValidSourceFile(fileName), position)); + } + function getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { synchronizeHostData(); return GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); @@ -1393,6 +1401,10 @@ namespace ts { return syntaxTreeCache.getCurrentSourceFile(fileName); } + function getSourceFile(fileName: string): SourceFile { + return getNonBoundSourceFile(fileName); + } + function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -1781,6 +1793,7 @@ namespace ts { getSignatureHelpItems, getQuickInfoAtPosition, getDefinitionAtPosition, + getImplementationAtPosition, getTypeDefinitionAtPosition, getReferencesAtPosition, findReferences, @@ -1803,6 +1816,7 @@ namespace ts { isValidBraceCompletionAtPosition, getEmitOutput, getNonBoundSourceFile, + getSourceFile, getProgram }; } diff --git a/src/services/shims.ts b/src/services/shims.ts index b7de34f53d6..260c80127b5 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -177,6 +177,12 @@ namespace ts { */ getTypeDefinitionAtPosition(fileName: string, position: number): string; + /** + * Returns a JSON-encoded value of the type: + * { fileName: string; textSpan: { start: number; length: number}; }[] + */ + getImplementationAtPosition(fileName: string, position: number): string; + /** * Returns a JSON-encoded value of the type: * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[] @@ -798,6 +804,19 @@ namespace ts { ); } + /// GOTO Implementation + + /** + * Computes the implementation location of the symbol + * at the requested position. + */ + public getImplementationAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + `getImplementationAtPosition('${fileName}', ${position})`, + () => this.languageService.getImplementationAtPosition(fileName, position) + ); + } + public getRenameInfo(fileName: string, position: number): string { return this.forwardJSONCall( `getRenameInfo('${fileName}', ${position})`, diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 59fd0048c82..58312c6f38f 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -49,6 +49,7 @@ "documentRegistry.ts", "findAllReferences.ts", "goToDefinition.ts", + "goToImplementation.ts", "jsDoc.ts", "jsTyping.ts", "navigateTo.ts", diff --git a/src/services/types.ts b/src/services/types.ts index 08501dc8725..e8c411cc1c8 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -209,6 +209,7 @@ namespace ts { getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; findReferences(fileName: string, position: number): ReferencedSymbol[]; @@ -239,6 +240,12 @@ namespace ts { /* @internal */ getNonBoundSourceFile(fileName: string): SourceFile; + /** + * @internal + * @deprecated Use ts.createSourceFile instead. + */ + getSourceFile(fileName: string): SourceFile; + dispose(): void; } @@ -297,6 +304,11 @@ namespace ts { isDefinition: boolean; } + export interface ImplementationLocation { + textSpan: TextSpan; + fileName: string; + } + export interface DocumentHighlights { fileName: string; highlightSpans: HighlightSpan[]; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ba419e4fec0..d1f3a54563f 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -953,9 +953,11 @@ namespace ts { if (node) { if (node.jsDocComments) { for (const jsDocComment of node.jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.pos <= position && position <= tag.end) { - return tag; + if (jsDocComment.tags) { + for (const tag of jsDocComment.tags) { + if (tag.pos <= position && position <= tag.end) { + return tag; + } } } } @@ -1353,4 +1355,4 @@ namespace ts { } return { configJsonObject, diagnostics }; } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.asteriskAfterPreamble.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.asteriskAfterPreamble.json new file mode 100644 index 00000000000..03baac016aa --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.asteriskAfterPreamble.json @@ -0,0 +1,6 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 23, + "comment": "* @type {number} " +} \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.leadingAsterisk.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.leadingAsterisk.json index 3fe305d4106..4ce75d8c3f9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.leadingAsterisk.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.leadingAsterisk.json @@ -27,7 +27,8 @@ "pos": 15, "end": 21 } - } + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noLeadingAsterisk.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noLeadingAsterisk.json index 3fe305d4106..4ce75d8c3f9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noLeadingAsterisk.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noLeadingAsterisk.json @@ -27,7 +27,8 @@ "pos": 15, "end": 21 } - } + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json index 7947de57a58..b37b887624a 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocReturnTag", "pos": 8, - "end": 15, + "end": 16, "atToken": { "kind": "AtToken", "pos": 8, @@ -17,10 +17,11 @@ "pos": 9, "end": 15, "text": "return" - } + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 15 + "end": 16 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noType.json index 7a4b97b1336..53c73cdf7c1 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noType.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTypeTag", "pos": 8, - "end": 13, + "end": 14, "atToken": { "kind": "AtToken", "pos": 8, @@ -17,10 +17,11 @@ "pos": 9, "end": 13, "text": "type" - } + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 13 + "end": 14 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json index 746c4056f83..9d303955ab1 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json @@ -33,7 +33,14 @@ "pos": 24, "end": 29, "text": "name1" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json index ff4bba576d2..1b87d268b93 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json @@ -33,7 +33,14 @@ "pos": 24, "end": 29, "text": "name1" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" + }, + "comment": "Description text follows" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json index 23264572fed..fe01df58851 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json @@ -34,7 +34,14 @@ "end": 30, "text": "name1" }, - "isBracketed": true + "parameterName": { + "kind": "Identifier", + "pos": 25, + "end": 30, + "text": "name1" + }, + "isBracketed": true, + "comment": "Description text follows" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json index ceb123b6b34..f50ce732606 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json @@ -34,7 +34,14 @@ "end": 31, "text": "name1" }, - "isBracketed": true + "parameterName": { + "kind": "Identifier", + "pos": 26, + "end": 31, + "text": "name1" + }, + "isBracketed": true, + "comment": "Description text follows" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json index 19bab08a77b..70f2641fd51 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json @@ -33,7 +33,14 @@ "pos": 22, "end": 28 } - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 20, + "text": "name1" + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json index 5da9084897e..4b720567cc7 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json @@ -33,7 +33,14 @@ "pos": 22, "end": 28 } - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 20, + "text": "name1" + }, + "comment": "Description" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json index 293d2a4c212..d77e80c7512 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json @@ -23,7 +23,14 @@ "pos": 15, "end": 18, "text": "foo" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 18, + "text": "foo" + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag1.json index a8425d833ae..59288030068 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag1.json @@ -27,7 +27,8 @@ "pos": 17, "end": 23 } - } + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag2.json index af4fd91964d..48c72efad36 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnTag2.json @@ -27,7 +27,8 @@ "pos": 17, "end": 23 } - } + }, + "comment": "Description text follows" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnsTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnsTag1.json index ceca9584a2d..12111466f9e 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnsTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.returnsTag1.json @@ -27,7 +27,8 @@ "pos": 18, "end": 24 } - } + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json index 2804a704ba7..8dd2963713e 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 19, + "end": 20, "atToken": { "kind": "AtToken", "pos": 8, @@ -22,7 +22,7 @@ "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -31,12 +31,13 @@ } }, "length": 1, - "pos": 17, - "end": 19 - } + "pos": 18, + "end": 20 + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 19 + "end": 20 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json index a55761a52b7..2f66159c249 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 21, + "end": 22, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 20, - "end": 21, + "end": 22, "name": { "kind": "Identifier", "pos": 20, @@ -42,12 +42,13 @@ } }, "length": 2, - "pos": 17, - "end": 21 - } + "pos": 18, + "end": 22 + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 21 + "end": 22 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json index 64e6e206e11..e5814c387bb 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 22, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -22,7 +22,7 @@ "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 21, - "end": 22, + "end": 23, "name": { "kind": "Identifier", "pos": 21, @@ -42,12 +42,13 @@ } }, "length": 2, - "pos": 17, - "end": 22 - } + "pos": 18, + "end": 23 + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 22 + "end": 23 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json index 64e6e206e11..f29fed31e4c 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 22, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 21, - "end": 22, + "end": 23, "name": { "kind": "Identifier", "pos": 21, @@ -42,12 +42,13 @@ } }, "length": 2, - "pos": 17, - "end": 22 - } + "pos": 18, + "end": 23 + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 22 + "end": 23 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json index 9b5a4a6c790..d3ee964df7a 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 23, + "end": 24, "atToken": { "kind": "AtToken", "pos": 8, @@ -22,7 +22,7 @@ "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 22, - "end": 23, + "end": 24, "name": { "kind": "Identifier", "pos": 22, @@ -42,12 +42,13 @@ } }, "length": 2, - "pos": 17, - "end": 23 - } + "pos": 18, + "end": 24 + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 23 + "end": 24 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag6.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag6.json index d5c1c997b02..98f0de70848 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag6.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag6.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 23, + "end": 24, "atToken": { "kind": "AtToken", "pos": 8, @@ -22,7 +22,7 @@ "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 22, - "end": 23, + "end": 24, "name": { "kind": "Identifier", "pos": 22, @@ -42,12 +42,13 @@ } }, "length": 2, - "pos": 17, - "end": 23 - } + "pos": 18, + "end": 24 + }, + "comment": "Description of type parameters." }, "length": 1, "pos": 8, - "end": 23 + "end": 24 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json index da465077066..16968061afc 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json @@ -33,7 +33,14 @@ "pos": 24, "end": 29, "text": "name1" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" + }, + "comment": "" }, "1": { "kind": "JSDocParameterTag", @@ -65,7 +72,14 @@ "pos": 50, "end": 55, "text": "name2" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 50, + "end": 55, + "text": "name2" + }, + "comment": "" }, "length": 2, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json index c995aa8bf22..8818c3a909e 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json @@ -33,10 +33,56 @@ "pos": 24, "end": 29, "text": "name1" - } + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" + }, + "comment": "" }, - "length": 1, + "1": { + "kind": "JSDocParameterTag", + "pos": 30, + "end": 51, + "atToken": { + "kind": "AtToken", + "pos": 30, + "end": 31 + }, + "tagName": { + "kind": "Identifier", + "pos": 31, + "end": 36, + "text": "param" + }, + "typeExpression": { + "kind": "JSDocTypeExpression", + "pos": 37, + "end": 45, + "type": { + "kind": "NumberKeyword", + "pos": 38, + "end": 44 + } + }, + "postParameterName": { + "kind": "Identifier", + "pos": 46, + "end": 51, + "text": "name2" + }, + "parameterName": { + "kind": "Identifier", + "pos": 46, + "end": 51, + "text": "name2" + }, + "comment": "" + }, + "length": 2, "pos": 8, - "end": 29 + "end": 51 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typeTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typeTag.json index 3fe305d4106..4ce75d8c3f9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typeTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typeTag.json @@ -27,7 +27,8 @@ "pos": 15, "end": 21 } - } + }, + "comment": "" }, "length": 1, "pos": 8, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index 2d6d58d36b2..30ca205587e 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTypedefTag", "pos": 8, - "end": 97, + "end": 98, "atToken": { "kind": "AtToken", "pos": 8, @@ -26,15 +26,15 @@ }, "jsDocTypeLiteral": { "kind": "JSDocTypeLiteral", - "pos": 23, - "end": 97, + "pos": 26, + "end": 98, "jsDocTypeTag": { "kind": "JSDocTypeTag", - "pos": 27, + "pos": 28, "end": 42, "atToken": { "kind": "AtToken", - "pos": 27, + "pos": 28, "end": 29 }, "tagName": { @@ -63,11 +63,11 @@ "jsDocPropertyTags": [ { "kind": "JSDocPropertyTag", - "pos": 46, - "end": 69, + "pos": 47, + "end": 72, "atToken": { "kind": "AtToken", - "pos": 46, + "pos": 47, "end": 48 }, "tagName": { @@ -95,11 +95,11 @@ }, { "kind": "JSDocPropertyTag", - "pos": 73, - "end": 97, + "pos": 74, + "end": 98, "atToken": { "kind": "AtToken", - "pos": 73, + "pos": 74, "end": 75 }, "tagName": { @@ -126,10 +126,11 @@ } } ] - } + }, + "comment": "" }, "length": 1, "pos": 8, - "end": 97 + "end": 98 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.callSignatureInRecordType.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.callSignatureInRecordType.json new file mode 100644 index 00000000000..244c568ae05 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.callSignatureInRecordType.json @@ -0,0 +1,30 @@ +{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 13, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 13, + "members": { + "0": { + "kind": "CallSignature", + "pos": 2, + "end": 12, + "parameters": { + "length": 0, + "pos": 3, + "end": 3 + }, + "type": { + "kind": "NumberKeyword", + "pos": 5, + "end": 12 + } + }, + "length": 1, + "pos": 2, + "end": 12 + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.methodInRecordType.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.methodInRecordType.json new file mode 100644 index 00000000000..fab9a581bd9 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.methodInRecordType.json @@ -0,0 +1,36 @@ +{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 16, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 16, + "members": { + "0": { + "kind": "MethodSignature", + "pos": 2, + "end": 15, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "parameters": { + "length": 0, + "pos": 6, + "end": 6 + }, + "type": { + "kind": "NumberKeyword", + "pos": 8, + "end": 15 + } + }, + "length": 1, + "pos": 2, + "end": 15 + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType1.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType1.json index ab9bb050a89..12be4806629 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType1.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType1.json @@ -2,9 +2,14 @@ "kind": "JSDocRecordType", "pos": 1, "end": 3, - "members": { - "length": 0, - "pos": 2, - "end": 2 + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 3, + "members": { + "length": 0, + "pos": 2, + "end": 2 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType2.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType2.json index 73ff5dbfa60..4bed6d0b918 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType2.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType2.json @@ -2,20 +2,25 @@ "kind": "JSDocRecordType", "pos": 1, "end": 6, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 6, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, "end": 5, - "text": "foo" - } - }, - "length": 1, - "pos": 2, - "end": 5 + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } + }, + "length": 1, + "pos": 2, + "end": 5 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType3.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType3.json index 0ffac6cba8f..565738a6ba9 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType3.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType3.json @@ -2,25 +2,30 @@ "kind": "JSDocRecordType", "pos": 1, "end": 14, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 14, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 13, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "length": 1, - "pos": 2, - "end": 13 + "length": 1, + "pos": 2, + "end": 13 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType4.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType4.json index f49c2fd22ae..74bb20ab30b 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType4.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType4.json @@ -2,31 +2,36 @@ "kind": "JSDocRecordType", "pos": 1, "end": 11, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 11, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 6, - "end": 10, - "name": { - "kind": "Identifier", + "end": 6, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } + }, + "1": { + "kind": "PropertySignature", "pos": 6, "end": 10, - "text": "bar" - } - }, - "length": 2, - "pos": 2, - "end": 10 + "name": { + "kind": "Identifier", + "pos": 6, + "end": 10, + "text": "bar" + } + }, + "length": 2, + "pos": 2, + "end": 10 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType5.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType5.json index 4474dba8e21..b57de3aea3c 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType5.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType5.json @@ -2,36 +2,41 @@ "kind": "JSDocRecordType", "pos": 1, "end": 19, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 19, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 14, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 14, - "end": 18, - "name": { - "kind": "Identifier", + "1": { + "kind": "PropertySignature", "pos": 14, "end": 18, - "text": "bar" - } - }, - "length": 2, - "pos": 2, - "end": 18 + "name": { + "kind": "Identifier", + "pos": 14, + "end": 18, + "text": "bar" + } + }, + "length": 2, + "pos": 2, + "end": 18 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType6.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType6.json index a88005b0cec..6c980da4085 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType6.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType6.json @@ -2,36 +2,41 @@ "kind": "JSDocRecordType", "pos": 1, "end": 19, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 19, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 6, - "end": 18, - "name": { - "kind": "Identifier", - "pos": 6, - "end": 10, - "text": "bar" + "end": 6, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } }, - "type": { - "kind": "NumberKeyword", - "pos": 11, - "end": 18 - } - }, - "length": 2, - "pos": 2, - "end": 18 + "1": { + "kind": "PropertySignature", + "pos": 6, + "end": 18, + "name": { + "kind": "Identifier", + "pos": 6, + "end": 10, + "text": "bar" + }, + "type": { + "kind": "NumberKeyword", + "pos": 11, + "end": 18 + } + }, + "length": 2, + "pos": 2, + "end": 18 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType7.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType7.json index e69f9a74682..fb9f8c055cb 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType7.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType7.json @@ -2,41 +2,46 @@ "kind": "JSDocRecordType", "pos": 1, "end": 27, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 27, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 14, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 14, - "end": 26, - "name": { - "kind": "Identifier", + "1": { + "kind": "PropertySignature", "pos": 14, - "end": 18, - "text": "bar" + "end": 26, + "name": { + "kind": "Identifier", + "pos": 14, + "end": 18, + "text": "bar" + }, + "type": { + "kind": "NumberKeyword", + "pos": 19, + "end": 26 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 19, - "end": 26 - } - }, - "length": 2, - "pos": 2, - "end": 26 + "length": 2, + "pos": 2, + "end": 26 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType8.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType8.json index 35701931097..748b593d235 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType8.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.recordType8.json @@ -2,21 +2,26 @@ "kind": "JSDocRecordType", "pos": 1, "end": 11, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 10, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 11, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, "end": 10, - "originalKeywordKind": "FunctionKeyword", - "text": "function" - } - }, - "length": 1, - "pos": 2, - "end": 10 + "name": { + "kind": "Identifier", + "pos": 2, + "end": 10, + "originalKeywordKind": "FunctionKeyword", + "text": "function" + } + }, + "length": 1, + "pos": 2, + "end": 10 + } } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.trailingCommaInRecordType.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.trailingCommaInRecordType.json new file mode 100644 index 00000000000..1694cf9aa73 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.trailingCommaInRecordType.json @@ -0,0 +1,26 @@ +{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 5, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 5, + "members": { + "0": { + "kind": "PropertySignature", + "pos": 2, + "end": 4, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 3, + "text": "a" + } + }, + "length": 1, + "pos": 2, + "end": 4 + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.js b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.js new file mode 100644 index 00000000000..6f99037a61d --- /dev/null +++ b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.js @@ -0,0 +1,20 @@ +//// [commentInNamespaceDeclarationWithIdentifierPathName.ts] +namespace hello.hi.world +{ + function foo() {} + + // TODO, blah +} + +//// [commentInNamespaceDeclarationWithIdentifierPathName.js] +var hello; +(function (hello) { + var hi; + (function (hi) { + var world; + (function (world) { + function foo() { } + // TODO, blah + })(world = hi.world || (hi.world = {})); + })(hi = hello.hi || (hello.hi = {})); +})(hello || (hello = {})); diff --git a/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.symbols b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.symbols new file mode 100644 index 00000000000..6db54887737 --- /dev/null +++ b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts === +namespace hello.hi.world +>hello : Symbol(hello, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 0)) +>hi : Symbol(hi, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 16)) +>world : Symbol(world, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 19)) +{ + function foo() {} +>foo : Symbol(foo, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 1, 1)) + + // TODO, blah +} diff --git a/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.types b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.types new file mode 100644 index 00000000000..6a5064e2700 --- /dev/null +++ b/tests/baselines/reference/commentInNamespaceDeclarationWithIdentifierPathName.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts === +namespace hello.hi.world +>hello : typeof hello +>hi : typeof hi +>world : typeof world +{ + function foo() {} +>foo : () => void + + // TODO, blah +} diff --git a/tests/baselines/reference/commentOnDecoratedClassDeclaration.js b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js new file mode 100644 index 00000000000..44a7047a2ac --- /dev/null +++ b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js @@ -0,0 +1,47 @@ +//// [commentOnDecoratedClassDeclaration.ts] +declare function decorator(x: string): any; + +/** + * Leading trivia + */ +@decorator("hello") +class Remote { } + +/** + * Floating Comment + */ + +@decorator("hi") +class AnotherRomote { + constructor() {} +} + +//// [commentOnDecoratedClassDeclaration.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +/** + * Leading trivia + */ +var Remote = (function () { + function Remote() { + } + return Remote; +}()); +Remote = __decorate([ + decorator("hello") +], Remote); +/** + * Floating Comment + */ +var AnotherRomote = (function () { + function AnotherRomote() { + } + return AnotherRomote; +}()); +AnotherRomote = __decorate([ + decorator("hi") +], AnotherRomote); diff --git a/tests/baselines/reference/commentOnDecoratedClassDeclaration.symbols b/tests/baselines/reference/commentOnDecoratedClassDeclaration.symbols new file mode 100644 index 00000000000..92a21ce23ba --- /dev/null +++ b/tests/baselines/reference/commentOnDecoratedClassDeclaration.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/commentOnDecoratedClassDeclaration.ts === +declare function decorator(x: string): any; +>decorator : Symbol(decorator, Decl(commentOnDecoratedClassDeclaration.ts, 0, 0)) +>x : Symbol(x, Decl(commentOnDecoratedClassDeclaration.ts, 0, 27)) + +/** + * Leading trivia + */ +@decorator("hello") +>decorator : Symbol(decorator, Decl(commentOnDecoratedClassDeclaration.ts, 0, 0)) + +class Remote { } +>Remote : Symbol(Remote, Decl(commentOnDecoratedClassDeclaration.ts, 0, 43)) + +/** + * Floating Comment + */ + +@decorator("hi") +>decorator : Symbol(decorator, Decl(commentOnDecoratedClassDeclaration.ts, 0, 0)) + +class AnotherRomote { +>AnotherRomote : Symbol(AnotherRomote, Decl(commentOnDecoratedClassDeclaration.ts, 6, 16)) + + constructor() {} +} diff --git a/tests/baselines/reference/commentOnDecoratedClassDeclaration.types b/tests/baselines/reference/commentOnDecoratedClassDeclaration.types new file mode 100644 index 00000000000..170eb674453 --- /dev/null +++ b/tests/baselines/reference/commentOnDecoratedClassDeclaration.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/commentOnDecoratedClassDeclaration.ts === +declare function decorator(x: string): any; +>decorator : (x: string) => any +>x : string + +/** + * Leading trivia + */ +@decorator("hello") +>decorator("hello") : any +>decorator : (x: string) => any +>"hello" : "hello" + +class Remote { } +>Remote : Remote + +/** + * Floating Comment + */ + +@decorator("hi") +>decorator("hi") : any +>decorator : (x: string) => any +>"hi" : "hi" + +class AnotherRomote { +>AnotherRomote : AnotherRomote + + constructor() {} +} diff --git a/tests/baselines/reference/commentOnExportEnumDeclaration.js b/tests/baselines/reference/commentOnExportEnumDeclaration.js new file mode 100644 index 00000000000..6ded51456d8 --- /dev/null +++ b/tests/baselines/reference/commentOnExportEnumDeclaration.js @@ -0,0 +1,19 @@ +//// [commentOnExportEnumDeclaration.ts] +/** + * comment + */ +export enum Color { + r, g, b +} + +//// [commentOnExportEnumDeclaration.js] +"use strict"; +/** + * comment + */ +(function (Color) { + Color[Color["r"] = 0] = "r"; + Color[Color["g"] = 1] = "g"; + Color[Color["b"] = 2] = "b"; +})(exports.Color || (exports.Color = {})); +var Color = exports.Color; diff --git a/tests/baselines/reference/commentOnExportEnumDeclaration.symbols b/tests/baselines/reference/commentOnExportEnumDeclaration.symbols new file mode 100644 index 00000000000..76cb7173703 --- /dev/null +++ b/tests/baselines/reference/commentOnExportEnumDeclaration.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/commentOnExportEnumDeclaration.ts === +/** + * comment + */ +export enum Color { +>Color : Symbol(Color, Decl(commentOnExportEnumDeclaration.ts, 0, 0)) + + r, g, b +>r : Symbol(Color.r, Decl(commentOnExportEnumDeclaration.ts, 3, 19)) +>g : Symbol(Color.g, Decl(commentOnExportEnumDeclaration.ts, 4, 6)) +>b : Symbol(Color.b, Decl(commentOnExportEnumDeclaration.ts, 4, 9)) +} diff --git a/tests/baselines/reference/commentOnExportEnumDeclaration.types b/tests/baselines/reference/commentOnExportEnumDeclaration.types new file mode 100644 index 00000000000..c9f9338bbe2 --- /dev/null +++ b/tests/baselines/reference/commentOnExportEnumDeclaration.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/commentOnExportEnumDeclaration.ts === +/** + * comment + */ +export enum Color { +>Color : Color + + r, g, b +>r : Color.r +>g : Color.g +>b : Color.b +} diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index 166718b9266..3634a322396 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -62,21 +62,21 @@ declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection; >HTMLCollection : HTMLCollection type EventTargetLike = {a: string} | HTMLCollection | NodeList; ->EventTargetLike : EventTargetLike +>EventTargetLike : NodeList | HTMLCollection | { a: string; } >a : string >HTMLCollection : HTMLCollection >NodeList : NodeList var sourceObj: EventTargetLike = undefined; ->sourceObj : EventTargetLike ->EventTargetLike : EventTargetLike +>sourceObj : NodeList | HTMLCollection | { a: string; } +>EventTargetLike : NodeList | HTMLCollection | { a: string; } >undefined : any >undefined : undefined if (isNodeList(sourceObj)) { >isNodeList(sourceObj) : boolean >isNodeList : (sourceObj: any) => sourceObj is NodeList ->sourceObj : EventTargetLike +>sourceObj : NodeList | HTMLCollection | { a: string; } sourceObj.length; >sourceObj.length : number @@ -87,7 +87,7 @@ if (isNodeList(sourceObj)) { if (isHTMLCollection(sourceObj)) { >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection ->sourceObj : EventTargetLike +>sourceObj : NodeList | HTMLCollection | { a: string; } sourceObj.length; >sourceObj.length : number @@ -99,7 +99,7 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >isNodeList(sourceObj) || isHTMLCollection(sourceObj) : boolean >isNodeList(sourceObj) : boolean >isNodeList : (sourceObj: any) => sourceObj is NodeList ->sourceObj : EventTargetLike +>sourceObj : NodeList | HTMLCollection | { a: string; } >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection >sourceObj : HTMLCollection | { a: string; } diff --git a/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.js b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.js new file mode 100644 index 00000000000..4fd9534080f --- /dev/null +++ b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.js @@ -0,0 +1,10 @@ +//// [declarationEmitArrayTypesFromGenericArrayUsage.ts] +interface A extends Array { } + + +//// [declarationEmitArrayTypesFromGenericArrayUsage.js] + + +//// [declarationEmitArrayTypesFromGenericArrayUsage.d.ts] +interface A extends Array { +} diff --git a/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.symbols b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.symbols new file mode 100644 index 00000000000..33c9d38355a --- /dev/null +++ b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts === +interface A extends Array { } +>A : Symbol(A, Decl(declarationEmitArrayTypesFromGenericArrayUsage.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.types b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.types new file mode 100644 index 00000000000..25350552a5f --- /dev/null +++ b/tests/baselines/reference/declarationEmitArrayTypesFromGenericArrayUsage.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts === +interface A extends Array { } +>A : A +>Array : T[] + diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.js b/tests/baselines/reference/declarationEmitBindingPatterns.js similarity index 74% rename from tests/baselines/reference/declarationEmit_bindingPatterns.js rename to tests/baselines/reference/declarationEmitBindingPatterns.js index 8cc52af53b8..c55d885a1ca 100644 --- a/tests/baselines/reference/declarationEmit_bindingPatterns.js +++ b/tests/baselines/reference/declarationEmitBindingPatterns.js @@ -1,4 +1,4 @@ -//// [declarationEmit_bindingPatterns.ts] +//// [declarationEmitBindingPatterns.ts] const k = ({x: z = 'y'}) => { } @@ -6,7 +6,7 @@ var a; function f({} = a, [] = a, { p: {} = a} = a) { } -//// [declarationEmit_bindingPatterns.js] +//// [declarationEmitBindingPatterns.js] var k = function (_a) { var _b = _a.x, z = _b === void 0 ? 'y' : _b; }; @@ -18,7 +18,7 @@ function f(_a, _b, _c) { } -//// [declarationEmit_bindingPatterns.d.ts] +//// [declarationEmitBindingPatterns.d.ts] declare const k: ({x: z}: { x?: string; }) => void; diff --git a/tests/baselines/reference/declarationEmitBindingPatterns.symbols b/tests/baselines/reference/declarationEmitBindingPatterns.symbols new file mode 100644 index 00000000000..705610bf04f --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatterns.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/declarationEmitBindingPatterns.ts === + +const k = ({x: z = 'y'}) => { } +>k : Symbol(k, Decl(declarationEmitBindingPatterns.ts, 1, 5)) +>x : Symbol(x) +>z : Symbol(z, Decl(declarationEmitBindingPatterns.ts, 1, 12)) + +var a; +>a : Symbol(a, Decl(declarationEmitBindingPatterns.ts, 3, 3)) + +function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(declarationEmitBindingPatterns.ts, 3, 6)) +>a : Symbol(a, Decl(declarationEmitBindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmitBindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmitBindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmitBindingPatterns.ts, 3, 3)) +} diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.types b/tests/baselines/reference/declarationEmitBindingPatterns.types similarity index 79% rename from tests/baselines/reference/declarationEmit_bindingPatterns.types rename to tests/baselines/reference/declarationEmitBindingPatterns.types index b3da24a2b95..a0ae3f5aa14 100644 --- a/tests/baselines/reference/declarationEmit_bindingPatterns.types +++ b/tests/baselines/reference/declarationEmitBindingPatterns.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_bindingPatterns.ts === +=== tests/cases/compiler/declarationEmitBindingPatterns.ts === const k = ({x: z = 'y'}) => { } >k : ({x: z}: { x?: string; }) => void diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict.js b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js similarity index 90% rename from tests/baselines/reference/declarationEmit_classMemberNameConflict.js rename to tests/baselines/reference/declarationEmitClassMemberNameConflict.js index 55acb13d2b9..23c83276201 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict.js +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js @@ -1,4 +1,4 @@ -//// [declarationEmit_classMemberNameConflict.ts] +//// [declarationEmitClassMemberNameConflict.ts] export class C1 { C1() { } // has to be the same as the class name @@ -36,7 +36,7 @@ export class C4 { } } -//// [declarationEmit_classMemberNameConflict.js] +//// [declarationEmitClassMemberNameConflict.js] "use strict"; var C1 = (function () { function C1() { @@ -93,7 +93,7 @@ var C4 = (function () { exports.C4 = C4; -//// [declarationEmit_classMemberNameConflict.d.ts] +//// [declarationEmitClassMemberNameConflict.d.ts] export declare class C1 { C1(): void; bar(): (t: typeof C1) => void; diff --git a/tests/baselines/reference/declarationEmitClassMemberNameConflict.symbols b/tests/baselines/reference/declarationEmitClassMemberNameConflict.symbols new file mode 100644 index 00000000000..02ea2f015f3 --- /dev/null +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict.symbols @@ -0,0 +1,70 @@ +=== tests/cases/compiler/declarationEmitClassMemberNameConflict.ts === + +export class C1 { +>C1 : Symbol(C1, Decl(declarationEmitClassMemberNameConflict.ts, 0, 0)) + + C1() { } // has to be the same as the class name +>C1 : Symbol(C1.C1, Decl(declarationEmitClassMemberNameConflict.ts, 1, 17)) + + bar() { +>bar : Symbol(C1.bar, Decl(declarationEmitClassMemberNameConflict.ts, 2, 12)) + + return function (t: typeof C1) { +>t : Symbol(t, Decl(declarationEmitClassMemberNameConflict.ts, 5, 25)) +>C1 : Symbol(C1, Decl(declarationEmitClassMemberNameConflict.ts, 0, 0)) + + }; + } +} + +export class C2 { +>C2 : Symbol(C2, Decl(declarationEmitClassMemberNameConflict.ts, 8, 1)) + + C2: any // has to be the same as the class name +>C2 : Symbol(C2.C2, Decl(declarationEmitClassMemberNameConflict.ts, 10, 17)) + + bar() { +>bar : Symbol(C2.bar, Decl(declarationEmitClassMemberNameConflict.ts, 11, 11)) + + return function (t: typeof C2) { +>t : Symbol(t, Decl(declarationEmitClassMemberNameConflict.ts, 14, 25)) +>C2 : Symbol(C2, Decl(declarationEmitClassMemberNameConflict.ts, 8, 1)) + + }; + } +} + +export class C3 { +>C3 : Symbol(C3, Decl(declarationEmitClassMemberNameConflict.ts, 17, 1)) + + get C3() { return 0; } // has to be the same as the class name +>C3 : Symbol(C3.C3, Decl(declarationEmitClassMemberNameConflict.ts, 19, 17)) + + bar() { +>bar : Symbol(C3.bar, Decl(declarationEmitClassMemberNameConflict.ts, 20, 26)) + + return function (t: typeof C3) { +>t : Symbol(t, Decl(declarationEmitClassMemberNameConflict.ts, 23, 25)) +>C3 : Symbol(C3, Decl(declarationEmitClassMemberNameConflict.ts, 17, 1)) + + }; + } +} + +export class C4 { +>C4 : Symbol(C4, Decl(declarationEmitClassMemberNameConflict.ts, 26, 1)) + + set C4(v) { } // has to be the same as the class name +>C4 : Symbol(C4.C4, Decl(declarationEmitClassMemberNameConflict.ts, 28, 17)) +>v : Symbol(v, Decl(declarationEmitClassMemberNameConflict.ts, 29, 11)) + + bar() { +>bar : Symbol(C4.bar, Decl(declarationEmitClassMemberNameConflict.ts, 29, 17)) + + return function (t: typeof C4) { +>t : Symbol(t, Decl(declarationEmitClassMemberNameConflict.ts, 32, 25)) +>C4 : Symbol(C4, Decl(declarationEmitClassMemberNameConflict.ts, 26, 1)) + + }; + } +} diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict.types b/tests/baselines/reference/declarationEmitClassMemberNameConflict.types similarity index 89% rename from tests/baselines/reference/declarationEmit_classMemberNameConflict.types rename to tests/baselines/reference/declarationEmitClassMemberNameConflict.types index 66bc493b2ee..266942f29c5 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict.types +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_classMemberNameConflict.ts === +=== tests/cases/compiler/declarationEmitClassMemberNameConflict.ts === export class C1 { >C1 : C1 diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.js similarity index 82% rename from tests/baselines/reference/declarationEmit_classMemberNameConflict2.js rename to tests/baselines/reference/declarationEmitClassMemberNameConflict2.js index d3ebddc8d17..233ca0fe138 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.js @@ -1,4 +1,4 @@ -//// [declarationEmit_classMemberNameConflict2.ts] +//// [declarationEmitClassMemberNameConflict2.ts] const Bar = 'bar'; @@ -21,7 +21,7 @@ class Foo { Hello2 = Hello1; } -//// [declarationEmit_classMemberNameConflict2.js] +//// [declarationEmitClassMemberNameConflict2.js] var Bar = 'bar'; var Hello; (function (Hello) { @@ -44,7 +44,7 @@ var Foo = (function () { }()); -//// [declarationEmit_classMemberNameConflict2.d.ts] +//// [declarationEmitClassMemberNameConflict2.d.ts] declare const Bar: "bar"; declare enum Hello { World = 0, diff --git a/tests/baselines/reference/declarationEmitClassMemberNameConflict2.symbols b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.symbols new file mode 100644 index 00000000000..059200c6074 --- /dev/null +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts === + +const Bar = 'bar'; +>Bar : Symbol(Bar, Decl(declarationEmitClassMemberNameConflict2.ts, 1, 5)) + +enum Hello { +>Hello : Symbol(Hello, Decl(declarationEmitClassMemberNameConflict2.ts, 1, 18)) + + World +>World : Symbol(Hello.World, Decl(declarationEmitClassMemberNameConflict2.ts, 3, 12)) +} + +enum Hello1 { +>Hello1 : Symbol(Hello1, Decl(declarationEmitClassMemberNameConflict2.ts, 5, 1)) + + World1 +>World1 : Symbol(Hello1.World1, Decl(declarationEmitClassMemberNameConflict2.ts, 7, 13)) +} + +class Foo { +>Foo : Symbol(Foo, Decl(declarationEmitClassMemberNameConflict2.ts, 9, 1)) + + // Same names + string => OK + Bar = Bar; +>Bar : Symbol(Foo.Bar, Decl(declarationEmitClassMemberNameConflict2.ts, 11, 11)) +>Bar : Symbol(Bar, Decl(declarationEmitClassMemberNameConflict2.ts, 1, 5)) + + // Same names + enum => OK + Hello = Hello; +>Hello : Symbol(Foo.Hello, Decl(declarationEmitClassMemberNameConflict2.ts, 13, 14)) +>Hello : Symbol(Hello, Decl(declarationEmitClassMemberNameConflict2.ts, 1, 18)) + + // Different names + enum => OK + Hello2 = Hello1; +>Hello2 : Symbol(Foo.Hello2, Decl(declarationEmitClassMemberNameConflict2.ts, 16, 18)) +>Hello1 : Symbol(Hello1, Decl(declarationEmitClassMemberNameConflict2.ts, 5, 1)) +} diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types similarity index 80% rename from tests/baselines/reference/declarationEmit_classMemberNameConflict2.types rename to tests/baselines/reference/declarationEmitClassMemberNameConflict2.types index dd184f7ba34..f355a9002c8 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_classMemberNameConflict2.ts === +=== tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts === const Bar = 'bar'; >Bar : "bar" diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.js b/tests/baselines/reference/declarationEmitExportAssignment.js similarity index 84% rename from tests/baselines/reference/declarationEmit_exportAssignment.js rename to tests/baselines/reference/declarationEmitExportAssignment.js index 36f698ec6c7..8c97ef8eb07 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.js +++ b/tests/baselines/reference/declarationEmitExportAssignment.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/declarationEmit_exportAssignment.ts] //// +//// [tests/cases/compiler/declarationEmitExportAssignment.ts] //// //// [utils.ts] diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.symbols b/tests/baselines/reference/declarationEmitExportAssignment.symbols similarity index 100% rename from tests/baselines/reference/declarationEmit_exportAssignment.symbols rename to tests/baselines/reference/declarationEmitExportAssignment.symbols diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.types b/tests/baselines/reference/declarationEmitExportAssignment.types similarity index 100% rename from tests/baselines/reference/declarationEmit_exportAssignment.types rename to tests/baselines/reference/declarationEmitExportAssignment.types diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.js b/tests/baselines/reference/declarationEmitExportDeclaration.js similarity index 85% rename from tests/baselines/reference/declarationEmit_exportDeclaration.js rename to tests/baselines/reference/declarationEmitExportDeclaration.js index 6c6c37bbcfd..dfbed90742d 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.js +++ b/tests/baselines/reference/declarationEmitExportDeclaration.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/declarationEmit_exportDeclaration.ts] //// +//// [tests/cases/compiler/declarationEmitExportDeclaration.ts] //// //// [utils.ts] diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols b/tests/baselines/reference/declarationEmitExportDeclaration.symbols similarity index 100% rename from tests/baselines/reference/declarationEmit_exportDeclaration.symbols rename to tests/baselines/reference/declarationEmitExportDeclaration.symbols diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.types b/tests/baselines/reference/declarationEmitExportDeclaration.types similarity index 100% rename from tests/baselines/reference/declarationEmit_exportDeclaration.types rename to tests/baselines/reference/declarationEmitExportDeclaration.types diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends.js b/tests/baselines/reference/declarationEmitExpressionInExtends.js similarity index 81% rename from tests/baselines/reference/declarationEmit_expressionInExtends.js rename to tests/baselines/reference/declarationEmitExpressionInExtends.js index 9fbb3a4bf63..8973fbb1455 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends.js @@ -1,4 +1,4 @@ -//// [declarationEmit_expressionInExtends.ts] +//// [declarationEmitExpressionInExtends.ts] var x: { new(s: any): Q; @@ -14,7 +14,7 @@ class B extends x { var q: B; q.s; -//// [declarationEmit_expressionInExtends.js] +//// [declarationEmitExpressionInExtends.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; } @@ -38,7 +38,7 @@ var q; q.s; -//// [declarationEmit_expressionInExtends.d.ts] +//// [declarationEmitExpressionInExtends.d.ts] declare var x: { new (s: any): Q; }; diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends.symbols b/tests/baselines/reference/declarationEmitExpressionInExtends.symbols new file mode 100644 index 00000000000..8ae1e2928fd --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpressionInExtends.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/declarationEmitExpressionInExtends.ts === + +var x: { +>x : Symbol(x, Decl(declarationEmitExpressionInExtends.ts, 1, 3)) + + new(s: any): Q; +>T : Symbol(T, Decl(declarationEmitExpressionInExtends.ts, 2, 8)) +>s : Symbol(s, Decl(declarationEmitExpressionInExtends.ts, 2, 11)) +>Q : Symbol(Q, Decl(declarationEmitExpressionInExtends.ts, 3, 1)) +} + +class Q { +>Q : Symbol(Q, Decl(declarationEmitExpressionInExtends.ts, 3, 1)) + + s: string; +>s : Symbol(Q.s, Decl(declarationEmitExpressionInExtends.ts, 5, 9)) +} + +class B extends x { +>B : Symbol(B, Decl(declarationEmitExpressionInExtends.ts, 7, 1)) +>x : Symbol(x, Decl(declarationEmitExpressionInExtends.ts, 1, 3)) +} + +var q: B; +>q : Symbol(q, Decl(declarationEmitExpressionInExtends.ts, 12, 3)) +>B : Symbol(B, Decl(declarationEmitExpressionInExtends.ts, 7, 1)) + +q.s; +>q.s : Symbol(Q.s, Decl(declarationEmitExpressionInExtends.ts, 5, 9)) +>q : Symbol(q, Decl(declarationEmitExpressionInExtends.ts, 12, 3)) +>s : Symbol(Q.s, Decl(declarationEmitExpressionInExtends.ts, 5, 9)) + diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends.types b/tests/baselines/reference/declarationEmitExpressionInExtends.types similarity index 71% rename from tests/baselines/reference/declarationEmit_expressionInExtends.types rename to tests/baselines/reference/declarationEmitExpressionInExtends.types index 2e810fccf68..fdbec3f9c48 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends.types +++ b/tests/baselines/reference/declarationEmitExpressionInExtends.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_expressionInExtends.ts === +=== tests/cases/compiler/declarationEmitExpressionInExtends.ts === var x: { >x : new (s: any) => Q diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends2.js b/tests/baselines/reference/declarationEmitExpressionInExtends2.js similarity index 82% rename from tests/baselines/reference/declarationEmit_expressionInExtends2.js rename to tests/baselines/reference/declarationEmitExpressionInExtends2.js index d74f9361e28..ff75df8baba 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends2.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends2.js @@ -1,4 +1,4 @@ -//// [declarationEmit_expressionInExtends2.ts] +//// [declarationEmitExpressionInExtends2.ts] class C { x: T; @@ -12,7 +12,7 @@ function getClass(c: T) { class MyClass extends getClass(2) { } -//// [declarationEmit_expressionInExtends2.js] +//// [declarationEmitExpressionInExtends2.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; } @@ -36,7 +36,7 @@ var MyClass = (function (_super) { }(getClass(2))); -//// [declarationEmit_expressionInExtends2.d.ts] +//// [declarationEmitExpressionInExtends2.d.ts] declare class C { x: T; y: U; diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends2.symbols b/tests/baselines/reference/declarationEmitExpressionInExtends2.symbols new file mode 100644 index 00000000000..a07590a14c7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpressionInExtends2.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/declarationEmitExpressionInExtends2.ts === + +class C { +>C : Symbol(C, Decl(declarationEmitExpressionInExtends2.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitExpressionInExtends2.ts, 1, 8)) +>U : Symbol(U, Decl(declarationEmitExpressionInExtends2.ts, 1, 10)) + + x: T; +>x : Symbol(C.x, Decl(declarationEmitExpressionInExtends2.ts, 1, 15)) +>T : Symbol(T, Decl(declarationEmitExpressionInExtends2.ts, 1, 8)) + + y: U; +>y : Symbol(C.y, Decl(declarationEmitExpressionInExtends2.ts, 2, 9)) +>U : Symbol(U, Decl(declarationEmitExpressionInExtends2.ts, 1, 10)) +} + +function getClass(c: T) { +>getClass : Symbol(getClass, Decl(declarationEmitExpressionInExtends2.ts, 4, 1)) +>T : Symbol(T, Decl(declarationEmitExpressionInExtends2.ts, 6, 18)) +>c : Symbol(c, Decl(declarationEmitExpressionInExtends2.ts, 6, 21)) +>T : Symbol(T, Decl(declarationEmitExpressionInExtends2.ts, 6, 18)) + + return C; +>C : Symbol(C, Decl(declarationEmitExpressionInExtends2.ts, 0, 0)) +} + +class MyClass extends getClass(2) { +>MyClass : Symbol(MyClass, Decl(declarationEmitExpressionInExtends2.ts, 8, 1)) +>getClass : Symbol(getClass, Decl(declarationEmitExpressionInExtends2.ts, 4, 1)) +} diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends2.types b/tests/baselines/reference/declarationEmitExpressionInExtends2.types similarity index 78% rename from tests/baselines/reference/declarationEmit_expressionInExtends2.types rename to tests/baselines/reference/declarationEmitExpressionInExtends2.types index 3f2b8964a2d..04265e9f74e 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends2.types +++ b/tests/baselines/reference/declarationEmitExpressionInExtends2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_expressionInExtends2.ts === +=== tests/cases/compiler/declarationEmitExpressionInExtends2.ts === class C { >C : C diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends3.errors.txt b/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt similarity index 73% rename from tests/baselines/reference/declarationEmit_expressionInExtends3.errors.txt rename to tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt index 2783810c568..5ed622caafe 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends3.errors.txt +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/declarationEmit_expressionInExtends3.ts(29,30): error TS4020: Extends clause of exported class 'MyClass' has or is using private name 'LocalClass'. -tests/cases/compiler/declarationEmit_expressionInExtends3.ts(37,31): error TS4020: Extends clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. +tests/cases/compiler/declarationEmitExpressionInExtends3.ts(29,30): error TS4020: Extends clause of exported class 'MyClass' has or is using private name 'LocalClass'. +tests/cases/compiler/declarationEmitExpressionInExtends3.ts(37,31): error TS4020: Extends clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. -==== tests/cases/compiler/declarationEmit_expressionInExtends3.ts (2 errors) ==== +==== tests/cases/compiler/declarationEmitExpressionInExtends3.ts (2 errors) ==== export class ExportedClass { x: T; diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends3.js b/tests/baselines/reference/declarationEmitExpressionInExtends3.js similarity index 93% rename from tests/baselines/reference/declarationEmit_expressionInExtends3.js rename to tests/baselines/reference/declarationEmitExpressionInExtends3.js index 5b7754dff64..fc73eb5dbd0 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends3.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.js @@ -1,4 +1,4 @@ -//// [declarationEmit_expressionInExtends3.ts] +//// [declarationEmitExpressionInExtends3.ts] export class ExportedClass { x: T; @@ -43,7 +43,7 @@ export class MyClass4 extends getExportedClass(undefined)foo : Symbol(foo, Decl(declarationEmitInferedDefaultExportType.ts, 2, 16)) + + bar: undefined, +>bar : Symbol(bar, Decl(declarationEmitInferedDefaultExportType.ts, 3, 10)) +>undefined : Symbol(undefined) + + baz: null +>baz : Symbol(baz, Decl(declarationEmitInferedDefaultExportType.ts, 4, 17)) +} diff --git a/tests/baselines/reference/declarationEmit_inferedDefaultExportType.types b/tests/baselines/reference/declarationEmitInferedDefaultExportType.types similarity index 74% rename from tests/baselines/reference/declarationEmit_inferedDefaultExportType.types rename to tests/baselines/reference/declarationEmitInferedDefaultExportType.types index 0f5d0ceed91..5c01d22b32e 100644 --- a/tests/baselines/reference/declarationEmit_inferedDefaultExportType.types +++ b/tests/baselines/reference/declarationEmitInferedDefaultExportType.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_inferedDefaultExportType.ts === +=== tests/cases/compiler/declarationEmitInferedDefaultExportType.ts === // test.ts export default { diff --git a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.js b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.js similarity index 57% rename from tests/baselines/reference/declarationEmit_inferedDefaultExportType2.js rename to tests/baselines/reference/declarationEmitInferedDefaultExportType2.js index 617d4a9966b..a81c7fc0bb7 100644 --- a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.js +++ b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.js @@ -1,4 +1,4 @@ -//// [declarationEmit_inferedDefaultExportType2.ts] +//// [declarationEmitInferedDefaultExportType2.ts] // test.ts export = { @@ -7,7 +7,7 @@ export = { baz: null } -//// [declarationEmit_inferedDefaultExportType2.js] +//// [declarationEmitInferedDefaultExportType2.js] "use strict"; module.exports = { foo: [], @@ -16,7 +16,7 @@ module.exports = { }; -//// [declarationEmit_inferedDefaultExportType2.d.ts] +//// [declarationEmitInferedDefaultExportType2.d.ts] declare var _default: { foo: any[]; bar: any; diff --git a/tests/baselines/reference/declarationEmitInferedDefaultExportType2.symbols b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.symbols new file mode 100644 index 00000000000..7ae974cca05 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/declarationEmitInferedDefaultExportType2.ts === + +// test.ts +export = { + foo: [], +>foo : Symbol(foo, Decl(declarationEmitInferedDefaultExportType2.ts, 2, 10)) + + bar: undefined, +>bar : Symbol(bar, Decl(declarationEmitInferedDefaultExportType2.ts, 3, 10)) +>undefined : Symbol(undefined) + + baz: null +>baz : Symbol(baz, Decl(declarationEmitInferedDefaultExportType2.ts, 4, 17)) +} diff --git a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.types b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.types similarity index 74% rename from tests/baselines/reference/declarationEmit_inferedDefaultExportType2.types rename to tests/baselines/reference/declarationEmitInferedDefaultExportType2.types index 5c8cbbb158c..a334434ea45 100644 --- a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.types +++ b/tests/baselines/reference/declarationEmitInferedDefaultExportType2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_inferedDefaultExportType2.ts === +=== tests/cases/compiler/declarationEmitInferedDefaultExportType2.ts === // test.ts export = { diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias1.js b/tests/baselines/reference/declarationEmitInferedTypeAlias1.js new file mode 100644 index 00000000000..05ce74e3bad --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias1.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias1.ts] //// + +//// [0.ts] + +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +//// [1.ts] +let v = "str" || true; +export { v } + +//// [0.js] +"use strict"; +{ + var obj = true; +} +//// [1.js] +"use strict"; +var v = "str" || true; +exports.v = v; + + +//// [0.d.ts] +export { }; +//// [1.d.ts] +declare let v: string | boolean; +export { v }; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias1.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias1.symbols new file mode 100644 index 00000000000..94599418c5d --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias1.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 1, 1)) + + let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 3, 7)) +>Data : Symbol(Data, Decl(0.ts, 1, 1)) +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : Symbol(v, Decl(1.ts, 0, 3)) + +export { v } +>v : Symbol(v, Decl(1.ts, 1, 8)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias1.types b/tests/baselines/reference/declarationEmitInferedTypeAlias1.types new file mode 100644 index 00000000000..922eb9ccf44 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias1.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : string | boolean + + let obj: Data = true; +>obj : string | boolean +>Data : string | boolean +>true : true +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : string | boolean +>"str" || true : true | "str" +>"str" : "str" +>true : true + +export { v } +>v : string | boolean + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias2.js b/tests/baselines/reference/declarationEmitInferedTypeAlias2.js new file mode 100644 index 00000000000..307a9b82d67 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias2.js @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias2.ts] //// + +//// [0.ts] + +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +//// [1.ts] +let v = "str" || true; +function bar () { + return v; +} +export { v, bar } + +//// [0.js] +"use strict"; +{ + var obj = true; +} +//// [1.js] +"use strict"; +var v = "str" || true; +exports.v = v; +function bar() { + return v; +} +exports.bar = bar; + + +//// [0.d.ts] +export { }; +//// [1.d.ts] +declare let v: string | boolean; +declare function bar(): string | boolean; +export { v, bar }; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias2.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias2.symbols new file mode 100644 index 00000000000..c8027397869 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias2.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 1, 1)) + + let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 3, 7)) +>Data : Symbol(Data, Decl(0.ts, 1, 1)) +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : Symbol(v, Decl(1.ts, 0, 3)) + +function bar () { +>bar : Symbol(bar, Decl(1.ts, 0, 22)) + + return v; +>v : Symbol(v, Decl(1.ts, 0, 3)) +} +export { v, bar } +>v : Symbol(v, Decl(1.ts, 4, 8)) +>bar : Symbol(bar, Decl(1.ts, 4, 11)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias2.types b/tests/baselines/reference/declarationEmitInferedTypeAlias2.types new file mode 100644 index 00000000000..6a9ace4eb86 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias2.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : string | boolean + + let obj: Data = true; +>obj : string | boolean +>Data : string | boolean +>true : true +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : string | boolean +>"str" || true : true | "str" +>"str" : "str" +>true : true + +function bar () { +>bar : () => string | boolean + + return v; +>v : string | boolean +} +export { v, bar } +>v : string | boolean +>bar : () => string | boolean + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias3.js b/tests/baselines/reference/declarationEmitInferedTypeAlias3.js new file mode 100644 index 00000000000..c99e5c429dd --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias3.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias3.ts] //// + +//// [0.ts] + +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +//// [1.ts] +var x = "hi" || 5; +export default x; + +//// [0.js] +"use strict"; +{ + var obj = true; +} +//// [1.js] +"use strict"; +var x = "hi" || 5; +exports.__esModule = true; +exports["default"] = x; + + +//// [0.d.ts] +export { }; +//// [1.d.ts] +declare var x: string | number; +export default x; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias3.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias3.symbols new file mode 100644 index 00000000000..8a9f7b35d18 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias3.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 1, 1)) + + let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 3, 7)) +>Data : Symbol(Data, Decl(0.ts, 1, 1)) +} +export { } + +=== tests/cases/compiler/1.ts === +var x = "hi" || 5; +>x : Symbol(x, Decl(1.ts, 0, 3)) + +export default x; +>x : Symbol(x, Decl(1.ts, 0, 3)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias3.types b/tests/baselines/reference/declarationEmitInferedTypeAlias3.types new file mode 100644 index 00000000000..565a484a094 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias3.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : string | boolean + + let obj: Data = true; +>obj : string | boolean +>Data : string | boolean +>true : true +} +export { } + +=== tests/cases/compiler/1.ts === +var x = "hi" || 5; +>x : string | number +>"hi" || 5 : "hi" | 5 +>"hi" : "hi" +>5 : 5 + +export default x; +>x : string | number + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias4.js b/tests/baselines/reference/declarationEmitInferedTypeAlias4.js new file mode 100644 index 00000000000..8d7ef72012c --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias4.js @@ -0,0 +1,19 @@ +//// [declarationEmitInferedTypeAlias4.ts] + +function f() { + type Foo = T | { x: Foo }; + var x: Foo; + return x; +} + +//// [declarationEmitInferedTypeAlias4.js] +function f() { + var x; + return x; +} + + +//// [declarationEmitInferedTypeAlias4.d.ts] +declare function f(): A[] | { + x: A[] | any; +}; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias4.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias4.symbols new file mode 100644 index 00000000000..f522eca7d0b --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias4.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias4.ts === + +function f() { +>f : Symbol(f, Decl(declarationEmitInferedTypeAlias4.ts, 0, 0)) +>A : Symbol(A, Decl(declarationEmitInferedTypeAlias4.ts, 1, 11)) + + type Foo = T | { x: Foo }; +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias4.ts, 1, 17)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias4.ts, 2, 13)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias4.ts, 2, 13)) +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias4.ts, 2, 23)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias4.ts, 1, 17)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias4.ts, 2, 13)) + + var x: Foo; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias4.ts, 3, 7)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias4.ts, 1, 17)) +>A : Symbol(A, Decl(declarationEmitInferedTypeAlias4.ts, 1, 11)) + + return x; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias4.ts, 3, 7)) +} diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias4.types b/tests/baselines/reference/declarationEmitInferedTypeAlias4.types new file mode 100644 index 00000000000..f4cc0789f45 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias4.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias4.ts === + +function f() { +>f : () => A[] | { x: A[] | any; } +>A : A + + type Foo = T | { x: Foo }; +>Foo : T | { x: T | any; } +>T : T +>T : T +>x : T | { x: T | any; } +>Foo : T | { x: T | any; } +>T : T + + var x: Foo; +>x : A[] | { x: A[] | any; } +>Foo : T | { x: T | any; } +>A : A + + return x; +>x : A[] | { x: A[] | any; } +} diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias5.js b/tests/baselines/reference/declarationEmitInferedTypeAlias5.js new file mode 100644 index 00000000000..79d28d3d181 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias5.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias5.ts] //// + +//// [0.ts] + +export type Data = string | boolean; +let obj: Data = true; + +//// [1.ts] +import * as Z from "./0" +//let v2: Z.Data; +let v = "str" || true; +export { v } + +//// [0.js] +"use strict"; +var obj = true; +//// [1.js] +"use strict"; +//let v2: Z.Data; +var v = "str" || true; +exports.v = v; + + +//// [0.d.ts] +export declare type Data = string | boolean; +//// [1.d.ts] +import * as Z from "./0"; +declare let v: Z.Data; +export { v }; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias5.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias5.symbols new file mode 100644 index 00000000000..6c06697cfdc --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias5.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/0.ts === + +export type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 0, 0)) + +let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 2, 3)) +>Data : Symbol(Data, Decl(0.ts, 0, 0)) + +=== tests/cases/compiler/1.ts === +import * as Z from "./0" +>Z : Symbol(Z, Decl(1.ts, 0, 6)) + +//let v2: Z.Data; +let v = "str" || true; +>v : Symbol(v, Decl(1.ts, 2, 3)) + +export { v } +>v : Symbol(v, Decl(1.ts, 3, 8)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias5.types b/tests/baselines/reference/declarationEmitInferedTypeAlias5.types new file mode 100644 index 00000000000..21e6b415d2e --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias5.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/0.ts === + +export type Data = string | boolean; +>Data : Data + +let obj: Data = true; +>obj : Data +>Data : Data +>true : true + +=== tests/cases/compiler/1.ts === +import * as Z from "./0" +>Z : typeof Z + +//let v2: Z.Data; +let v = "str" || true; +>v : Z.Data +>"str" || true : true | "str" +>"str" : "str" +>true : true + +export { v } +>v : Z.Data + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias6.js b/tests/baselines/reference/declarationEmitInferedTypeAlias6.js new file mode 100644 index 00000000000..924f73d0ed9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias6.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias6.ts] //// + +//// [0.ts] + +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +//// [1.ts] +let v = "str" || true; +export { v } + +//// [0.js] +"use strict"; +{ + var obj = true; +} +//// [1.js] +"use strict"; +var v = "str" || true; +exports.v = v; + + +//// [0.d.ts] +export { }; +//// [1.d.ts] +declare let v: string | boolean; +export { v }; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias6.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias6.symbols new file mode 100644 index 00000000000..94599418c5d --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias6.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 1, 1)) + + let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 3, 7)) +>Data : Symbol(Data, Decl(0.ts, 1, 1)) +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : Symbol(v, Decl(1.ts, 0, 3)) + +export { v } +>v : Symbol(v, Decl(1.ts, 1, 8)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias6.types b/tests/baselines/reference/declarationEmitInferedTypeAlias6.types new file mode 100644 index 00000000000..922eb9ccf44 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias6.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/0.ts === + +{ + type Data = string | boolean; +>Data : string | boolean + + let obj: Data = true; +>obj : string | boolean +>Data : string | boolean +>true : true +} +export { } + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : string | boolean +>"str" || true : true | "str" +>"str" : "str" +>true : true + +export { v } +>v : string | boolean + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias7.js b/tests/baselines/reference/declarationEmitInferedTypeAlias7.js new file mode 100644 index 00000000000..2fba057fc91 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias7.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/declarationEmitInferedTypeAlias7.ts] //// + +//// [0.ts] + +export type Data = string | boolean; +let obj: Data = true; + +//// [1.ts] +let v = "str" || true; +export { v } + +//// [0.js] +"use strict"; +var obj = true; +//// [1.js] +"use strict"; +var v = "str" || true; +exports.v = v; + + +//// [0.d.ts] +export declare type Data = string | boolean; +//// [1.d.ts] +declare let v: string | boolean; +export { v }; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias7.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias7.symbols new file mode 100644 index 00000000000..8923fd72692 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias7.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/0.ts === + +export type Data = string | boolean; +>Data : Symbol(Data, Decl(0.ts, 0, 0)) + +let obj: Data = true; +>obj : Symbol(obj, Decl(0.ts, 2, 3)) +>Data : Symbol(Data, Decl(0.ts, 0, 0)) + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : Symbol(v, Decl(1.ts, 0, 3)) + +export { v } +>v : Symbol(v, Decl(1.ts, 1, 8)) + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias7.types b/tests/baselines/reference/declarationEmitInferedTypeAlias7.types new file mode 100644 index 00000000000..f4bcaaf5105 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias7.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/0.ts === + +export type Data = string | boolean; +>Data : Data + +let obj: Data = true; +>obj : Data +>Data : Data +>true : true + +=== tests/cases/compiler/1.ts === +let v = "str" || true; +>v : string | boolean +>"str" || true : true | "str" +>"str" : "str" +>true : true + +export { v } +>v : string | boolean + diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias8.js b/tests/baselines/reference/declarationEmitInferedTypeAlias8.js new file mode 100644 index 00000000000..54a8ba37af1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias8.js @@ -0,0 +1,22 @@ +//// [declarationEmitInferedTypeAlias8.ts] + +type Foo = T | { x: Foo }; +var x: Foo; + +function returnSomeGlobalValue() { + return x; +} + +//// [declarationEmitInferedTypeAlias8.js] +var x; +function returnSomeGlobalValue() { + return x; +} + + +//// [declarationEmitInferedTypeAlias8.d.ts] +declare type Foo = T | { + x: Foo; +}; +declare var x: Foo; +declare function returnSomeGlobalValue(): Foo; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias8.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias8.symbols new file mode 100644 index 00000000000..9a0c0974e79 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias8.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias8.ts === + +type Foo = T | { x: Foo }; +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias8.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias8.ts, 1, 9)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias8.ts, 1, 9)) +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias8.ts, 1, 19)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias8.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias8.ts, 1, 9)) + +var x: Foo; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias8.ts, 2, 3)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias8.ts, 0, 0)) + +function returnSomeGlobalValue() { +>returnSomeGlobalValue : Symbol(returnSomeGlobalValue, Decl(declarationEmitInferedTypeAlias8.ts, 2, 21)) + + return x; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias8.ts, 2, 3)) +} diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias8.types b/tests/baselines/reference/declarationEmitInferedTypeAlias8.types new file mode 100644 index 00000000000..9fc0aaf7016 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias8.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias8.ts === + +type Foo = T | { x: Foo }; +>Foo : Foo +>T : T +>T : T +>x : Foo +>Foo : Foo +>T : T + +var x: Foo; +>x : Foo +>Foo : Foo + +function returnSomeGlobalValue() { +>returnSomeGlobalValue : () => Foo + + return x; +>x : Foo +} diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias9.js b/tests/baselines/reference/declarationEmitInferedTypeAlias9.js new file mode 100644 index 00000000000..667acdff49c --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias9.js @@ -0,0 +1,22 @@ +//// [declarationEmitInferedTypeAlias9.ts] + +type Foo = T | { x: Foo }; +var x: Foo; + +export function returnSomeGlobalValue() { + return x; +} + +//// [declarationEmitInferedTypeAlias9.js] +"use strict"; +var x; +function returnSomeGlobalValue() { + return x; +} +exports.returnSomeGlobalValue = returnSomeGlobalValue; + + +//// [declarationEmitInferedTypeAlias9.d.ts] +export declare function returnSomeGlobalValue(): number[] | { + x: number[] | any; +}; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias9.symbols b/tests/baselines/reference/declarationEmitInferedTypeAlias9.symbols new file mode 100644 index 00000000000..5057ef22c0b --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias9.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias9.ts === + +type Foo = T | { x: Foo }; +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias9.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias9.ts, 1, 9)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias9.ts, 1, 9)) +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias9.ts, 1, 19)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias9.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitInferedTypeAlias9.ts, 1, 9)) + +var x: Foo; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias9.ts, 2, 3)) +>Foo : Symbol(Foo, Decl(declarationEmitInferedTypeAlias9.ts, 0, 0)) + +export function returnSomeGlobalValue() { +>returnSomeGlobalValue : Symbol(returnSomeGlobalValue, Decl(declarationEmitInferedTypeAlias9.ts, 2, 21)) + + return x; +>x : Symbol(x, Decl(declarationEmitInferedTypeAlias9.ts, 2, 3)) +} diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias9.types b/tests/baselines/reference/declarationEmitInferedTypeAlias9.types new file mode 100644 index 00000000000..d4f61bf927a --- /dev/null +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias9.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmitInferedTypeAlias9.ts === + +type Foo = T | { x: Foo }; +>Foo : T | { x: T | any; } +>T : T +>T : T +>x : T | { x: T | any; } +>Foo : T | { x: T | any; } +>T : T + +var x: Foo; +>x : number[] | { x: number[] | any; } +>Foo : T | { x: T | any; } + +export function returnSomeGlobalValue() { +>returnSomeGlobalValue : () => number[] | { x: number[] | any; } + + return x; +>x : number[] | { x: number[] | any; } +} diff --git a/tests/baselines/reference/declarationEmitInvalidExport.errors.txt b/tests/baselines/reference/declarationEmitInvalidExport.errors.txt new file mode 100644 index 00000000000..529a6167973 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidExport.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/declarationEmitInvalidExport.ts(3,3): error TS7027: Unreachable code detected. +tests/cases/compiler/declarationEmitInvalidExport.ts(5,30): error TS4081: Exported type alias 'MyClass' has or is using private name 'myClass'. +tests/cases/compiler/declarationEmitInvalidExport.ts(6,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/compiler/declarationEmitInvalidExport.ts (3 errors) ==== + + if (false) { + export var myClass = 0; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + export type MyClass = typeof myClass; + ~~~~~~~ +!!! error TS4081: Exported type alias 'MyClass' has or is using private name 'myClass'. + } + ~ +!!! error TS1128: Declaration or statement expected. + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_invalidExport.js b/tests/baselines/reference/declarationEmitInvalidExport.js similarity index 61% rename from tests/baselines/reference/declarationEmit_invalidExport.js rename to tests/baselines/reference/declarationEmitInvalidExport.js index 74b5bfd8019..18ed73b0a5a 100644 --- a/tests/baselines/reference/declarationEmit_invalidExport.js +++ b/tests/baselines/reference/declarationEmitInvalidExport.js @@ -1,4 +1,4 @@ -//// [declarationEmit_invalidExport.ts] +//// [declarationEmitInvalidExport.ts] if (false) { export var myClass = 0; @@ -7,7 +7,7 @@ export type MyClass = typeof myClass; } -//// [declarationEmit_invalidExport.js] +//// [declarationEmitInvalidExport.js] "use strict"; if (false) { export var myClass = 0; diff --git a/tests/baselines/reference/declarationEmitInvalidReference.js b/tests/baselines/reference/declarationEmitInvalidReference.js new file mode 100644 index 00000000000..e5a8bf5f289 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidReference.js @@ -0,0 +1,11 @@ +//// [declarationEmitInvalidReference.ts] +/// +var x = 0; + +//// [declarationEmitInvalidReference.js] +/// +var x = 0; + + +//// [declarationEmitInvalidReference.d.ts] +declare var x: number; diff --git a/tests/baselines/reference/declarationEmitInvalidReference.symbols b/tests/baselines/reference/declarationEmitInvalidReference.symbols new file mode 100644 index 00000000000..9607e5434ca --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidReference.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declarationEmitInvalidReference.ts === +/// +var x = 0; +>x : Symbol(x, Decl(declarationEmitInvalidReference.ts, 1, 3)) + diff --git a/tests/baselines/reference/declarationEmitInvalidReference.types b/tests/baselines/reference/declarationEmitInvalidReference.types new file mode 100644 index 00000000000..aa2658874bc --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidReference.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/declarationEmitInvalidReference.ts === +/// +var x = 0; +>x : number +>0 : 0 + diff --git a/tests/baselines/reference/declarationEmitInvalidReference2.errors.txt b/tests/baselines/reference/declarationEmitInvalidReference2.errors.txt new file mode 100644 index 00000000000..32423b8d849 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidReference2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/declarationEmitInvalidReference2.ts(1,1): error TS6053: File 'tests/cases/compiler/invalid.ts' not found. + + +==== tests/cases/compiler/declarationEmitInvalidReference2.ts (1 errors) ==== + /// + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6053: File 'tests/cases/compiler/invalid.ts' not found. + var x = 0; \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitInvalidReference2.js b/tests/baselines/reference/declarationEmitInvalidReference2.js new file mode 100644 index 00000000000..e14da1dabb6 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInvalidReference2.js @@ -0,0 +1,11 @@ +//// [declarationEmitInvalidReference2.ts] +/// +var x = 0; + +//// [declarationEmitInvalidReference2.js] +/// +var x = 0; + + +//// [declarationEmitInvalidReference2.d.ts] +declare var x: number; diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.js b/tests/baselines/reference/declarationEmitNameConflicts.js similarity index 94% rename from tests/baselines/reference/declarationEmit_nameConflicts.js rename to tests/baselines/reference/declarationEmitNameConflicts.js index 957a0da472a..2ce92501409 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.js +++ b/tests/baselines/reference/declarationEmitNameConflicts.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/declarationEmit_nameConflicts.ts] //// +//// [tests/cases/compiler/declarationEmitNameConflicts.ts] //// //// [declarationEmit_nameConflicts_1.ts] module f { export class c { } } diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.symbols b/tests/baselines/reference/declarationEmitNameConflicts.symbols similarity index 100% rename from tests/baselines/reference/declarationEmit_nameConflicts.symbols rename to tests/baselines/reference/declarationEmitNameConflicts.symbols diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.types b/tests/baselines/reference/declarationEmitNameConflicts.types similarity index 100% rename from tests/baselines/reference/declarationEmit_nameConflicts.types rename to tests/baselines/reference/declarationEmitNameConflicts.types diff --git a/tests/baselines/reference/declarationEmit_nameConflicts2.js b/tests/baselines/reference/declarationEmitNameConflicts2.js similarity index 90% rename from tests/baselines/reference/declarationEmit_nameConflicts2.js rename to tests/baselines/reference/declarationEmitNameConflicts2.js index b93745c3a12..b7b345979d7 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts2.js +++ b/tests/baselines/reference/declarationEmitNameConflicts2.js @@ -1,4 +1,4 @@ -//// [declarationEmit_nameConflicts2.ts] +//// [declarationEmitNameConflicts2.ts] module X.Y.base { export function f() { } export class C { } @@ -15,7 +15,7 @@ module X.Y.base.Z { export var E = X.Y.base.E; // Should be base.E } -//// [declarationEmit_nameConflicts2.js] +//// [declarationEmitNameConflicts2.js] var X; (function (X) { var Y; @@ -57,7 +57,7 @@ var X; })(X || (X = {})); -//// [declarationEmit_nameConflicts2.d.ts] +//// [declarationEmitNameConflicts2.d.ts] declare module X.Y.base { function f(): void; class C { diff --git a/tests/baselines/reference/declarationEmitNameConflicts2.symbols b/tests/baselines/reference/declarationEmitNameConflicts2.symbols new file mode 100644 index 00000000000..eba4dd0bf4d --- /dev/null +++ b/tests/baselines/reference/declarationEmitNameConflicts2.symbols @@ -0,0 +1,68 @@ +=== tests/cases/compiler/declarationEmitNameConflicts2.ts === +module X.Y.base { +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) + + export function f() { } +>f : Symbol(f, Decl(declarationEmitNameConflicts2.ts, 0, 17)) + + export class C { } +>C : Symbol(C, Decl(declarationEmitNameConflicts2.ts, 1, 27)) + + export module M { +>M : Symbol(M, Decl(declarationEmitNameConflicts2.ts, 2, 22)) + + export var v; +>v : Symbol(v, Decl(declarationEmitNameConflicts2.ts, 4, 18)) + } + export enum E { } +>E : Symbol(E, Decl(declarationEmitNameConflicts2.ts, 5, 5)) +} + +module X.Y.base.Z { +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>Z : Symbol(Z, Decl(declarationEmitNameConflicts2.ts, 9, 16)) + + export var f = X.Y.base.f; // Should be base.f +>f : Symbol(f, Decl(declarationEmitNameConflicts2.ts, 10, 14)) +>X.Y.base.f : Symbol(f, Decl(declarationEmitNameConflicts2.ts, 0, 17)) +>X.Y.base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>X.Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>f : Symbol(f, Decl(declarationEmitNameConflicts2.ts, 0, 17)) + + export var C = X.Y.base.C; // Should be base.C +>C : Symbol(C, Decl(declarationEmitNameConflicts2.ts, 11, 14)) +>X.Y.base.C : Symbol(C, Decl(declarationEmitNameConflicts2.ts, 1, 27)) +>X.Y.base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>X.Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>C : Symbol(C, Decl(declarationEmitNameConflicts2.ts, 1, 27)) + + export var M = X.Y.base.M; // Should be base.M +>M : Symbol(M, Decl(declarationEmitNameConflicts2.ts, 12, 14)) +>X.Y.base.M : Symbol(M, Decl(declarationEmitNameConflicts2.ts, 2, 22)) +>X.Y.base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>X.Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>M : Symbol(M, Decl(declarationEmitNameConflicts2.ts, 2, 22)) + + export var E = X.Y.base.E; // Should be base.E +>E : Symbol(E, Decl(declarationEmitNameConflicts2.ts, 13, 14)) +>X.Y.base.E : Symbol(E, Decl(declarationEmitNameConflicts2.ts, 5, 5)) +>X.Y.base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>X.Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>X : Symbol(X, Decl(declarationEmitNameConflicts2.ts, 0, 0), Decl(declarationEmitNameConflicts2.ts, 7, 1)) +>Y : Symbol(Y, Decl(declarationEmitNameConflicts2.ts, 0, 9), Decl(declarationEmitNameConflicts2.ts, 9, 9)) +>base : Symbol(base, Decl(declarationEmitNameConflicts2.ts, 0, 11), Decl(declarationEmitNameConflicts2.ts, 9, 11)) +>E : Symbol(E, Decl(declarationEmitNameConflicts2.ts, 5, 5)) +} diff --git a/tests/baselines/reference/declarationEmit_nameConflicts2.types b/tests/baselines/reference/declarationEmitNameConflicts2.types similarity index 89% rename from tests/baselines/reference/declarationEmit_nameConflicts2.types rename to tests/baselines/reference/declarationEmitNameConflicts2.types index 026cfed0989..7da15138c16 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts2.types +++ b/tests/baselines/reference/declarationEmitNameConflicts2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_nameConflicts2.ts === +=== tests/cases/compiler/declarationEmitNameConflicts2.ts === module X.Y.base { >X : typeof X >Y : typeof Y diff --git a/tests/baselines/reference/declarationEmit_nameConflicts3.js b/tests/baselines/reference/declarationEmitNameConflicts3.js similarity index 91% rename from tests/baselines/reference/declarationEmit_nameConflicts3.js rename to tests/baselines/reference/declarationEmitNameConflicts3.js index 81236200ade..c17f624087d 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts3.js +++ b/tests/baselines/reference/declarationEmitNameConflicts3.js @@ -1,4 +1,4 @@ -//// [declarationEmit_nameConflicts3.ts] +//// [declarationEmitNameConflicts3.ts] module M { export interface D { } export module D { @@ -26,7 +26,7 @@ module M.P { export var x = M.E.f; // error, should be typeof M.E.f } -//// [declarationEmit_nameConflicts3.js] +//// [declarationEmitNameConflicts3.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; } @@ -81,7 +81,7 @@ var M; })(M || (M = {})); -//// [declarationEmit_nameConflicts3.d.ts] +//// [declarationEmitNameConflicts3.d.ts] declare module M { interface D { } diff --git a/tests/baselines/reference/declarationEmitNameConflicts3.symbols b/tests/baselines/reference/declarationEmitNameConflicts3.symbols new file mode 100644 index 00000000000..b4bd4615da9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNameConflicts3.symbols @@ -0,0 +1,76 @@ +=== tests/cases/compiler/declarationEmitNameConflicts3.ts === +module M { +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) + + export interface D { } +>D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 0, 10), Decl(declarationEmitNameConflicts3.ts, 1, 26)) + + export module D { +>D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 0, 10), Decl(declarationEmitNameConflicts3.ts, 1, 26)) + + export function f() { } +>f : Symbol(f, Decl(declarationEmitNameConflicts3.ts, 2, 21)) + } + export module C { +>C : Symbol(C, Decl(declarationEmitNameConflicts3.ts, 4, 5)) + + export function f() { } +>f : Symbol(f, Decl(declarationEmitNameConflicts3.ts, 5, 21)) + } + export module E { +>E : Symbol(E, Decl(declarationEmitNameConflicts3.ts, 7, 5)) + + export function f() { } +>f : Symbol(f, Decl(declarationEmitNameConflicts3.ts, 8, 21)) + } +} + +module M.P { +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) +>P : Symbol(P, Decl(declarationEmitNameConflicts3.ts, 13, 9)) + + export class C { +>C : Symbol(C, Decl(declarationEmitNameConflicts3.ts, 13, 12)) + + static f() { } +>f : Symbol(C.f, Decl(declarationEmitNameConflicts3.ts, 14, 20)) + } + export class E extends C { } +>E : Symbol(E, Decl(declarationEmitNameConflicts3.ts, 16, 5)) +>C : Symbol(C, Decl(declarationEmitNameConflicts3.ts, 13, 12)) + + export enum D { +>D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 17, 32)) + + f +>f : Symbol(D.f, Decl(declarationEmitNameConflicts3.ts, 18, 19)) + } + export var v: M.D; // ok +>v : Symbol(v, Decl(declarationEmitNameConflicts3.ts, 21, 14)) +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) +>D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 0, 10), Decl(declarationEmitNameConflicts3.ts, 1, 26)) + + export var w = M.D.f; // error, should be typeof M.D.f +>w : Symbol(w, Decl(declarationEmitNameConflicts3.ts, 22, 14)) +>M.D.f : Symbol(M.D.f, Decl(declarationEmitNameConflicts3.ts, 2, 21)) +>M.D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 0, 10), Decl(declarationEmitNameConflicts3.ts, 1, 26)) +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) +>D : Symbol(D, Decl(declarationEmitNameConflicts3.ts, 0, 10), Decl(declarationEmitNameConflicts3.ts, 1, 26)) +>f : Symbol(M.D.f, Decl(declarationEmitNameConflicts3.ts, 2, 21)) + + export var x = M.C.f; // error, should be typeof M.C.f +>x : Symbol(x, Decl(declarationEmitNameConflicts3.ts, 23, 14), Decl(declarationEmitNameConflicts3.ts, 24, 14)) +>M.C.f : Symbol(C.f, Decl(declarationEmitNameConflicts3.ts, 5, 21)) +>M.C : Symbol(C, Decl(declarationEmitNameConflicts3.ts, 4, 5)) +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) +>C : Symbol(C, Decl(declarationEmitNameConflicts3.ts, 4, 5)) +>f : Symbol(C.f, Decl(declarationEmitNameConflicts3.ts, 5, 21)) + + export var x = M.E.f; // error, should be typeof M.E.f +>x : Symbol(x, Decl(declarationEmitNameConflicts3.ts, 23, 14), Decl(declarationEmitNameConflicts3.ts, 24, 14)) +>M.E.f : Symbol(E.f, Decl(declarationEmitNameConflicts3.ts, 8, 21)) +>M.E : Symbol(E, Decl(declarationEmitNameConflicts3.ts, 7, 5)) +>M : Symbol(M, Decl(declarationEmitNameConflicts3.ts, 0, 0), Decl(declarationEmitNameConflicts3.ts, 11, 1)) +>E : Symbol(E, Decl(declarationEmitNameConflicts3.ts, 7, 5)) +>f : Symbol(E.f, Decl(declarationEmitNameConflicts3.ts, 8, 21)) +} diff --git a/tests/baselines/reference/declarationEmit_nameConflicts3.types b/tests/baselines/reference/declarationEmitNameConflicts3.types similarity index 88% rename from tests/baselines/reference/declarationEmit_nameConflicts3.types rename to tests/baselines/reference/declarationEmitNameConflicts3.types index 8d52bda68f5..2443f2c78d7 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts3.types +++ b/tests/baselines/reference/declarationEmitNameConflicts3.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_nameConflicts3.ts === +=== tests/cases/compiler/declarationEmitNameConflicts3.ts === module M { >M : typeof M diff --git a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.js b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js similarity index 72% rename from tests/baselines/reference/declarationEmit_nameConflictsWithAlias.js rename to tests/baselines/reference/declarationEmitNameConflictsWithAlias.js index 0b99d3e1efe..b49e3ad314d 100644 --- a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.js +++ b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js @@ -1,4 +1,4 @@ -//// [declarationEmit_nameConflictsWithAlias.ts] +//// [declarationEmitNameConflictsWithAlias.ts] export module C { export interface I { } } export import v = C; export module M { @@ -6,14 +6,14 @@ export module M { export var w: v.I; // Gets emitted as C.I, which is the wrong interface } -//// [declarationEmit_nameConflictsWithAlias.js] +//// [declarationEmitNameConflictsWithAlias.js] "use strict"; var M; (function (M) { })(M = exports.M || (exports.M = {})); -//// [declarationEmit_nameConflictsWithAlias.d.ts] +//// [declarationEmitNameConflictsWithAlias.d.ts] export declare module C { interface I { } diff --git a/tests/baselines/reference/declarationEmitNameConflictsWithAlias.symbols b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.symbols new file mode 100644 index 00000000000..8690cffaa80 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/declarationEmitNameConflictsWithAlias.ts === +export module C { export interface I { } } +>C : Symbol(C, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 0)) +>I : Symbol(I, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 17)) + +export import v = C; +>v : Symbol(v, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 42)) +>C : Symbol(C, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 0)) + +export module M { +>M : Symbol(M, Decl(declarationEmitNameConflictsWithAlias.ts, 1, 20)) + + export module C { export interface I { } } +>C : Symbol(C, Decl(declarationEmitNameConflictsWithAlias.ts, 2, 17)) +>I : Symbol(I, Decl(declarationEmitNameConflictsWithAlias.ts, 3, 21)) + + export var w: v.I; // Gets emitted as C.I, which is the wrong interface +>w : Symbol(w, Decl(declarationEmitNameConflictsWithAlias.ts, 4, 14)) +>v : Symbol(v, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 42)) +>I : Symbol(v.I, Decl(declarationEmitNameConflictsWithAlias.ts, 0, 17)) +} diff --git a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.types b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.types similarity index 76% rename from tests/baselines/reference/declarationEmit_nameConflictsWithAlias.types rename to tests/baselines/reference/declarationEmitNameConflictsWithAlias.types index 744869f0e3a..f00982eb70c 100644 --- a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.types +++ b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_nameConflictsWithAlias.ts === +=== tests/cases/compiler/declarationEmitNameConflictsWithAlias.ts === export module C { export interface I { } } >C : any >I : I diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.js b/tests/baselines/reference/declarationEmitProtectedMembers.js similarity index 93% rename from tests/baselines/reference/declarationEmit_protectedMembers.js rename to tests/baselines/reference/declarationEmitProtectedMembers.js index e118e164dfc..cc4e27895f1 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.js +++ b/tests/baselines/reference/declarationEmitProtectedMembers.js @@ -1,4 +1,4 @@ -//// [declarationEmit_protectedMembers.ts] +//// [declarationEmitProtectedMembers.ts] // Class with protected members class C1 { @@ -50,7 +50,7 @@ class C4 { constructor(protected a: number, protected b) { } } -//// [declarationEmit_protectedMembers.js] +//// [declarationEmitProtectedMembers.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; } @@ -129,7 +129,7 @@ var C4 = (function () { }()); -//// [declarationEmit_protectedMembers.d.ts] +//// [declarationEmitProtectedMembers.d.ts] declare class C1 { protected x: number; protected f(): number; diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.symbols b/tests/baselines/reference/declarationEmitProtectedMembers.symbols new file mode 100644 index 00000000000..31f1a9a67e4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitProtectedMembers.symbols @@ -0,0 +1,114 @@ +=== tests/cases/compiler/declarationEmitProtectedMembers.ts === + +// Class with protected members +class C1 { +>C1 : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) + + protected x: number; +>x : Symbol(C1.x, Decl(declarationEmitProtectedMembers.ts, 2, 10)) + + protected f() { +>f : Symbol(C1.f, Decl(declarationEmitProtectedMembers.ts, 3, 24)) + + return this.x; +>this.x : Symbol(C1.x, Decl(declarationEmitProtectedMembers.ts, 2, 10)) +>this : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) +>x : Symbol(C1.x, Decl(declarationEmitProtectedMembers.ts, 2, 10)) + } + + protected set accessor(a: number) { } +>accessor : Symbol(C1.accessor, Decl(declarationEmitProtectedMembers.ts, 7, 5), Decl(declarationEmitProtectedMembers.ts, 9, 41)) +>a : Symbol(a, Decl(declarationEmitProtectedMembers.ts, 9, 27)) + + protected get accessor() { return 0; } +>accessor : Symbol(C1.accessor, Decl(declarationEmitProtectedMembers.ts, 7, 5), Decl(declarationEmitProtectedMembers.ts, 9, 41)) + + protected static sx: number; +>sx : Symbol(C1.sx, Decl(declarationEmitProtectedMembers.ts, 10, 42)) + + protected static sf() { +>sf : Symbol(C1.sf, Decl(declarationEmitProtectedMembers.ts, 12, 32)) + + return this.sx; +>this.sx : Symbol(C1.sx, Decl(declarationEmitProtectedMembers.ts, 10, 42)) +>this : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) +>sx : Symbol(C1.sx, Decl(declarationEmitProtectedMembers.ts, 10, 42)) + } + + protected static set staticSetter(a: number) { } +>staticSetter : Symbol(C1.staticSetter, Decl(declarationEmitProtectedMembers.ts, 16, 5)) +>a : Symbol(a, Decl(declarationEmitProtectedMembers.ts, 18, 38)) + + protected static get staticGetter() { return 0; } +>staticGetter : Symbol(C1.staticGetter, Decl(declarationEmitProtectedMembers.ts, 18, 52)) +} + +// Derived class overriding protected members +class C2 extends C1 { +>C2 : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) +>C1 : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) + + protected f() { +>f : Symbol(C2.f, Decl(declarationEmitProtectedMembers.ts, 23, 21)) + + return super.f() + this.x; +>super.f : Symbol(C1.f, Decl(declarationEmitProtectedMembers.ts, 3, 24)) +>super : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) +>f : Symbol(C1.f, Decl(declarationEmitProtectedMembers.ts, 3, 24)) +>this.x : Symbol(C1.x, Decl(declarationEmitProtectedMembers.ts, 2, 10)) +>this : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) +>x : Symbol(C1.x, Decl(declarationEmitProtectedMembers.ts, 2, 10)) + } + protected static sf() { +>sf : Symbol(C2.sf, Decl(declarationEmitProtectedMembers.ts, 26, 5)) + + return super.sf() + this.sx; +>super.sf : Symbol(C1.sf, Decl(declarationEmitProtectedMembers.ts, 12, 32)) +>super : Symbol(C1, Decl(declarationEmitProtectedMembers.ts, 0, 0)) +>sf : Symbol(C1.sf, Decl(declarationEmitProtectedMembers.ts, 12, 32)) +>this.sx : Symbol(C1.sx, Decl(declarationEmitProtectedMembers.ts, 10, 42)) +>this : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) +>sx : Symbol(C1.sx, Decl(declarationEmitProtectedMembers.ts, 10, 42)) + } +} + +// Derived class making protected members public +class C3 extends C2 { +>C3 : Symbol(C3, Decl(declarationEmitProtectedMembers.ts, 30, 1)) +>C2 : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) + + x: number; +>x : Symbol(C3.x, Decl(declarationEmitProtectedMembers.ts, 33, 21)) + + static sx: number; +>sx : Symbol(C3.sx, Decl(declarationEmitProtectedMembers.ts, 34, 14)) + + f() { +>f : Symbol(C3.f, Decl(declarationEmitProtectedMembers.ts, 35, 22)) + + return super.f(); +>super.f : Symbol(C2.f, Decl(declarationEmitProtectedMembers.ts, 23, 21)) +>super : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) +>f : Symbol(C2.f, Decl(declarationEmitProtectedMembers.ts, 23, 21)) + } + static sf() { +>sf : Symbol(C3.sf, Decl(declarationEmitProtectedMembers.ts, 38, 5)) + + return super.sf(); +>super.sf : Symbol(C2.sf, Decl(declarationEmitProtectedMembers.ts, 26, 5)) +>super : Symbol(C2, Decl(declarationEmitProtectedMembers.ts, 20, 1)) +>sf : Symbol(C2.sf, Decl(declarationEmitProtectedMembers.ts, 26, 5)) + } + + static get staticGetter() { return 1; } +>staticGetter : Symbol(C3.staticGetter, Decl(declarationEmitProtectedMembers.ts, 41, 5)) +} + +// Protected properties in constructors +class C4 { +>C4 : Symbol(C4, Decl(declarationEmitProtectedMembers.ts, 44, 1)) + + constructor(protected a: number, protected b) { } +>a : Symbol(C4.a, Decl(declarationEmitProtectedMembers.ts, 48, 16)) +>b : Symbol(C4.b, Decl(declarationEmitProtectedMembers.ts, 48, 36)) +} diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.types b/tests/baselines/reference/declarationEmitProtectedMembers.types similarity index 91% rename from tests/baselines/reference/declarationEmit_protectedMembers.types rename to tests/baselines/reference/declarationEmitProtectedMembers.types index dd2f0012bf9..b293487d57d 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.types +++ b/tests/baselines/reference/declarationEmitProtectedMembers.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/declarationEmit_protectedMembers.ts === +=== tests/cases/compiler/declarationEmitProtectedMembers.ts === // Class with protected members class C1 { diff --git a/tests/baselines/reference/declarationEmit_readonly.js b/tests/baselines/reference/declarationEmitReadonly.js similarity index 63% rename from tests/baselines/reference/declarationEmit_readonly.js rename to tests/baselines/reference/declarationEmitReadonly.js index 4925e5dafae..fd90188940c 100644 --- a/tests/baselines/reference/declarationEmit_readonly.js +++ b/tests/baselines/reference/declarationEmitReadonly.js @@ -1,10 +1,10 @@ -//// [declarationEmit_readonly.ts] +//// [declarationEmitReadonly.ts] class C { constructor(readonly x: number) {} } -//// [declarationEmit_readonly.js] +//// [declarationEmitReadonly.js] var C = (function () { function C(x) { this.x = x; @@ -13,7 +13,7 @@ var C = (function () { }()); -//// [declarationEmit_readonly.d.ts] +//// [declarationEmitReadonly.d.ts] declare class C { readonly x: number; constructor(x: number); diff --git a/tests/baselines/reference/declarationEmitReadonly.symbols b/tests/baselines/reference/declarationEmitReadonly.symbols new file mode 100644 index 00000000000..2ef310cf7df --- /dev/null +++ b/tests/baselines/reference/declarationEmitReadonly.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts === + +class C { +>C : Symbol(C, Decl(declarationEmitReadonly.ts, 0, 0)) + + constructor(readonly x: number) {} +>x : Symbol(C.x, Decl(declarationEmitReadonly.ts, 2, 16)) +} diff --git a/tests/baselines/reference/declarationEmit_readonly.types b/tests/baselines/reference/declarationEmitReadonly.types similarity index 70% rename from tests/baselines/reference/declarationEmit_readonly.types rename to tests/baselines/reference/declarationEmitReadonly.types index 3036c234ae5..e64256698cf 100644 --- a/tests/baselines/reference/declarationEmit_readonly.types +++ b/tests/baselines/reference/declarationEmitReadonly.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmit_readonly.ts === +=== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts === class C { >C : C diff --git a/tests/baselines/reference/declarationEmitUnknownImport.errors.txt b/tests/baselines/reference/declarationEmitUnknownImport.errors.txt new file mode 100644 index 00000000000..a2bee225fe8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUnknownImport.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/declarationEmitUnknownImport.ts(2,14): error TS2304: Cannot find name 'SomeNonExistingName'. +tests/cases/compiler/declarationEmitUnknownImport.ts(2,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +tests/cases/compiler/declarationEmitUnknownImport.ts(2,14): error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. + + +==== tests/cases/compiler/declarationEmitUnknownImport.ts (3 errors) ==== + + import Foo = SomeNonExistingName + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'SomeNonExistingName'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'SomeNonExistingName'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. + export {Foo} \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_UnknownImport.js b/tests/baselines/reference/declarationEmitUnknownImport.js similarity index 56% rename from tests/baselines/reference/declarationEmit_UnknownImport.js rename to tests/baselines/reference/declarationEmitUnknownImport.js index 05449c08b6a..bccf2337e08 100644 --- a/tests/baselines/reference/declarationEmit_UnknownImport.js +++ b/tests/baselines/reference/declarationEmitUnknownImport.js @@ -1,9 +1,9 @@ -//// [declarationEmit_UnknownImport.ts] +//// [declarationEmitUnknownImport.ts] import Foo = SomeNonExistingName export {Foo} -//// [declarationEmit_UnknownImport.js] +//// [declarationEmitUnknownImport.js] "use strict"; var Foo = SomeNonExistingName; exports.Foo = Foo; diff --git a/tests/baselines/reference/declarationEmitUnknownImport2.errors.txt b/tests/baselines/reference/declarationEmitUnknownImport2.errors.txt new file mode 100644 index 00000000000..db017d3c89a --- /dev/null +++ b/tests/baselines/reference/declarationEmitUnknownImport2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/declarationEmitUnknownImport2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/declarationEmitUnknownImport2.ts(2,12): error TS2304: Cannot find name 'From'. +tests/cases/compiler/declarationEmitUnknownImport2.ts(2,12): error TS2503: Cannot find namespace 'From'. +tests/cases/compiler/declarationEmitUnknownImport2.ts(2,12): error TS4000: Import declaration 'Foo' is using private name 'From'. +tests/cases/compiler/declarationEmitUnknownImport2.ts(2,17): error TS1005: ';' expected. + + +==== tests/cases/compiler/declarationEmitUnknownImport2.ts (5 errors) ==== + + import Foo From './Foo'; // Syntax error + ~~~~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'From'. + ~~~~ +!!! error TS2503: Cannot find namespace 'From'. + ~~~~ +!!! error TS4000: Import declaration 'Foo' is using private name 'From'. + ~~~~~~~ +!!! error TS1005: ';' expected. + export default Foo \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_UnknownImport2.js b/tests/baselines/reference/declarationEmitUnknownImport2.js similarity index 69% rename from tests/baselines/reference/declarationEmit_UnknownImport2.js rename to tests/baselines/reference/declarationEmitUnknownImport2.js index 7f20d9ec9b8..08afa34f8c8 100644 --- a/tests/baselines/reference/declarationEmit_UnknownImport2.js +++ b/tests/baselines/reference/declarationEmitUnknownImport2.js @@ -1,9 +1,9 @@ -//// [declarationEmit_UnknownImport2.ts] +//// [declarationEmitUnknownImport2.ts] import Foo From './Foo'; // Syntax error export default Foo -//// [declarationEmit_UnknownImport2.js] +//// [declarationEmitUnknownImport2.js] "use strict"; var Foo = From; './Foo'; // Syntax error diff --git a/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt b/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt deleted file mode 100644 index 9d333e66129..00000000000 --- a/tests/baselines/reference/declarationEmit_UnknownImport.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS2304: Cannot find name 'SomeNonExistingName'. -tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. -tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. - - -==== tests/cases/compiler/declarationEmit_UnknownImport.ts (3 errors) ==== - - import Foo = SomeNonExistingName - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'SomeNonExistingName'. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2503: Cannot find namespace 'SomeNonExistingName'. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'. - export {Foo} \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt b/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt deleted file mode 100644 index 72dbde546f1..00000000000 --- a/tests/baselines/reference/declarationEmit_UnknownImport2.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS1005: '=' expected. -tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS2304: Cannot find name 'From'. -tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS2503: Cannot find namespace 'From'. -tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS4000: Import declaration 'Foo' is using private name 'From'. -tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,17): error TS1005: ';' expected. - - -==== tests/cases/compiler/declarationEmit_UnknownImport2.ts (5 errors) ==== - - import Foo From './Foo'; // Syntax error - ~~~~ -!!! error TS1005: '=' expected. - ~~~~ -!!! error TS2304: Cannot find name 'From'. - ~~~~ -!!! error TS2503: Cannot find namespace 'From'. - ~~~~ -!!! error TS4000: Import declaration 'Foo' is using private name 'From'. - ~~~~~~~ -!!! error TS1005: ';' expected. - export default Foo \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.js b/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.js deleted file mode 100644 index 59974d0fb85..00000000000 --- a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [declarationEmit_array-types-from-generic-array-usage.ts] -interface A extends Array { } - - -//// [declarationEmit_array-types-from-generic-array-usage.js] - - -//// [declarationEmit_array-types-from-generic-array-usage.d.ts] -interface A extends Array { -} diff --git a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.symbols b/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.symbols deleted file mode 100644 index 9c9e757afb9..00000000000 --- a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/declarationEmit_array-types-from-generic-array-usage.ts === -interface A extends Array { } ->A : Symbol(A, Decl(declarationEmit_array-types-from-generic-array-usage.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) - diff --git a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.types b/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.types deleted file mode 100644 index 63f35d0f263..00000000000 --- a/tests/baselines/reference/declarationEmit_array-types-from-generic-array-usage.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/declarationEmit_array-types-from-generic-array-usage.ts === -interface A extends Array { } ->A : A ->Array : T[] - diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.symbols b/tests/baselines/reference/declarationEmit_bindingPatterns.symbols deleted file mode 100644 index b39aca17ea3..00000000000 --- a/tests/baselines/reference/declarationEmit_bindingPatterns.symbols +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/declarationEmit_bindingPatterns.ts === - -const k = ({x: z = 'y'}) => { } ->k : Symbol(k, Decl(declarationEmit_bindingPatterns.ts, 1, 5)) ->x : Symbol(x) ->z : Symbol(z, Decl(declarationEmit_bindingPatterns.ts, 1, 12)) - -var a; ->a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) - -function f({} = a, [] = a, { p: {} = a} = a) { ->f : Symbol(f, Decl(declarationEmit_bindingPatterns.ts, 3, 6)) ->a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) -} diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict.symbols b/tests/baselines/reference/declarationEmit_classMemberNameConflict.symbols deleted file mode 100644 index 2b8959289a8..00000000000 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict.symbols +++ /dev/null @@ -1,70 +0,0 @@ -=== tests/cases/compiler/declarationEmit_classMemberNameConflict.ts === - -export class C1 { ->C1 : Symbol(C1, Decl(declarationEmit_classMemberNameConflict.ts, 0, 0)) - - C1() { } // has to be the same as the class name ->C1 : Symbol(C1.C1, Decl(declarationEmit_classMemberNameConflict.ts, 1, 17)) - - bar() { ->bar : Symbol(C1.bar, Decl(declarationEmit_classMemberNameConflict.ts, 2, 12)) - - return function (t: typeof C1) { ->t : Symbol(t, Decl(declarationEmit_classMemberNameConflict.ts, 5, 25)) ->C1 : Symbol(C1, Decl(declarationEmit_classMemberNameConflict.ts, 0, 0)) - - }; - } -} - -export class C2 { ->C2 : Symbol(C2, Decl(declarationEmit_classMemberNameConflict.ts, 8, 1)) - - C2: any // has to be the same as the class name ->C2 : Symbol(C2.C2, Decl(declarationEmit_classMemberNameConflict.ts, 10, 17)) - - bar() { ->bar : Symbol(C2.bar, Decl(declarationEmit_classMemberNameConflict.ts, 11, 11)) - - return function (t: typeof C2) { ->t : Symbol(t, Decl(declarationEmit_classMemberNameConflict.ts, 14, 25)) ->C2 : Symbol(C2, Decl(declarationEmit_classMemberNameConflict.ts, 8, 1)) - - }; - } -} - -export class C3 { ->C3 : Symbol(C3, Decl(declarationEmit_classMemberNameConflict.ts, 17, 1)) - - get C3() { return 0; } // has to be the same as the class name ->C3 : Symbol(C3.C3, Decl(declarationEmit_classMemberNameConflict.ts, 19, 17)) - - bar() { ->bar : Symbol(C3.bar, Decl(declarationEmit_classMemberNameConflict.ts, 20, 26)) - - return function (t: typeof C3) { ->t : Symbol(t, Decl(declarationEmit_classMemberNameConflict.ts, 23, 25)) ->C3 : Symbol(C3, Decl(declarationEmit_classMemberNameConflict.ts, 17, 1)) - - }; - } -} - -export class C4 { ->C4 : Symbol(C4, Decl(declarationEmit_classMemberNameConflict.ts, 26, 1)) - - set C4(v) { } // has to be the same as the class name ->C4 : Symbol(C4.C4, Decl(declarationEmit_classMemberNameConflict.ts, 28, 17)) ->v : Symbol(v, Decl(declarationEmit_classMemberNameConflict.ts, 29, 11)) - - bar() { ->bar : Symbol(C4.bar, Decl(declarationEmit_classMemberNameConflict.ts, 29, 17)) - - return function (t: typeof C4) { ->t : Symbol(t, Decl(declarationEmit_classMemberNameConflict.ts, 32, 25)) ->C4 : Symbol(C4, Decl(declarationEmit_classMemberNameConflict.ts, 26, 1)) - - }; - } -} diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.symbols b/tests/baselines/reference/declarationEmit_classMemberNameConflict2.symbols deleted file mode 100644 index e7c4b6f060c..00000000000 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.symbols +++ /dev/null @@ -1,37 +0,0 @@ -=== tests/cases/compiler/declarationEmit_classMemberNameConflict2.ts === - -const Bar = 'bar'; ->Bar : Symbol(Bar, Decl(declarationEmit_classMemberNameConflict2.ts, 1, 5)) - -enum Hello { ->Hello : Symbol(Hello, Decl(declarationEmit_classMemberNameConflict2.ts, 1, 18)) - - World ->World : Symbol(Hello.World, Decl(declarationEmit_classMemberNameConflict2.ts, 3, 12)) -} - -enum Hello1 { ->Hello1 : Symbol(Hello1, Decl(declarationEmit_classMemberNameConflict2.ts, 5, 1)) - - World1 ->World1 : Symbol(Hello1.World1, Decl(declarationEmit_classMemberNameConflict2.ts, 7, 13)) -} - -class Foo { ->Foo : Symbol(Foo, Decl(declarationEmit_classMemberNameConflict2.ts, 9, 1)) - - // Same names + string => OK - Bar = Bar; ->Bar : Symbol(Foo.Bar, Decl(declarationEmit_classMemberNameConflict2.ts, 11, 11)) ->Bar : Symbol(Bar, Decl(declarationEmit_classMemberNameConflict2.ts, 1, 5)) - - // Same names + enum => OK - Hello = Hello; ->Hello : Symbol(Foo.Hello, Decl(declarationEmit_classMemberNameConflict2.ts, 13, 14)) ->Hello : Symbol(Hello, Decl(declarationEmit_classMemberNameConflict2.ts, 1, 18)) - - // Different names + enum => OK - Hello2 = Hello1; ->Hello2 : Symbol(Foo.Hello2, Decl(declarationEmit_classMemberNameConflict2.ts, 16, 18)) ->Hello1 : Symbol(Hello1, Decl(declarationEmit_classMemberNameConflict2.ts, 5, 1)) -} diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends.symbols b/tests/baselines/reference/declarationEmit_expressionInExtends.symbols deleted file mode 100644 index 319914702ac..00000000000 --- a/tests/baselines/reference/declarationEmit_expressionInExtends.symbols +++ /dev/null @@ -1,32 +0,0 @@ -=== tests/cases/compiler/declarationEmit_expressionInExtends.ts === - -var x: { ->x : Symbol(x, Decl(declarationEmit_expressionInExtends.ts, 1, 3)) - - new(s: any): Q; ->T : Symbol(T, Decl(declarationEmit_expressionInExtends.ts, 2, 8)) ->s : Symbol(s, Decl(declarationEmit_expressionInExtends.ts, 2, 11)) ->Q : Symbol(Q, Decl(declarationEmit_expressionInExtends.ts, 3, 1)) -} - -class Q { ->Q : Symbol(Q, Decl(declarationEmit_expressionInExtends.ts, 3, 1)) - - s: string; ->s : Symbol(Q.s, Decl(declarationEmit_expressionInExtends.ts, 5, 9)) -} - -class B extends x { ->B : Symbol(B, Decl(declarationEmit_expressionInExtends.ts, 7, 1)) ->x : Symbol(x, Decl(declarationEmit_expressionInExtends.ts, 1, 3)) -} - -var q: B; ->q : Symbol(q, Decl(declarationEmit_expressionInExtends.ts, 12, 3)) ->B : Symbol(B, Decl(declarationEmit_expressionInExtends.ts, 7, 1)) - -q.s; ->q.s : Symbol(Q.s, Decl(declarationEmit_expressionInExtends.ts, 5, 9)) ->q : Symbol(q, Decl(declarationEmit_expressionInExtends.ts, 12, 3)) ->s : Symbol(Q.s, Decl(declarationEmit_expressionInExtends.ts, 5, 9)) - diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends2.symbols b/tests/baselines/reference/declarationEmit_expressionInExtends2.symbols deleted file mode 100644 index 03a36a49b15..00000000000 --- a/tests/baselines/reference/declarationEmit_expressionInExtends2.symbols +++ /dev/null @@ -1,30 +0,0 @@ -=== tests/cases/compiler/declarationEmit_expressionInExtends2.ts === - -class C { ->C : Symbol(C, Decl(declarationEmit_expressionInExtends2.ts, 0, 0)) ->T : Symbol(T, Decl(declarationEmit_expressionInExtends2.ts, 1, 8)) ->U : Symbol(U, Decl(declarationEmit_expressionInExtends2.ts, 1, 10)) - - x: T; ->x : Symbol(C.x, Decl(declarationEmit_expressionInExtends2.ts, 1, 15)) ->T : Symbol(T, Decl(declarationEmit_expressionInExtends2.ts, 1, 8)) - - y: U; ->y : Symbol(C.y, Decl(declarationEmit_expressionInExtends2.ts, 2, 9)) ->U : Symbol(U, Decl(declarationEmit_expressionInExtends2.ts, 1, 10)) -} - -function getClass(c: T) { ->getClass : Symbol(getClass, Decl(declarationEmit_expressionInExtends2.ts, 4, 1)) ->T : Symbol(T, Decl(declarationEmit_expressionInExtends2.ts, 6, 18)) ->c : Symbol(c, Decl(declarationEmit_expressionInExtends2.ts, 6, 21)) ->T : Symbol(T, Decl(declarationEmit_expressionInExtends2.ts, 6, 18)) - - return C; ->C : Symbol(C, Decl(declarationEmit_expressionInExtends2.ts, 0, 0)) -} - -class MyClass extends getClass(2) { ->MyClass : Symbol(MyClass, Decl(declarationEmit_expressionInExtends2.ts, 8, 1)) ->getClass : Symbol(getClass, Decl(declarationEmit_expressionInExtends2.ts, 4, 1)) -} diff --git a/tests/baselines/reference/declarationEmit_inferedDefaultExportType.symbols b/tests/baselines/reference/declarationEmit_inferedDefaultExportType.symbols deleted file mode 100644 index 7e8cdea2c75..00000000000 --- a/tests/baselines/reference/declarationEmit_inferedDefaultExportType.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/declarationEmit_inferedDefaultExportType.ts === - -// test.ts -export default { - foo: [], ->foo : Symbol(foo, Decl(declarationEmit_inferedDefaultExportType.ts, 2, 16)) - - bar: undefined, ->bar : Symbol(bar, Decl(declarationEmit_inferedDefaultExportType.ts, 3, 10)) ->undefined : Symbol(undefined) - - baz: null ->baz : Symbol(baz, Decl(declarationEmit_inferedDefaultExportType.ts, 4, 17)) -} diff --git a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.symbols b/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.symbols deleted file mode 100644 index d04c50c0d7c..00000000000 --- a/tests/baselines/reference/declarationEmit_inferedDefaultExportType2.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/declarationEmit_inferedDefaultExportType2.ts === - -// test.ts -export = { - foo: [], ->foo : Symbol(foo, Decl(declarationEmit_inferedDefaultExportType2.ts, 2, 10)) - - bar: undefined, ->bar : Symbol(bar, Decl(declarationEmit_inferedDefaultExportType2.ts, 3, 10)) ->undefined : Symbol(undefined) - - baz: null ->baz : Symbol(baz, Decl(declarationEmit_inferedDefaultExportType2.ts, 4, 17)) -} diff --git a/tests/baselines/reference/declarationEmit_invalidExport.errors.txt b/tests/baselines/reference/declarationEmit_invalidExport.errors.txt deleted file mode 100644 index 19d650d6d6f..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidExport.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/compiler/declarationEmit_invalidExport.ts(3,3): error TS7027: Unreachable code detected. -tests/cases/compiler/declarationEmit_invalidExport.ts(5,30): error TS4081: Exported type alias 'MyClass' has or is using private name 'myClass'. -tests/cases/compiler/declarationEmit_invalidExport.ts(6,1): error TS1128: Declaration or statement expected. - - -==== tests/cases/compiler/declarationEmit_invalidExport.ts (3 errors) ==== - - if (false) { - export var myClass = 0; - ~~~~~~ -!!! error TS7027: Unreachable code detected. - } - export type MyClass = typeof myClass; - ~~~~~~~ -!!! error TS4081: Exported type alias 'MyClass' has or is using private name 'myClass'. - } - ~ -!!! error TS1128: Declaration or statement expected. - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_invalidReference.js b/tests/baselines/reference/declarationEmit_invalidReference.js deleted file mode 100644 index d6ef9f48e53..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidReference.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [declarationEmit_invalidReference.ts] -/// -var x = 0; - -//// [declarationEmit_invalidReference.js] -/// -var x = 0; - - -//// [declarationEmit_invalidReference.d.ts] -declare var x: number; diff --git a/tests/baselines/reference/declarationEmit_invalidReference.symbols b/tests/baselines/reference/declarationEmit_invalidReference.symbols deleted file mode 100644 index b23bf697661..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidReference.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/declarationEmit_invalidReference.ts === -/// -var x = 0; ->x : Symbol(x, Decl(declarationEmit_invalidReference.ts, 1, 3)) - diff --git a/tests/baselines/reference/declarationEmit_invalidReference.types b/tests/baselines/reference/declarationEmit_invalidReference.types deleted file mode 100644 index 942f2088fc0..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidReference.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/declarationEmit_invalidReference.ts === -/// -var x = 0; ->x : number ->0 : 0 - diff --git a/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt b/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt deleted file mode 100644 index 9d480419022..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/compiler/declarationEmit_invalidReference2.ts(1,1): error TS6053: File 'tests/cases/compiler/invalid.ts' not found. - - -==== tests/cases/compiler/declarationEmit_invalidReference2.ts (1 errors) ==== - /// - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'tests/cases/compiler/invalid.ts' not found. - var x = 0; \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmit_invalidReference2.js b/tests/baselines/reference/declarationEmit_invalidReference2.js deleted file mode 100644 index 78fb232cca7..00000000000 --- a/tests/baselines/reference/declarationEmit_invalidReference2.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [declarationEmit_invalidReference2.ts] -/// -var x = 0; - -//// [declarationEmit_invalidReference2.js] -/// -var x = 0; - - -//// [declarationEmit_invalidReference2.d.ts] -declare var x: number; diff --git a/tests/baselines/reference/declarationEmit_nameConflicts2.symbols b/tests/baselines/reference/declarationEmit_nameConflicts2.symbols deleted file mode 100644 index 801ad3e7cfc..00000000000 --- a/tests/baselines/reference/declarationEmit_nameConflicts2.symbols +++ /dev/null @@ -1,68 +0,0 @@ -=== tests/cases/compiler/declarationEmit_nameConflicts2.ts === -module X.Y.base { ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) - - export function f() { } ->f : Symbol(f, Decl(declarationEmit_nameConflicts2.ts, 0, 17)) - - export class C { } ->C : Symbol(C, Decl(declarationEmit_nameConflicts2.ts, 1, 27)) - - export module M { ->M : Symbol(M, Decl(declarationEmit_nameConflicts2.ts, 2, 22)) - - export var v; ->v : Symbol(v, Decl(declarationEmit_nameConflicts2.ts, 4, 18)) - } - export enum E { } ->E : Symbol(E, Decl(declarationEmit_nameConflicts2.ts, 5, 5)) -} - -module X.Y.base.Z { ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->Z : Symbol(Z, Decl(declarationEmit_nameConflicts2.ts, 9, 16)) - - export var f = X.Y.base.f; // Should be base.f ->f : Symbol(f, Decl(declarationEmit_nameConflicts2.ts, 10, 14)) ->X.Y.base.f : Symbol(f, Decl(declarationEmit_nameConflicts2.ts, 0, 17)) ->X.Y.base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->X.Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->f : Symbol(f, Decl(declarationEmit_nameConflicts2.ts, 0, 17)) - - export var C = X.Y.base.C; // Should be base.C ->C : Symbol(C, Decl(declarationEmit_nameConflicts2.ts, 11, 14)) ->X.Y.base.C : Symbol(C, Decl(declarationEmit_nameConflicts2.ts, 1, 27)) ->X.Y.base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->X.Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->C : Symbol(C, Decl(declarationEmit_nameConflicts2.ts, 1, 27)) - - export var M = X.Y.base.M; // Should be base.M ->M : Symbol(M, Decl(declarationEmit_nameConflicts2.ts, 12, 14)) ->X.Y.base.M : Symbol(M, Decl(declarationEmit_nameConflicts2.ts, 2, 22)) ->X.Y.base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->X.Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts2.ts, 2, 22)) - - export var E = X.Y.base.E; // Should be base.E ->E : Symbol(E, Decl(declarationEmit_nameConflicts2.ts, 13, 14)) ->X.Y.base.E : Symbol(E, Decl(declarationEmit_nameConflicts2.ts, 5, 5)) ->X.Y.base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->X.Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->X : Symbol(X, Decl(declarationEmit_nameConflicts2.ts, 0, 0), Decl(declarationEmit_nameConflicts2.ts, 7, 1)) ->Y : Symbol(Y, Decl(declarationEmit_nameConflicts2.ts, 0, 9), Decl(declarationEmit_nameConflicts2.ts, 9, 9)) ->base : Symbol(base, Decl(declarationEmit_nameConflicts2.ts, 0, 11), Decl(declarationEmit_nameConflicts2.ts, 9, 11)) ->E : Symbol(E, Decl(declarationEmit_nameConflicts2.ts, 5, 5)) -} diff --git a/tests/baselines/reference/declarationEmit_nameConflicts3.symbols b/tests/baselines/reference/declarationEmit_nameConflicts3.symbols deleted file mode 100644 index e72c4ec9cee..00000000000 --- a/tests/baselines/reference/declarationEmit_nameConflicts3.symbols +++ /dev/null @@ -1,76 +0,0 @@ -=== tests/cases/compiler/declarationEmit_nameConflicts3.ts === -module M { ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) - - export interface D { } ->D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 0, 10), Decl(declarationEmit_nameConflicts3.ts, 1, 26)) - - export module D { ->D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 0, 10), Decl(declarationEmit_nameConflicts3.ts, 1, 26)) - - export function f() { } ->f : Symbol(f, Decl(declarationEmit_nameConflicts3.ts, 2, 21)) - } - export module C { ->C : Symbol(C, Decl(declarationEmit_nameConflicts3.ts, 4, 5)) - - export function f() { } ->f : Symbol(f, Decl(declarationEmit_nameConflicts3.ts, 5, 21)) - } - export module E { ->E : Symbol(E, Decl(declarationEmit_nameConflicts3.ts, 7, 5)) - - export function f() { } ->f : Symbol(f, Decl(declarationEmit_nameConflicts3.ts, 8, 21)) - } -} - -module M.P { ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) ->P : Symbol(P, Decl(declarationEmit_nameConflicts3.ts, 13, 9)) - - export class C { ->C : Symbol(C, Decl(declarationEmit_nameConflicts3.ts, 13, 12)) - - static f() { } ->f : Symbol(C.f, Decl(declarationEmit_nameConflicts3.ts, 14, 20)) - } - export class E extends C { } ->E : Symbol(E, Decl(declarationEmit_nameConflicts3.ts, 16, 5)) ->C : Symbol(C, Decl(declarationEmit_nameConflicts3.ts, 13, 12)) - - export enum D { ->D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 17, 32)) - - f ->f : Symbol(D.f, Decl(declarationEmit_nameConflicts3.ts, 18, 19)) - } - export var v: M.D; // ok ->v : Symbol(v, Decl(declarationEmit_nameConflicts3.ts, 21, 14)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) ->D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 0, 10), Decl(declarationEmit_nameConflicts3.ts, 1, 26)) - - export var w = M.D.f; // error, should be typeof M.D.f ->w : Symbol(w, Decl(declarationEmit_nameConflicts3.ts, 22, 14)) ->M.D.f : Symbol(M.D.f, Decl(declarationEmit_nameConflicts3.ts, 2, 21)) ->M.D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 0, 10), Decl(declarationEmit_nameConflicts3.ts, 1, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) ->D : Symbol(D, Decl(declarationEmit_nameConflicts3.ts, 0, 10), Decl(declarationEmit_nameConflicts3.ts, 1, 26)) ->f : Symbol(M.D.f, Decl(declarationEmit_nameConflicts3.ts, 2, 21)) - - export var x = M.C.f; // error, should be typeof M.C.f ->x : Symbol(x, Decl(declarationEmit_nameConflicts3.ts, 23, 14), Decl(declarationEmit_nameConflicts3.ts, 24, 14)) ->M.C.f : Symbol(C.f, Decl(declarationEmit_nameConflicts3.ts, 5, 21)) ->M.C : Symbol(C, Decl(declarationEmit_nameConflicts3.ts, 4, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) ->C : Symbol(C, Decl(declarationEmit_nameConflicts3.ts, 4, 5)) ->f : Symbol(C.f, Decl(declarationEmit_nameConflicts3.ts, 5, 21)) - - export var x = M.E.f; // error, should be typeof M.E.f ->x : Symbol(x, Decl(declarationEmit_nameConflicts3.ts, 23, 14), Decl(declarationEmit_nameConflicts3.ts, 24, 14)) ->M.E.f : Symbol(E.f, Decl(declarationEmit_nameConflicts3.ts, 8, 21)) ->M.E : Symbol(E, Decl(declarationEmit_nameConflicts3.ts, 7, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts3.ts, 0, 0), Decl(declarationEmit_nameConflicts3.ts, 11, 1)) ->E : Symbol(E, Decl(declarationEmit_nameConflicts3.ts, 7, 5)) ->f : Symbol(E.f, Decl(declarationEmit_nameConflicts3.ts, 8, 21)) -} diff --git a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.symbols b/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.symbols deleted file mode 100644 index 26c8875a236..00000000000 --- a/tests/baselines/reference/declarationEmit_nameConflictsWithAlias.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/declarationEmit_nameConflictsWithAlias.ts === -export module C { export interface I { } } ->C : Symbol(C, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 0)) ->I : Symbol(I, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 17)) - -export import v = C; ->v : Symbol(v, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 42)) ->C : Symbol(C, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 0)) - -export module M { ->M : Symbol(M, Decl(declarationEmit_nameConflictsWithAlias.ts, 1, 20)) - - export module C { export interface I { } } ->C : Symbol(C, Decl(declarationEmit_nameConflictsWithAlias.ts, 2, 17)) ->I : Symbol(I, Decl(declarationEmit_nameConflictsWithAlias.ts, 3, 21)) - - export var w: v.I; // Gets emitted as C.I, which is the wrong interface ->w : Symbol(w, Decl(declarationEmit_nameConflictsWithAlias.ts, 4, 14)) ->v : Symbol(v, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 42)) ->I : Symbol(v.I, Decl(declarationEmit_nameConflictsWithAlias.ts, 0, 17)) -} diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.symbols b/tests/baselines/reference/declarationEmit_protectedMembers.symbols deleted file mode 100644 index ee9f5ce199d..00000000000 --- a/tests/baselines/reference/declarationEmit_protectedMembers.symbols +++ /dev/null @@ -1,114 +0,0 @@ -=== tests/cases/compiler/declarationEmit_protectedMembers.ts === - -// Class with protected members -class C1 { ->C1 : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) - - protected x: number; ->x : Symbol(C1.x, Decl(declarationEmit_protectedMembers.ts, 2, 10)) - - protected f() { ->f : Symbol(C1.f, Decl(declarationEmit_protectedMembers.ts, 3, 24)) - - return this.x; ->this.x : Symbol(C1.x, Decl(declarationEmit_protectedMembers.ts, 2, 10)) ->this : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) ->x : Symbol(C1.x, Decl(declarationEmit_protectedMembers.ts, 2, 10)) - } - - protected set accessor(a: number) { } ->accessor : Symbol(C1.accessor, Decl(declarationEmit_protectedMembers.ts, 7, 5), Decl(declarationEmit_protectedMembers.ts, 9, 41)) ->a : Symbol(a, Decl(declarationEmit_protectedMembers.ts, 9, 27)) - - protected get accessor() { return 0; } ->accessor : Symbol(C1.accessor, Decl(declarationEmit_protectedMembers.ts, 7, 5), Decl(declarationEmit_protectedMembers.ts, 9, 41)) - - protected static sx: number; ->sx : Symbol(C1.sx, Decl(declarationEmit_protectedMembers.ts, 10, 42)) - - protected static sf() { ->sf : Symbol(C1.sf, Decl(declarationEmit_protectedMembers.ts, 12, 32)) - - return this.sx; ->this.sx : Symbol(C1.sx, Decl(declarationEmit_protectedMembers.ts, 10, 42)) ->this : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) ->sx : Symbol(C1.sx, Decl(declarationEmit_protectedMembers.ts, 10, 42)) - } - - protected static set staticSetter(a: number) { } ->staticSetter : Symbol(C1.staticSetter, Decl(declarationEmit_protectedMembers.ts, 16, 5)) ->a : Symbol(a, Decl(declarationEmit_protectedMembers.ts, 18, 38)) - - protected static get staticGetter() { return 0; } ->staticGetter : Symbol(C1.staticGetter, Decl(declarationEmit_protectedMembers.ts, 18, 52)) -} - -// Derived class overriding protected members -class C2 extends C1 { ->C2 : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) ->C1 : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) - - protected f() { ->f : Symbol(C2.f, Decl(declarationEmit_protectedMembers.ts, 23, 21)) - - return super.f() + this.x; ->super.f : Symbol(C1.f, Decl(declarationEmit_protectedMembers.ts, 3, 24)) ->super : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) ->f : Symbol(C1.f, Decl(declarationEmit_protectedMembers.ts, 3, 24)) ->this.x : Symbol(C1.x, Decl(declarationEmit_protectedMembers.ts, 2, 10)) ->this : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) ->x : Symbol(C1.x, Decl(declarationEmit_protectedMembers.ts, 2, 10)) - } - protected static sf() { ->sf : Symbol(C2.sf, Decl(declarationEmit_protectedMembers.ts, 26, 5)) - - return super.sf() + this.sx; ->super.sf : Symbol(C1.sf, Decl(declarationEmit_protectedMembers.ts, 12, 32)) ->super : Symbol(C1, Decl(declarationEmit_protectedMembers.ts, 0, 0)) ->sf : Symbol(C1.sf, Decl(declarationEmit_protectedMembers.ts, 12, 32)) ->this.sx : Symbol(C1.sx, Decl(declarationEmit_protectedMembers.ts, 10, 42)) ->this : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) ->sx : Symbol(C1.sx, Decl(declarationEmit_protectedMembers.ts, 10, 42)) - } -} - -// Derived class making protected members public -class C3 extends C2 { ->C3 : Symbol(C3, Decl(declarationEmit_protectedMembers.ts, 30, 1)) ->C2 : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) - - x: number; ->x : Symbol(C3.x, Decl(declarationEmit_protectedMembers.ts, 33, 21)) - - static sx: number; ->sx : Symbol(C3.sx, Decl(declarationEmit_protectedMembers.ts, 34, 14)) - - f() { ->f : Symbol(C3.f, Decl(declarationEmit_protectedMembers.ts, 35, 22)) - - return super.f(); ->super.f : Symbol(C2.f, Decl(declarationEmit_protectedMembers.ts, 23, 21)) ->super : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) ->f : Symbol(C2.f, Decl(declarationEmit_protectedMembers.ts, 23, 21)) - } - static sf() { ->sf : Symbol(C3.sf, Decl(declarationEmit_protectedMembers.ts, 38, 5)) - - return super.sf(); ->super.sf : Symbol(C2.sf, Decl(declarationEmit_protectedMembers.ts, 26, 5)) ->super : Symbol(C2, Decl(declarationEmit_protectedMembers.ts, 20, 1)) ->sf : Symbol(C2.sf, Decl(declarationEmit_protectedMembers.ts, 26, 5)) - } - - static get staticGetter() { return 1; } ->staticGetter : Symbol(C3.staticGetter, Decl(declarationEmit_protectedMembers.ts, 41, 5)) -} - -// Protected properties in constructors -class C4 { ->C4 : Symbol(C4, Decl(declarationEmit_protectedMembers.ts, 44, 1)) - - constructor(protected a: number, protected b) { } ->a : Symbol(C4.a, Decl(declarationEmit_protectedMembers.ts, 48, 16)) ->b : Symbol(C4.b, Decl(declarationEmit_protectedMembers.ts, 48, 36)) -} diff --git a/tests/baselines/reference/declarationEmit_readonly.symbols b/tests/baselines/reference/declarationEmit_readonly.symbols deleted file mode 100644 index eadb7dc3ddf..00000000000 --- a/tests/baselines/reference/declarationEmit_readonly.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmit_readonly.ts === - -class C { ->C : Symbol(C, Decl(declarationEmit_readonly.ts, 0, 0)) - - constructor(readonly x: number) {} ->x : Symbol(C.x, Decl(declarationEmit_readonly.ts, 2, 16)) -} diff --git a/tests/baselines/reference/genericTypeAliases.types b/tests/baselines/reference/genericTypeAliases.types index 1cabaa8caa0..b4c75841245 100644 --- a/tests/baselines/reference/genericTypeAliases.types +++ b/tests/baselines/reference/genericTypeAliases.types @@ -215,60 +215,60 @@ p.tag = "test"; >"test" : "test" function f() { ->f : () => Foo +>f : () => A[] | { x: A[] | any; } >A : A type Foo = T | { x: Foo }; ->Foo : Foo +>Foo : T | { x: T | any; } >T : T >T : T ->x : Foo ->Foo : Foo +>x : T | { x: T | any; } +>Foo : T | { x: T | any; } >T : T var x: Foo; ->x : Foo ->Foo : Foo +>x : A[] | { x: A[] | any; } +>Foo : T | { x: T | any; } >A : A return x; ->x : Foo +>x : A[] | { x: A[] | any; } } function g() { ->g : () => Bar +>g : () => B[] | { x: B[] | any; } >B : B type Bar = U | { x: Bar }; ->Bar : Bar +>Bar : U | { x: U | any; } >U : U >U : U ->x : Bar ->Bar : Bar +>x : U | { x: U | any; } +>Bar : U | { x: U | any; } >U : U var x: Bar; ->x : Bar ->Bar : Bar +>x : B[] | { x: B[] | any; } +>Bar : U | { x: U | any; } >B : B return x; ->x : Bar +>x : B[] | { x: B[] | any; } } // Deeply instantiated generics var a = f(); ->a : Foo ->f() : Foo ->f : () => Foo +>a : string[] | { x: string[] | any; } +>f() : string[] | { x: string[] | any; } +>f : () => A[] | { x: A[] | any; } var b = g(); ->b : Bar ->g() : Bar ->g : () => Bar +>b : string[] | { x: string[] | any; } +>g() : string[] | { x: string[] | any; } +>g : () => B[] | { x: B[] | any; } a = b; ->a = b : Bar ->a : Foo ->b : Bar +>a = b : string[] | { x: string[] | any; } +>a : string[] | { x: string[] | any; } +>b : string[] | { x: string[] | any; } diff --git a/tests/baselines/reference/returns.js b/tests/baselines/reference/returns.js new file mode 100644 index 00000000000..67390dea72a --- /dev/null +++ b/tests/baselines/reference/returns.js @@ -0,0 +1,16 @@ +//// [returns.js] +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} + + +//// [dummy.js] +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} diff --git a/tests/baselines/reference/returns.symbols b/tests/baselines/reference/returns.symbols new file mode 100644 index 00000000000..e0f0d4dac96 --- /dev/null +++ b/tests/baselines/reference/returns.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/jsdoc/returns.js === +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : Symbol(f, Decl(returns.js, 0, 0)) + + return ""; +} + diff --git a/tests/baselines/reference/returns.types b/tests/baselines/reference/returns.types new file mode 100644 index 00000000000..c85bc7272f8 --- /dev/null +++ b/tests/baselines/reference/returns.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/returns.js === +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : () => string + + return ""; +>"" : "" +} + diff --git a/tests/baselines/reference/umd8.errors.txt b/tests/baselines/reference/umd8.errors.txt new file mode 100644 index 00000000000..9396c8c5450 --- /dev/null +++ b/tests/baselines/reference/umd8.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module + + +==== tests/cases/conformance/externalModules/a.ts (1 errors) ==== + /// + import * as ff from './foo'; + + let y: Foo; // OK in type position + y.foo(); + let z: Foo.SubThing; // OK in ns position + let x: any = Foo; // Not OK in value position + ~~~ +!!! error TS2686: Identifier 'Foo' must be imported from a module + +==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ==== + + declare class Thing { + foo(): number; + } + declare namespace Thing { + interface SubThing { } + } + export = Thing; + export as namespace Foo; + \ No newline at end of file diff --git a/tests/baselines/reference/umd8.js b/tests/baselines/reference/umd8.js index b4c6e0fa76b..e76b3902156 100644 --- a/tests/baselines/reference/umd8.js +++ b/tests/baselines/reference/umd8.js @@ -5,17 +5,25 @@ declare class Thing { foo(): number; } +declare namespace Thing { + interface SubThing { } +} export = Thing; export as namespace Foo; //// [a.ts] /// -let y: Foo; -y.foo(); +import * as ff from './foo'; +let y: Foo; // OK in type position +y.foo(); +let z: Foo.SubThing; // OK in ns position +let x: any = Foo; // Not OK in value position //// [a.js] -/// -var y; +"use strict"; +var y; // OK in type position y.foo(); +var z; // OK in ns position +var x = Foo; // Not OK in value position diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types index 6090d300056..e927b011e53 100644 --- a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types @@ -2,14 +2,14 @@ // used in a declaration type handler1 = () => void; ->handler1 : handler1 +>handler1 : () => void export interface I1 { >I1 : I1 getHandler: handler1; ->getHandler : handler1 ->handler1 : handler1 +>getHandler : () => void +>handler1 : () => void } // exported @@ -18,12 +18,12 @@ export type handler2 = () => void; // used in extends clause type handler3 = () => void; ->handler3 : handler3 +>handler3 : () => void export interface I3 { >I3 : I3 >T : T ->handler3 : handler3 +>handler3 : () => void getHandler: T; >getHandler : T @@ -32,32 +32,32 @@ export interface I3 { // used in another type alias declaration type handler4 = () => void; ->handler4 : handler4 +>handler4 : () => void type handler5 = handler4 | (()=>number); ->handler5 : handler5 ->handler4 : handler4 +>handler5 : (() => void) | (() => number) +>handler4 : () => void var x: handler5; ->x : handler5 ->handler5 : handler5 +>x : (() => void) | (() => number) +>handler5 : (() => void) | (() => number) x(); >x() : number | void ->x : handler5 +>x : (() => void) | (() => number) // used as type argument type handler6 = () => void; ->handler6 : handler6 +>handler6 : () => void var y: Array; ->y : handler6[] +>y : (() => void)[] >Array : T[] ->handler6 : handler6 +>handler6 : () => void y[0](); >y[0]() : void ->y[0] : handler6 ->y : handler6[] +>y[0] : () => void +>y : (() => void)[] >0 : 0 diff --git a/tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts b/tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts new file mode 100644 index 00000000000..a5a32e53502 --- /dev/null +++ b/tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts @@ -0,0 +1,6 @@ +namespace hello.hi.world +{ + function foo() {} + + // TODO, blah +} \ No newline at end of file diff --git a/tests/cases/compiler/commentOnDecoratedClassDeclaration.ts b/tests/cases/compiler/commentOnDecoratedClassDeclaration.ts new file mode 100644 index 00000000000..aadf63bf757 --- /dev/null +++ b/tests/cases/compiler/commentOnDecoratedClassDeclaration.ts @@ -0,0 +1,17 @@ +// @experimentalDecorators: true +declare function decorator(x: string): any; + +/** + * Leading trivia + */ +@decorator("hello") +class Remote { } + +/** + * Floating Comment + */ + +@decorator("hi") +class AnotherRomote { + constructor() {} +} \ No newline at end of file diff --git a/tests/cases/compiler/commentOnExportEnumDeclaration.ts b/tests/cases/compiler/commentOnExportEnumDeclaration.ts new file mode 100644 index 00000000000..d9a120492ff --- /dev/null +++ b/tests/cases/compiler/commentOnExportEnumDeclaration.ts @@ -0,0 +1,6 @@ +/** + * comment + */ +export enum Color { + r, g, b +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_array-types-from-generic-array-usage.ts b/tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_array-types-from-generic-array-usage.ts rename to tests/cases/compiler/declarationEmitArrayTypesFromGenericArrayUsage.ts diff --git a/tests/cases/compiler/declarationEmit_bindingPatterns.ts b/tests/cases/compiler/declarationEmitBindingPatterns.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_bindingPatterns.ts rename to tests/cases/compiler/declarationEmitBindingPatterns.ts diff --git a/tests/cases/compiler/declarationEmit_classMemberNameConflict.ts b/tests/cases/compiler/declarationEmitClassMemberNameConflict.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_classMemberNameConflict.ts rename to tests/cases/compiler/declarationEmitClassMemberNameConflict.ts diff --git a/tests/cases/compiler/declarationEmit_classMemberNameConflict2.ts b/tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_classMemberNameConflict2.ts rename to tests/cases/compiler/declarationEmitClassMemberNameConflict2.ts diff --git a/tests/cases/compiler/declarationEmit_exportAssignment.ts b/tests/cases/compiler/declarationEmitExportAssignment.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_exportAssignment.ts rename to tests/cases/compiler/declarationEmitExportAssignment.ts diff --git a/tests/cases/compiler/declarationEmit_exportDeclaration.ts b/tests/cases/compiler/declarationEmitExportDeclaration.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_exportDeclaration.ts rename to tests/cases/compiler/declarationEmitExportDeclaration.ts diff --git a/tests/cases/compiler/declarationEmit_expressionInExtends.ts b/tests/cases/compiler/declarationEmitExpressionInExtends.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_expressionInExtends.ts rename to tests/cases/compiler/declarationEmitExpressionInExtends.ts diff --git a/tests/cases/compiler/declarationEmit_expressionInExtends2.ts b/tests/cases/compiler/declarationEmitExpressionInExtends2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_expressionInExtends2.ts rename to tests/cases/compiler/declarationEmitExpressionInExtends2.ts diff --git a/tests/cases/compiler/declarationEmit_expressionInExtends3.ts b/tests/cases/compiler/declarationEmitExpressionInExtends3.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_expressionInExtends3.ts rename to tests/cases/compiler/declarationEmitExpressionInExtends3.ts diff --git a/tests/cases/compiler/declarationEmit_expressionInExtends4.ts b/tests/cases/compiler/declarationEmitExpressionInExtends4.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_expressionInExtends4.ts rename to tests/cases/compiler/declarationEmitExpressionInExtends4.ts diff --git a/tests/cases/compiler/declarationEmit_inferedDefaultExportType.ts b/tests/cases/compiler/declarationEmitInferedDefaultExportType.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_inferedDefaultExportType.ts rename to tests/cases/compiler/declarationEmitInferedDefaultExportType.ts diff --git a/tests/cases/compiler/declarationEmit_inferedDefaultExportType2.ts b/tests/cases/compiler/declarationEmitInferedDefaultExportType2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_inferedDefaultExportType2.ts rename to tests/cases/compiler/declarationEmitInferedDefaultExportType2.ts diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias1.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias1.ts new file mode 100644 index 00000000000..2e30797e515 --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias1.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +// @Filename: 1.ts +let v = "str" || true; +export { v } \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias2.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias2.ts new file mode 100644 index 00000000000..2a4e4e73b8d --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias2.ts @@ -0,0 +1,16 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +// @Filename: 1.ts +let v = "str" || true; +function bar () { + return v; +} +export { v, bar } \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias3.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias3.ts new file mode 100644 index 00000000000..c7ba5168655 --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias3.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +// @Filename: 1.ts +var x = "hi" || 5; +export default x; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias4.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias4.ts new file mode 100644 index 00000000000..d9c6b75912b --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias4.ts @@ -0,0 +1,7 @@ +// @declaration: true + +function f() { + type Foo = T | { x: Foo }; + var x: Foo; + return x; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias5.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias5.ts new file mode 100644 index 00000000000..787847aecb0 --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias5.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +export type Data = string | boolean; +let obj: Data = true; + +// @Filename: 1.ts +import * as Z from "./0" +//let v2: Z.Data; +let v = "str" || true; +export { v } \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias6.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias6.ts new file mode 100644 index 00000000000..2e30797e515 --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias6.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +{ + type Data = string | boolean; + let obj: Data = true; +} +export { } + +// @Filename: 1.ts +let v = "str" || true; +export { v } \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias7.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias7.ts new file mode 100644 index 00000000000..690814f3667 --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias7.ts @@ -0,0 +1,10 @@ +// @declaration: true +// @skipDefaultLibCheck: true + +// @Filename: 0.ts +export type Data = string | boolean; +let obj: Data = true; + +// @Filename: 1.ts +let v = "str" || true; +export { v } \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias8.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias8.ts new file mode 100644 index 00000000000..20c5e5da2fb --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias8.ts @@ -0,0 +1,8 @@ +// @declaration: true + +type Foo = T | { x: Foo }; +var x: Foo; + +function returnSomeGlobalValue() { + return x; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitInferedTypeAlias9.ts b/tests/cases/compiler/declarationEmitInferedTypeAlias9.ts new file mode 100644 index 00000000000..f346cf27e1c --- /dev/null +++ b/tests/cases/compiler/declarationEmitInferedTypeAlias9.ts @@ -0,0 +1,8 @@ +// @declaration: true + +type Foo = T | { x: Foo }; +var x: Foo; + +export function returnSomeGlobalValue() { + return x; +} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_invalidExport.ts b/tests/cases/compiler/declarationEmitInvalidExport.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_invalidExport.ts rename to tests/cases/compiler/declarationEmitInvalidExport.ts diff --git a/tests/cases/compiler/declarationEmit_invalidReference.ts b/tests/cases/compiler/declarationEmitInvalidReference.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_invalidReference.ts rename to tests/cases/compiler/declarationEmitInvalidReference.ts diff --git a/tests/cases/compiler/declarationEmit_invalidReference2.ts b/tests/cases/compiler/declarationEmitInvalidReference2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_invalidReference2.ts rename to tests/cases/compiler/declarationEmitInvalidReference2.ts diff --git a/tests/cases/compiler/declarationEmit_nameConflicts.ts b/tests/cases/compiler/declarationEmitNameConflicts.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_nameConflicts.ts rename to tests/cases/compiler/declarationEmitNameConflicts.ts diff --git a/tests/cases/compiler/declarationEmit_nameConflicts2.ts b/tests/cases/compiler/declarationEmitNameConflicts2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_nameConflicts2.ts rename to tests/cases/compiler/declarationEmitNameConflicts2.ts diff --git a/tests/cases/compiler/declarationEmit_nameConflicts3.ts b/tests/cases/compiler/declarationEmitNameConflicts3.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_nameConflicts3.ts rename to tests/cases/compiler/declarationEmitNameConflicts3.ts diff --git a/tests/cases/compiler/declarationEmit_nameConflictsWithAlias.ts b/tests/cases/compiler/declarationEmitNameConflictsWithAlias.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_nameConflictsWithAlias.ts rename to tests/cases/compiler/declarationEmitNameConflictsWithAlias.ts diff --git a/tests/cases/compiler/declarationEmit_protectedMembers.ts b/tests/cases/compiler/declarationEmitProtectedMembers.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_protectedMembers.ts rename to tests/cases/compiler/declarationEmitProtectedMembers.ts diff --git a/tests/cases/compiler/declarationEmit_UnknownImport.ts b/tests/cases/compiler/declarationEmitUnknownImport.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_UnknownImport.ts rename to tests/cases/compiler/declarationEmitUnknownImport.ts diff --git a/tests/cases/compiler/declarationEmit_UnknownImport2.ts b/tests/cases/compiler/declarationEmitUnknownImport2.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_UnknownImport2.ts rename to tests/cases/compiler/declarationEmitUnknownImport2.ts diff --git a/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmit_readonly.ts b/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts similarity index 100% rename from tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmit_readonly.ts rename to tests/cases/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts diff --git a/tests/cases/conformance/externalModules/umd8.ts b/tests/cases/conformance/externalModules/umd8.ts index caab734f5e0..9a8331fded3 100644 --- a/tests/cases/conformance/externalModules/umd8.ts +++ b/tests/cases/conformance/externalModules/umd8.ts @@ -5,11 +5,17 @@ declare class Thing { foo(): number; } +declare namespace Thing { + interface SubThing { } +} export = Thing; export as namespace Foo; // @filename: a.ts /// -let y: Foo; -y.foo(); +import * as ff from './foo'; +let y: Foo; // OK in type position +y.foo(); +let z: Foo.SubThing; // OK in ns position +let x: any = Foo; // Not OK in value position diff --git a/tests/cases/conformance/jsdoc/returns.ts b/tests/cases/conformance/jsdoc/returns.ts new file mode 100644 index 00000000000..72cb4a6cb67 --- /dev/null +++ b/tests/cases/conformance/jsdoc/returns.ts @@ -0,0 +1,9 @@ +// @allowJs: true +// @filename: returns.js +// @out: dummy.js +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} diff --git a/tests/cases/fourslash/commentsClassMembers.ts b/tests/cases/fourslash/commentsClassMembers.ts index 90ca3ff5671..6edb684caa6 100644 --- a/tests/cases/fourslash/commentsClassMembers.ts +++ b/tests/cases/fourslash/commentsClassMembers.ts @@ -8,11 +8,11 @@ //// public p/*3*/2(/** number to add*/b: number) { //// return this./*4*/p1 + /*5*/b; //// } -//// /** getter property*/ +//// /** getter property 1*/ //// public get p/*6*/3() { //// return this./*7*/p/*8q*/2(/*8*/this./*9*/p1); //// } -//// /** setter property*/ +//// /** setter property 1*/ //// public set p/*10*/3(/** this is value*/value: number) { //// this./*11*/p1 = this./*12*/p/*13q*/2(/*13*/value); //// } @@ -22,11 +22,11 @@ //// private p/*15*/p2(/** number to add*/b: number) { //// return this./*16*/p1 + /*17*/b; //// } -//// /** getter property*/ +//// /** getter property 2*/ //// private get p/*18*/p3() { //// return this./*19*/p/*20q*/p2(/*20*/this./*21*/pp1); //// } -//// /** setter property*/ +//// /** setter property 2*/ //// private set p/*22*/p3( /** this is value*/value: number) { //// this./*23*/pp1 = this./*24*/p/*25q*/p2(/*25*/value); //// } @@ -43,7 +43,7 @@ //// static get s/*32*/3() { //// return /*33*/c1./*34*/s/*35q*/2(/*35*/c1./*36*/s1); //// } -//// /** setter property*/ +//// /** setter property 3*/ //// static set s/*37*/3( /** this is value*/value: number) { //// /*38*/c1./*39*/s1 = /*40*/c1./*41*/s/*42q*/2(/*42*/value); //// } @@ -141,10 +141,10 @@ verify.quickInfos({ goTo.marker('4'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -155,15 +155,15 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('5'); verify.completionListContains("b", "(parameter) b: number", "number to add"); -verify.quickInfoAt("6", "(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoAt("6", "(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('7'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -179,10 +179,10 @@ verify.quickInfoAt("8q", "(method) c1.p2(b: number): number", "sum with property goTo.marker('9'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -190,15 +190,15 @@ verify.memberListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); verify.memberListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); -verify.quickInfoAt("10", "(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoAt("10", "(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('11'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -209,10 +209,10 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('12'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -234,10 +234,10 @@ verify.quickInfos({ goTo.marker('16'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -248,15 +248,15 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('17'); verify.completionListContains("b", "(parameter) b: number", "number to add"); -verify.quickInfoAt("18", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.quickInfoAt("18", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); goTo.marker('19'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -272,10 +272,10 @@ verify.quickInfoAt("20q", "(method) c1.pp2(b: number): number", "sum with proper goTo.marker('21'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -283,15 +283,15 @@ verify.memberListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); verify.memberListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); -verify.quickInfoAt("22", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.quickInfoAt("22", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); goTo.marker('23'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -302,10 +302,10 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('24'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -331,7 +331,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('30'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -339,7 +339,7 @@ verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); goTo.marker('31'); verify.completionListContains("b", "(parameter) b: number", "number to add"); -verify.quickInfoAt("32", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoAt("32", "(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('33'); verify.completionListContains("c1", "class c1", "This is comment for c1"); @@ -347,7 +347,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('34'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -361,12 +361,12 @@ verify.quickInfoAt("35q", "(method) c1.s2(b: number): number", "static sum with goTo.marker('36'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); -verify.quickInfoAt("37", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoAt("37", "(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('38'); verify.completionListContains("c1", "class c1", "This is comment for c1"); @@ -374,7 +374,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('39'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -385,7 +385,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('41'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -479,7 +479,7 @@ goTo.marker("67"); verify.quickInfoIs("(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -497,8 +497,8 @@ verify.currentParameterHelpArgumentDocCommentIs("number to add"); verify.quickInfos({ "71q": ["(method) c1.p2(b: number): number", "sum with property"], 72: "var i1_prop: number", - 73: ["(property) c1.p3: number", "getter property\nsetter property"], - 74: ["(property) c1.p3: number", "getter property\nsetter property"], + 73: ["(property) c1.p3: number", "getter property 1\nsetter property 1"], + 74: ["(property) c1.p3: number", "getter property 1\nsetter property 1"], 75: "var i1_prop: number", 76: "var i1_nc_p: number", 77: "(property) c1.nc_p1: number", @@ -528,7 +528,7 @@ goTo.marker('88'); verify.quickInfoIs("(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -546,8 +546,8 @@ verify.currentParameterHelpArgumentDocCommentIs("number to add"); verify.quickInfos({ "92q": ["(method) c1.s2(b: number): number", "static sum with property"], 93: "var i1_s_prop: number", - 94: ["(property) c1.s3: number", "static getter property\nsetter property"], - 95: ["(property) c1.s3: number", "static getter property\nsetter property"], + 94: ["(property) c1.s3: number", "static getter property\nsetter property 3"], + 95: ["(property) c1.s3: number", "static getter property\nsetter property 3"], 96: "var i1_s_prop: number", 97: "var i1_s_nc_p: number", 98: "(property) c1.nc_s1: number", @@ -605,8 +605,8 @@ verify.quickInfos({ }); goTo.marker('114'); -verify.memberListContains("a", "(property) cWithConstructorProperty.a: number", "more info about a"); -verify.quickInfoIs("(property) cWithConstructorProperty.a: number", "more info about a"); +verify.memberListContains("a", "(property) cWithConstructorProperty.a: number", "this is first parameter a\nmore info about a"); +verify.quickInfoIs("(property) cWithConstructorProperty.a: number", "this is first parameter a\nmore info about a"); goTo.marker('115'); verify.completionListContains("a", "(parameter) a: number", "this is first parameter a\nmore info about a"); diff --git a/tests/cases/fourslash/commentsCommentParsing.ts b/tests/cases/fourslash/commentsCommentParsing.ts index b2ed4e8a379..ce80fd519dd 100644 --- a/tests/cases/fourslash/commentsCommentParsing.ts +++ b/tests/cases/fourslash/commentsCommentParsing.ts @@ -48,7 +48,7 @@ ////} ////jsDocMi/*7q*/xedComments2(/*7*/); //// -/////** jsdoc comment */ /*** another jsDocComment*/ +/////** jsdoc comment */ /*** malformed jsDocComment*/ /////// Triple slash comment ////function jsDocMixedComments3() { ////} @@ -231,8 +231,8 @@ verify.currentSignatureHelpDocCommentIs("jsdoc comment \nanother jsDocComment"); verify.quickInfoAt("7q", "function jsDocMixedComments2(): void", "jsdoc comment \nanother jsDocComment"); goTo.marker('8'); -verify.currentSignatureHelpDocCommentIs("jsdoc comment \n* another jsDocComment"); -verify.quickInfoAt("8q", "function jsDocMixedComments3(): void", "jsdoc comment \n* another jsDocComment"); +verify.currentSignatureHelpDocCommentIs("jsdoc comment "); +verify.quickInfoAt("8q", "function jsDocMixedComments3(): void", "jsdoc comment "); goTo.marker('9'); verify.currentSignatureHelpDocCommentIs("jsdoc comment \nanother jsDocComment"); @@ -280,33 +280,33 @@ verify.completionListContains("a", "(parameter) a: number", "first number"); verify.completionListContains("b", "(parameter) b: number", "second number"); goTo.marker('19'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs("first number"); verify.quickInfos({ "19q": [ "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", - "This is multiplication function\n@anotherTag\n@anotherTag" + "This is multiplication function" ], "19aq": ["(parameter) a: number", "first number"] }); goTo.marker('20'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs(""); verify.quickInfoAt("20aq", "(parameter) b: number"); goTo.marker('21'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); -verify.currentParameterHelpArgumentDocCommentIs("{"); -verify.quickInfoAt("21aq", "(parameter) c: number", "{"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); +verify.currentParameterHelpArgumentDocCommentIs(""); +verify.quickInfoAt("21aq", "(parameter) c: number"); goTo.marker('22'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs(""); verify.quickInfoAt("22aq", "(parameter) d: any"); goTo.marker('23'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs("LastParam "); verify.quickInfoAt("23aq", "(parameter) e: any", "LastParam "); @@ -331,52 +331,52 @@ verify.quickInfos({ }); goTo.marker('27'); -verify.completionListContains("multiply", "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function\n@anotherTag\n@anotherTag"); +verify.completionListContains("multiply", "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function"); verify.completionListContains("f1", "function f1(a: number): any (+1 overload)", "fn f1 with number"); goTo.marker('28'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs(""); verify.quickInfos({ "28q": [ "function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", - "This is subtract function" + "This is subtract function{ () => string; } } f this is optional param f" ], "28aq": "(parameter) a: number" }); goTo.marker('29'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is about b"); verify.quickInfoAt("29aq", "(parameter) b: number", "this is about b"); goTo.marker('30'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is optional param c"); verify.quickInfoAt("30aq", "(parameter) c: () => string", "this is optional param c"); goTo.marker('31'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); -verify.currentParameterHelpArgumentDocCommentIs(""); -verify.quickInfoAt("31aq", "(parameter) d: () => string"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); +verify.currentParameterHelpArgumentDocCommentIs("this is optional param d"); +verify.quickInfoAt("31aq", "(parameter) d: () => string", "this is optional param d"); goTo.marker('32'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is optional param e"); verify.quickInfoAt("32aq", "(parameter) e: () => string", "this is optional param e"); goTo.marker('33'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{ () => string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs(""); verify.quickInfoAt("33aq", "(parameter) f: () => string"); goTo.marker('34'); -verify.currentSignatureHelpDocCommentIs("this is square function\n@paramTag { number } a this is input number of paramTag\n@returnType { number } it is return type"); +verify.currentSignatureHelpDocCommentIs("this is square function"); verify.currentParameterHelpArgumentDocCommentIs("this is input number"); verify.quickInfos({ "34q": [ "function square(a: number): number", - "this is square function\n@paramTag { number } a this is input number of paramTag\n@returnType { number } it is return type" + "this is square function" ], "34aq": [ "(parameter) a: number", @@ -385,12 +385,12 @@ verify.quickInfos({ }); goTo.marker('35'); -verify.currentSignatureHelpDocCommentIs("this is divide function\n@paramTag { number } g this is optional param g"); +verify.currentSignatureHelpDocCommentIs("this is divide function"); verify.currentParameterHelpArgumentDocCommentIs("this is a"); verify.quickInfos({ "35q": [ "function divide(a: number, b: number): void", - "this is divide function\n@paramTag { number } g this is optional param g" + "this is divide function" ], "35aq": [ "(parameter) a: number", @@ -399,7 +399,7 @@ verify.quickInfos({ }); goTo.marker('36'); -verify.currentSignatureHelpDocCommentIs("this is divide function\n@paramTag { number } g this is optional param g"); +verify.currentSignatureHelpDocCommentIs("this is divide function"); verify.currentParameterHelpArgumentDocCommentIs("this is b"); verify.quickInfoAt("36aq", "(parameter) b: number", "this is b"); diff --git a/tests/cases/fourslash/commentsFunctionExpression.ts b/tests/cases/fourslash/commentsFunctionExpression.ts index 87da4c56168..65a061d1f91 100644 --- a/tests/cases/fourslash/commentsFunctionExpression.ts +++ b/tests/cases/fourslash/commentsFunctionExpression.ts @@ -60,23 +60,23 @@ verify.currentParameterHelpArgumentDocCommentIs("param b"); verify.quickInfos({ 7: "function anotherFunc(a: number): string", 8: ["(local var) lambdaVar: (b: string) => string", "documentation\ninner docs "], - 9: ["(parameter) b: string", "{string} inner parameter "], + 9: ["(parameter) b: string", "inner parameter "], 10: "(local var) localVar: string", 11: "(local var) localVar: string", - 12: ["(parameter) b: string", "{string} inner parameter "], + 12: ["(parameter) b: string", "inner parameter "], 13: ["(local var) lambdaVar: (b: string) => string", "documentation\ninner docs "], 14: [ "var assigned: (s: string) => number", - "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression" + "On variable\nSummary on expression" ] }); goTo.marker('15'); verify.completionListContains('s', '(parameter) s: string', "the first parameter!\nparam on expression\nOn parameter "); -verify.quickInfoAt("16", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.quickInfoAt("16", "var assigned: (s: string) => number", "On variable\nSummary on expression"); goTo.marker('17'); -verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\nSummary on expression"); goTo.marker('18'); -verify.currentSignatureHelpDocCommentIs("On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.currentSignatureHelpDocCommentIs("On variable\nSummary on expression"); verify.currentParameterHelpArgumentDocCommentIs("the first parameter!\nparam on expression\nOn parameter "); diff --git a/tests/cases/fourslash/commentsLinePreservation.ts b/tests/cases/fourslash/commentsLinePreservation.ts index 9ccfd5c26a9..6d085f71f80 100644 --- a/tests/cases/fourslash/commentsLinePreservation.ts +++ b/tests/cases/fourslash/commentsLinePreservation.ts @@ -111,19 +111,19 @@ verify.quickInfos({ b: ["var b: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line"], c: ["var c: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line"], - d: ["function d(param: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line"], + d: ["function d(param: string): void", "This is firstLine\nThis is second Line"], 1: "(parameter) param: string", e: ["function e(param: string): void", "This is firstLine\nThis is second Line"], 2: "(parameter) param: string", - f: ["function f(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line"], + f: ["function f(param1: string): void", "This is firstLine\nThis is second Line"], 3: ["(parameter) param1: string", "first line of param\n\nparam information third line"], - g: ["function g(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line"], + g: ["function g(param1: string): void", "This is firstLine\nThis is second Line"], 4: ["(parameter) param1: string", "param information first line"], - h: ["function h(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line"], + h: ["function h(param1: string): void", "This is firstLine\nThis is second Line"], 5: ["(parameter) param1: string", "param information first line\n\nparam information third line"], i: ["function i(param1: string): void", "This is firstLine\nThis is second Line"], @@ -132,7 +132,7 @@ verify.quickInfos({ j: ["function j(param1: string): void", "This is firstLine\nThis is second Line"], 7: ["(parameter) param1: string", "param information first line\n\nparam information third line"], - k: ["function k(param1: string): void", "This is firstLine\nThis is second Line\n@randomtag \n\n random information first line\n\n random information third line"], + k: ["function k(param1: string): void", "This is firstLine\nThis is second Line"], 8: ["(parameter) param1: string", "hello "], l: ["function l(param1: string): void", "This is firstLine\nThis is second Line"], diff --git a/tests/cases/fourslash/commentsModules.ts b/tests/cases/fourslash/commentsModules.ts index f56b009081a..5f9457d81f4 100644 --- a/tests/cases/fourslash/commentsModules.ts +++ b/tests/cases/fourslash/commentsModules.ts @@ -126,8 +126,8 @@ verify.memberListContains("c", "constructor m1.m2.c(): m1.m2.c", ""); verify.memberListContains("i", "var m1.m2.i: m1.m2.c", "i"); goTo.marker('9'); -verify.completionListContains("m2", "namespace m2", ""); -verify.quickInfoIs("namespace m2"); +verify.completionListContains("m2", "namespace m2", "namespace comment of m2.m3"); +verify.quickInfoIs("namespace m2", "namespace comment of m2.m3"); goTo.marker('10'); verify.memberListContains("m3", "namespace m2.m3"); @@ -138,12 +138,12 @@ verify.quickInfoIs("constructor m2.m3.c(): m2.m3.c"); verify.memberListContains("c", "constructor m2.m3.c(): m2.m3.c", ""); goTo.marker('12'); -verify.completionListContains("m3", "namespace m3", ""); -verify.quickInfoIs("namespace m3"); +verify.completionListContains("m3", "namespace m3", "namespace comment of m3.m4.m5"); +verify.quickInfoIs("namespace m3", "namespace comment of m3.m4.m5"); goTo.marker('13'); -verify.memberListContains("m4", "namespace m3.m4", ""); -verify.quickInfoIs("namespace m3.m4"); +verify.memberListContains("m4", "namespace m3.m4", "namespace comment of m3.m4.m5"); +verify.quickInfoIs("namespace m3.m4", "namespace comment of m3.m4.m5"); goTo.marker('14'); verify.memberListContains("m5", "namespace m3.m4.m5"); @@ -154,12 +154,12 @@ verify.quickInfoIs("constructor m3.m4.m5.c(): m3.m4.m5.c"); verify.memberListContains("c", "constructor m3.m4.m5.c(): m3.m4.m5.c", ""); goTo.marker('16'); -verify.completionListContains("m4", "namespace m4", ""); -verify.quickInfoIs("namespace m4"); +verify.completionListContains("m4", "namespace m4", "namespace comment of m4.m5.m6"); +verify.quickInfoIs("namespace m4", "namespace comment of m4.m5.m6"); goTo.marker('17'); -verify.memberListContains("m5", "namespace m4.m5", ""); -verify.quickInfoIs("namespace m4.m5"); +verify.memberListContains("m5", "namespace m4.m5", "namespace comment of m4.m5.m6"); +verify.quickInfoIs("namespace m4.m5", "namespace comment of m4.m5.m6"); goTo.marker('18'); verify.memberListContains("m6", "namespace m4.m5.m6"); @@ -175,11 +175,11 @@ verify.quickInfoIs("constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c"); goTo.marker('21'); verify.completionListContains("m5", "namespace m5"); -verify.quickInfoIs("namespace m5"); +verify.quickInfoIs("namespace m5", "namespace comment of m5.m6.m7"); goTo.marker('22'); verify.memberListContains("m6", "namespace m5.m6"); -verify.quickInfoIs("namespace m5.m6"); +verify.quickInfoIs("namespace m5.m6", "namespace comment of m5.m6.m7"); goTo.marker('23'); verify.memberListContains("m7", "namespace m5.m6.m7"); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b8c84027053..5f86cbbafa4 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -111,6 +111,7 @@ declare namespace FourSlashInterface { bof(): void; eof(): void; type(definitionIndex?: number): void; + implementation(): void; position(position: number, fileIndex?: number): any; position(position: number, fileName?: string): any; file(index: number, content?: string, scriptKindName?: string): any; @@ -133,6 +134,7 @@ declare namespace FourSlashInterface { errorExistsBeforeMarker(markerName?: string): void; quickInfoExists(): void; typeDefinitionCountIs(expectedCount: number): void; + implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; } class verify extends verifyNegatable { @@ -250,6 +252,7 @@ declare namespace FourSlashInterface { getSyntacticDiagnostics(expected: string): void; getSemanticDiagnostics(expected: string): void; ProjectInfo(expected: string[]): void; + allRangesAppearInImplementationList(markerName: string): void; } class edit { backspace(count?: number): void; diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo1.ts b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts index b983ef0e4f0..95769764660 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo1.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts @@ -5,4 +5,4 @@ /////** @type {function(new:string,number)} */ ////var /**/v; -verify.quickInfoAt("", "var v: new (p1: number) => string", "@type {function(new:string,number)} "); +verify.quickInfoAt("", "var v: new (arg1: number) => string", undefined); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts index 144e0ac11d4..cdf2027e3a6 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts @@ -17,4 +17,4 @@ //// x - /**/a1() verify.quickInfoAt("", "function a1(p: any): number", - "This is a very cool function that is very nice.\n@returns something"); + "This is a very cool function that is very nice."); diff --git a/tests/cases/fourslash/goToImplementationClassMethod_00.ts b/tests/cases/fourslash/goToImplementationClassMethod_00.ts new file mode 100644 index 00000000000..6fc8d9bf7cc --- /dev/null +++ b/tests/cases/fourslash/goToImplementationClassMethod_00.ts @@ -0,0 +1,11 @@ +/// + +// Should handle calls made on members declared in a class + +//// class Bar { +//// [|hello() {}|] +//// } +//// +//// new Bar().hel/*reference*/lo; + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationClassMethod_01.ts b/tests/cases/fourslash/goToImplementationClassMethod_01.ts new file mode 100644 index 00000000000..7f59376a6ae --- /dev/null +++ b/tests/cases/fourslash/goToImplementationClassMethod_01.ts @@ -0,0 +1,18 @@ +/// + +// Should handle calls made on member declared in an abstract class + +//// abstract class AbstractBar { +//// abstract he/*declaration*/llo(): void; +//// } +//// +//// class Bar extends AbstractBar{ +//// [|hello() {}|] +//// } +//// +//// function whatever(x: AbstractBar) { +//// x.he/*reference*/llo(); +//// } + +verify.allRangesAppearInImplementationList("reference"); +verify.allRangesAppearInImplementationList("declaration"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationEnum_00.ts b/tests/cases/fourslash/goToImplementationEnum_00.ts new file mode 100644 index 00000000000..81e72b871a2 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationEnum_00.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls made on members of an enum + +//// enum Foo { +//// [|Foo1 = function initializer() { return 5 } ()|], +//// Foo2 = 6 +//// } +//// +//// Foo.Fo/*reference*/o1; + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationEnum_01.ts b/tests/cases/fourslash/goToImplementationEnum_01.ts new file mode 100644 index 00000000000..43273b6b03a --- /dev/null +++ b/tests/cases/fourslash/goToImplementationEnum_01.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls made on enum name + +//// [|enum Foo { +//// Foo1 = function initializer() { return 5 } (), +//// Foo2 = 6 +//// }|] +//// +//// Fo/*reference*/o; + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts new file mode 100644 index 00000000000..38afd0cfb3d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts @@ -0,0 +1,25 @@ +/// + +// Should return method implementations in object literals within variable-like declarations + +//// interface Foo { +//// he/*declaration*/llo: () => void +//// } +//// +//// var bar: Foo = { [|hello: helloImpl|] }; +//// var baz: Foo = { [|"hello": helloImpl|] }; +//// +//// function helloImpl () {} +//// +//// function whatever(x: Foo = { [|hello() {/**1*/}|] }) { +//// x.he/*function_call*/llo() +//// } +//// +//// class Bar { +//// x: Foo = { [|hello() {/*2*/}|] } +//// +//// constructor(public f: Foo = { [|hello() {/**3*/}|] } ) {} +//// } + +verify.allRangesAppearInImplementationList("function_call"); +verify.allRangesAppearInImplementationList("declaration"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts new file mode 100644 index 00000000000..8bd328bcb54 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts @@ -0,0 +1,22 @@ +/// + +// Should return implementations in a simple class + +//// interface Foo { +//// hel/*declaration*/lo(): void; +//// okay?: number; +//// } +//// +//// class Bar implements Foo { +//// [|hello() {}|] +//// public sure() {} +//// } +//// +//// function whatever(a: Foo) { +//// a.he/*function_call*/llo(); +//// } +//// +//// whatever(new Bar()); + +verify.allRangesAppearInImplementationList("function_call"); +verify.allRangesAppearInImplementationList("declaration"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts new file mode 100644 index 00000000000..82dceaad91c --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts @@ -0,0 +1,22 @@ +/// + +// Should return implementations when left hand side of function call is an abstract class + +//// interface Foo { +//// he/*declaration*/llo(): void +//// } +//// +//// abstract class AbstractBar implements Foo { +//// abstract hello(): void; +//// } +//// +//// class Bar extends AbstractBar { +//// [|hello() {}|] +//// } +//// +//// function whatever(a: AbstractBar) { +//// a.he/*function_call*/llo(); +//// } + +verify.allRangesAppearInImplementationList("function_call"); +verify.allRangesAppearInImplementationList("declaration"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts new file mode 100644 index 00000000000..8826cc1eab4 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts @@ -0,0 +1,24 @@ +/// + +// Should not return super implementations when method is implemented in class + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class Bar extends SuperBar { +//// [|hello() {}|] +//// } +//// +//// class SuperBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// class OtherBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// new Bar().hel/*function_call*/lo(); +//// new Bar()["hello"](); + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts new file mode 100644 index 00000000000..a9b825c717f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts @@ -0,0 +1,25 @@ +/// + +// Should return implementation in class and all sub-classes of target + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class Bar extends SuperBar { +//// [|hello() {}|] +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class OtherBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// function (x: SuperBar) { +//// x.he/*function_call*/llo() +//// } + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts new file mode 100644 index 00000000000..b051e16a929 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts @@ -0,0 +1,37 @@ +/// + +// Should not return implementations in classes with a shared parent that implements the interface + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class Bar extends SuperBar { +//// hello2() {} +//// } +//// +//// class OtherBar extends SuperBar { +//// hello() {} +//// hello2() {} +//// hello3() {} +//// } +//// +//// class NotRelatedToBar { +//// hello() {} // Equivalent to last case, but shares no common ancestors with Bar and so is not returned +//// hello2() {} +//// hello3() {} +//// } +//// +//// class NotBar extends SuperBar { +//// hello() {} // Should not be returned because it is not structurally equivalent to Bar +//// } +//// +//// function whatever(x: Bar) { +//// x.he/*function_call*/llo() +//// } + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts new file mode 100644 index 00000000000..b340270096d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts @@ -0,0 +1,48 @@ +/// + +// Should not return references to parent interfaces even if the method is declared there + +//// interface SuperFoo { +//// hello (): void; +//// } +//// +//// interface Foo extends SuperFoo { +//// someOtherFunction(): void; +//// } +//// +//// class Bar implements Foo { +//// [|hello() {}|] +//// someOtherFunction() {} +//// } +//// +//// function createFoo(): Foo { +//// return { +//// [|hello() {}|], +//// someOtherFunction() {} +//// }; +//// } +//// +//// var y: Foo = { +//// [|hello() {}|], +//// someOtherFunction() {} +//// }; +//// +//// class FooLike implements SuperFoo { +//// hello() {} +//// someOtherFunction() {} +//// } +//// +//// class NotRelatedToFoo { +//// hello() {} // This case is equivalent to the last case, but is not returned because it does not share a common ancestor with Foo +//// someOtherFunction() {} +//// } +//// +//// class NotFoo implements SuperFoo { +//// hello() {} // We only want implementations of Foo, even though the function is declared in SuperFoo +//// } +//// +//// function (x: Foo) { +//// x.he/*function_call*/llo() +//// } + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts new file mode 100644 index 00000000000..d2038f99efd --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts @@ -0,0 +1,22 @@ +/// + +// Should handle calls made on this + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class Bar extends SuperBar { +//// whatever() { this.he/*function_call*/llo(); } +//// } +//// +//// class SubBar extends Bar { +//// [|hello() {}|] +//// } + + +verify.allRangesAppearInImplementationList("function_call"); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts new file mode 100644 index 00000000000..84c57ec2bce --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts @@ -0,0 +1,31 @@ +/// + +// Should handle calls made on super + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SubBar extends Bar { +//// hello() {} +//// } +//// +//// class Bar extends SuperBar { +//// hello() {} +//// +//// whatever() { +//// super.he/*function_call*/llo(); +//// super["hel/*element_access*/lo"](); +//// } +//// } +//// +//// class SuperBar extends MegaBar { +//// [|hello() {}|] +//// } +//// +//// class MegaBar implements Foo { +//// hello() {} +//// } + +verify.allRangesAppearInImplementationList("function_call"); +verify.allRangesAppearInImplementationList("element_access"); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts new file mode 100644 index 00000000000..0604d2511f2 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts @@ -0,0 +1,48 @@ +/// + +// Should handle union and intersection types + +//// interface BaseFoo { +//// hello(): void; +//// } +//// +//// interface Foo extends BaseFoo { +//// aloha(): void; +//// } +//// +//// interface Bar { +//// hello(): void; +//// goodbye(): void; +//// } +//// +//// class FooImpl implements Foo { +//// [|hello() {/**FooImpl*/}|] +//// aloha() {} +//// } +//// +//// class BaseFooImpl implements BaseFoo { +//// hello() {/**BaseFooImpl*/} // Should not show up +//// } +//// +//// class BarImpl implements Bar { +//// [|hello() {/**BarImpl*/}|] +//// goodbye() {} +//// } +//// +//// class FooAndBarImpl implements Foo, Bar { +//// [|hello() {/**FooAndBarImpl*/}|] +//// aloha() {} +//// goodbye() {} +//// } +//// +//// function someFunction(x: Foo | Bar) { +//// x.he/*function_call0*/llo(); +//// } +//// +//// function anotherFunction(x: Foo & Bar) { +//// x.he/*function_call1*/llo(); +//// } + +for (var i = 0; i < 2; i++) { + verify.allRangesAppearInImplementationList("function_call" + i); +} diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts new file mode 100644 index 00000000000..9528aa409b4 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts @@ -0,0 +1,12 @@ +/// + +// Should handle members of object literals in type assertion expressions + +//// interface Foo { +//// hel/*reference*/lo(): void; +//// } +//// +//// var x = { [|hello: () => {}|] }; +//// var y = (((({ [|hello: () => {}|] })))); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts b/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts new file mode 100644 index 00000000000..70e49c10b45 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts @@ -0,0 +1,22 @@ +/// + +// Should handle property assignments in object literals within variable like declarations + +//// interface Foo { +//// hello: number +//// } +//// +//// var bar: Foo = { [|hello: 5|] }; +//// +//// +//// function whatever(x: Foo = { [|hello: 5 * 9|] }) { +//// x.he/*reference*/llo +//// } +//// +//// class Bar { +//// x: Foo = { [|hello: 6|] } +//// +//// constructor(public f: Foo = { [|hello: 7|] } ) {} +//// } + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts b/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts new file mode 100644 index 00000000000..14b80362917 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts @@ -0,0 +1,15 @@ +/// + +// Should handle property assignments within class declarations + +//// interface Foo { hello: number } +//// +//// class Bar implements Foo { +//// [|hello = 5 * 9;|] +//// } +//// +//// function whatever(foo: Foo) { +//// foo.he/*reference*/llo; +//// } + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_00.ts b/tests/cases/fourslash/goToImplementationInterface_00.ts new file mode 100644 index 00000000000..8fc36b4bab5 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_00.ts @@ -0,0 +1,25 @@ +/// + +// Should go to definitions in object literals in variable like declarations when invoked on interface + +//// interface Fo/*interface_definition*/o { +//// hello: () => void +//// } +//// +//// interface Baz extends Foo {} +//// +//// var bar: Foo = [|{ hello: helloImpl /**0*/ }|]; +//// var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|]; +//// +//// function helloImpl () {} +//// +//// function whatever(x: Foo = [|{ hello() {/**1*/} }|] ) { +//// } +//// +//// class Bar { +//// x: Foo = [|{ hello() {/*2*/} }|] +//// +//// constructor(public f: Foo = [|{ hello() {/**3*/} }|] ) {} +//// } + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_01.ts b/tests/cases/fourslash/goToImplementationInterface_01.ts new file mode 100644 index 00000000000..62d01da6ca8 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_01.ts @@ -0,0 +1,24 @@ +/// + +//// interface Fo/*interface_definition*/o { hello(): void } +//// +//// [|class SuperBar implements Foo { +//// hello () {} +//// }|] +//// +//// [|abstract class AbstractBar implements Foo { +//// abstract hello (): void; +//// }|] +//// +//// class Bar extends SuperBar { +//// } +//// +//// class NotAbstractBar extends AbstractBar { +//// hello () {} +//// } +//// +//// var x = new SuperBar(); +//// var y: SuperBar = new SuperBar(); +//// var z: AbstractBar = new NotAbstractBar(); + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_02.ts b/tests/cases/fourslash/goToImplementationInterface_02.ts new file mode 100644 index 00000000000..27f29465a9a --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_02.ts @@ -0,0 +1,28 @@ +/// + +// Should go to definitions in object literals in return statements of functions with the type of the interface + +//// interface Fo/*interface_definition*/o { hello: () => void } +//// +//// let x: number = 9; +//// +//// function createFoo(): Foo { +//// if (x === 2) { +//// return [|{ +//// hello() {} +//// }|]; +//// } +//// return [|{ +//// hello() {} +//// }|]; +//// } +//// +//// let createFoo2 = (): Foo => [|({hello() {}})|]; +//// +//// function createFooLike() { +//// return { +//// hello() {} +//// }; +//// } + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_03.ts b/tests/cases/fourslash/goToImplementationInterface_03.ts new file mode 100644 index 00000000000..1c63852dafc --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_03.ts @@ -0,0 +1,9 @@ +/// + +// Should go to object literals within cast expressions when invoked on interface + +//// interface Fo/*interface_definition*/o { hello: () => void } +//// +//// var x = [|{ hello: () => {} }|]; + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_04.ts b/tests/cases/fourslash/goToImplementationInterface_04.ts new file mode 100644 index 00000000000..febc511388d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_04.ts @@ -0,0 +1,20 @@ +/// + +// Should go to function literals that implement the interface within variable like declarations when invoked on an interface + +//// interface Fo/*interface_definition*/o { +//// (a: number): void +//// } +//// +//// var bar: Foo = [|(a) => {/**0*/}|]; +//// +//// function whatever(x: Foo = [|(a) => {/**1*/}|] ) { +//// } +//// +//// class Bar { +//// x: Foo = [|(a) => {/**2*/}|] +//// +//// constructor(public f: Foo = [|function(a) {}|] ) {} +//// } + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_05.ts b/tests/cases/fourslash/goToImplementationInterface_05.ts new file mode 100644 index 00000000000..3b31b89b528 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_05.ts @@ -0,0 +1,12 @@ +/// + +// Should go to function literals that implement the interface within type assertions when invoked on an interface + +//// interface Fo/*interface_definition*/o { +//// (a: number): void +//// } +//// +//// let bar2 = [|function(a) {}|]; +//// + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_06.ts b/tests/cases/fourslash/goToImplementationInterface_06.ts new file mode 100644 index 00000000000..15f52132868 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_06.ts @@ -0,0 +1,14 @@ +/// + +// Should go to class expressions that implement a constructor type + +//// interface Fo/*interface_definition*/o { +//// new (a: number): SomeOtherType; +//// } +//// +//// interface SomeOtherType {} +//// +//// let x: Foo = [|class { constructor (a: number) {} }|]; +//// let y = [|class { constructor (a: number) {} }|]; + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_07.ts b/tests/cases/fourslash/goToImplementationInterface_07.ts new file mode 100644 index 00000000000..6d874b3dc76 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_07.ts @@ -0,0 +1,28 @@ +/// + +// Should handle all the various type references + +//// interface Fo/*interface_definition*/o { +//// hello (): void; +//// } +//// +//// interface Bar { +//// hello (): void; +//// } +//// +//// let x1: Foo = [|{ hello () { /**typeReference*/ } }|]; +//// let x2: () => Foo = [|(() => { hello () { /**functionType*/} })|]; +//// let x3: Foo | Bar = [|{ hello () { /**unionType*/} }|]; +//// let x4: Foo & (Foo & Bar) = [|{ hello () { /**intersectionType*/} }|]; +//// let x5: [Foo] = [|[{ hello () { /**tupleType*/} }]|]; +//// let x6: (Foo) = [|{ hello () { /**parenthesizedType*/} }|]; +//// let x7: (new() => Foo) = [|class { hello () { /**constructorType*/} }|]; +//// let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|]; +//// let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|]; +//// +//// // Should not do anything for type predicates +//// function isFoo(a: any): a is Foo { +//// return true; +//// } + +verify.allRangesAppearInImplementationList("interface_definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_08.ts b/tests/cases/fourslash/goToImplementationInterface_08.ts new file mode 100644 index 00000000000..652cfe46246 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_08.ts @@ -0,0 +1,21 @@ +/// + +// Should not hang on inheritance loops + +//// interface Base { +//// hello (): void; +//// } +//// +//// interface A extends Base {} +//// interface B extends C, A {} +//// interface C extends B, A {} +//// +//// class X implements B { +//// [|hello() {}|] +//// } +//// +//// function someFunction(d : A) { +//// d.he/*function_call*/llo(); +//// } + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInvalid.ts b/tests/cases/fourslash/goToImplementationInvalid.ts new file mode 100644 index 00000000000..52b2773342e --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInvalid.ts @@ -0,0 +1,12 @@ +/// + +// Should not crash when invoked on an invalid location + +//// var x1 = 50/*0*/0; +//// var x2 = "hel/*1*/lo"; +//// /*2*/ + +for(var i = 0; i < 3; i++) { + goTo.marker("" + i); + verify.implementationListIsEmpty(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_00.ts b/tests/cases/fourslash/goToImplementationLocal_00.ts new file mode 100644 index 00000000000..b97fadfcb02 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_00.ts @@ -0,0 +1,8 @@ +/// + +// Should return definition of locally declared functions + +//// he/*function_call*/llo(); +//// [|function hello() {}|] + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_01.ts b/tests/cases/fourslash/goToImplementationLocal_01.ts new file mode 100644 index 00000000000..0bda3418354 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_01.ts @@ -0,0 +1,8 @@ +/// + +// Should return the defintion of locally defined variables + +//// const [|hello = function() {}|]; +//// he/*function_call*/llo(); + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_02.ts b/tests/cases/fourslash/goToImplementationLocal_02.ts new file mode 100644 index 00000000000..62bb8a71a10 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_02.ts @@ -0,0 +1,8 @@ +/// + +//// const x = { [|hello: () => {}|] }; +//// +//// x.he/*function_call*/llo(); +//// + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_03.ts b/tests/cases/fourslash/goToImplementationLocal_03.ts new file mode 100644 index 00000000000..d3f25ea29dc --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_03.ts @@ -0,0 +1,12 @@ +/// + +// Should return the definition when invoked on variable assignment + +//// let [|he/*local_var*/llo = {}|]; +//// +//// x.hello(); +//// +//// hello = {}; +//// + +verify.allRangesAppearInImplementationList("local_var"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_04.ts b/tests/cases/fourslash/goToImplementationLocal_04.ts new file mode 100644 index 00000000000..9de9dcd0a9f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_04.ts @@ -0,0 +1,10 @@ +/// + +// Should return definition of function when invoked on the declaration + +//// [|function he/*local_var*/llo() {}|] +//// +//// hello(); +//// + +verify.allRangesAppearInImplementationList("local_var"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_05.ts b/tests/cases/fourslash/goToImplementationLocal_05.ts new file mode 100644 index 00000000000..969f4c25fc7 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_05.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls made the left hand side of a property access expression + +//// class Bar { +//// public hello() {} +//// } +//// +//// var [|someVar = new Bar()|]; +//// someVa/*reference*/r.hello(); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_06.ts b/tests/cases/fourslash/goToImplementationLocal_06.ts new file mode 100644 index 00000000000..acdbaffc36f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_06.ts @@ -0,0 +1,8 @@ +/// + +// Should be able to go to ambient variable declarations + +//// declare var [|someVar: string|]; +//// someVa/*reference*/r + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_07.ts b/tests/cases/fourslash/goToImplementationLocal_07.ts new file mode 100644 index 00000000000..3556c25abc0 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_07.ts @@ -0,0 +1,8 @@ +/// + +// Should be able to go to ambient function declarations + +//// [|declare function someFunction(): () => void;|] +//// someFun/*reference*/ction(); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_08.ts b/tests/cases/fourslash/goToImplementationLocal_08.ts new file mode 100644 index 00000000000..3556c25abc0 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_08.ts @@ -0,0 +1,8 @@ +/// + +// Should be able to go to ambient function declarations + +//// [|declare function someFunction(): () => void;|] +//// someFun/*reference*/ction(); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_00.ts b/tests/cases/fourslash/goToImplementationNamespace_00.ts new file mode 100644 index 00000000000..5b71b7bbf9f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_00.ts @@ -0,0 +1,20 @@ +/// + +// Should handle namespace and module implementations + +//// /*implementation0*/namespace Foo { +//// export function hello() {} +//// } +//// +//// /*implementation1*/module Bar { +//// export function sure() {} +//// } +//// +//// let x = Fo/*reference0*/o; +//// let y = Ba/*reference1*/r; + +for (let i = 0; i < 2; i ++) { + goTo.marker("reference" + i); + goTo.implementation(); + verify.caretAtMarker("implementation" + i); +} \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_01.ts b/tests/cases/fourslash/goToImplementationNamespace_01.ts new file mode 100644 index 00000000000..b2e267d5378 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_01.ts @@ -0,0 +1,11 @@ +/// + +// Should handle property access expressions on namespaces + +//// namespace Foo { +//// [|export function hello() {}|] +//// } +//// +//// Foo.hell/*reference*/o(); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_02.ts b/tests/cases/fourslash/goToImplementationNamespace_02.ts new file mode 100644 index 00000000000..2d2ae960a99 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_02.ts @@ -0,0 +1,11 @@ +/// + +// Should handle property access expressions on namespaces + +//// module Foo { +//// [|export function hello() {}|] +//// } +//// +//// Foo.hell/*reference*/o(); + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_03.ts b/tests/cases/fourslash/goToImplementationNamespace_03.ts new file mode 100644 index 00000000000..751d182ec00 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_03.ts @@ -0,0 +1,27 @@ +/// + +// Should handle types that are members of a namespace in type references and heritage clauses + +//// namespace Foo { +//// export interface Bar { +//// hello(): void; +//// } +//// +//// [|class BarImpl implements Bar { +//// hello() {} +//// }|] +//// } +//// +//// [|class Baz implements Foo.Bar { +//// hello() {} +//// }|] +//// +//// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; +//// +//// var someVar2 = [|{ hello: () => {/**2*/} }|]; +//// +//// function whatever(x: Foo.Ba/*reference*/r) { +//// +//// } + +verify.allRangesAppearInImplementationList("reference"); diff --git a/tests/cases/fourslash/goToImplementationNamespace_04.ts b/tests/cases/fourslash/goToImplementationNamespace_04.ts new file mode 100644 index 00000000000..ac0b85e43fe --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_04.ts @@ -0,0 +1,27 @@ +/// + +// Should handle types that are members of a module in type references and heritage clauses + +//// module Foo { +//// export interface Bar { +//// hello(): void; +//// } +//// +//// [|class BarImpl implements Bar { +//// hello() {} +//// }|] +//// } +//// +//// [|class Baz implements Foo.Bar { +//// hello() {} +//// }|] +//// +//// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; +//// +//// var someVar2 = [|{ hello: () => {/**2*/} }|]; +//// +//// function whatever(x: Foo.Ba/*reference*/r) { +//// +//// } + +verify.allRangesAppearInImplementationList("reference"); diff --git a/tests/cases/fourslash/goToImplementationNamespace_05.ts b/tests/cases/fourslash/goToImplementationNamespace_05.ts new file mode 100644 index 00000000000..6936b79bd9b --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_05.ts @@ -0,0 +1,22 @@ +/// + +// Should handle namespace and module implementations with qualified names + +//// /*implementation0*/namespace Foo./*implementation2*/Baz { +//// export function hello() {} +//// } +//// +//// /*implementation1*/module Bar./*implementation3*/Baz { +//// export function sure() {} +//// } +//// +//// let x = Fo/*reference0*/o; +//// let y = Ba/*reference1*/r; +//// let x1 = Foo.B/*reference2*/az; +//// let y1 = Bar.B/*reference3*/az; + +for (let i = 0; i < 4; i ++) { + goTo.marker("reference" + i); + goTo.implementation(); + verify.caretAtMarker("implementation" + i); +} \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_06.ts b/tests/cases/fourslash/goToImplementationNamespace_06.ts new file mode 100644 index 00000000000..f5e52d90b1c --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_06.ts @@ -0,0 +1,12 @@ +/// + +// Should handle type queries + +//// [|namespace F/*declaration*/oo { +//// declare function hello(): void; +//// }|] +//// +//// +//// let x: typeof Foo = [|{ hello() {} }|]; + +verify.allRangesAppearInImplementationList("declaration"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts new file mode 100644 index 00000000000..ad4a0cd6b51 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts @@ -0,0 +1,43 @@ +/// + +// Should handle shorthand property assignments of class constructors + +//// interface Foo { +//// someFunction(): void; +//// } +//// +//// interface FooConstructor { +//// new (): Foo +//// } +//// +//// interface Bar { +//// Foo: FooConstructor; +//// } +//// +//// var x = /*classExpression*/class Foo { +//// createBarInClassExpression(): Bar { +//// return { +//// Fo/*classExpressionRef*/o +//// }; +//// } +//// +//// someFunction() {} +//// } +//// +//// /*declaredClass*/class Foo { +//// +//// } +//// +//// function createBarUsingClassDeclaration(): Bar { +//// return { +//// Fo/*declaredClassRef*/o +//// }; +//// } + +goTo.marker("classExpressionRef"); +goTo.implementation(); +verify.caretAtMarker("classExpression"); + +goTo.marker("declaredClassRef"); +goTo.implementation(); +verify.caretAtMarker("declaredClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts new file mode 100644 index 00000000000..fb4763619a4 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts @@ -0,0 +1,47 @@ +/// + +// Should handle shorthand property assignments of class constructors when invoked on member of interface + +//// interface Foo { +//// someFunction(): void; +//// } +//// +//// interface FooConstructor { +//// new (): Foo +//// } +//// +//// interface Bar { +//// Foo: FooConstructor; +//// } +//// +//// // Class expression that gets used in a bar implementation +//// var x = [|class Foo { +//// createBarInClassExpression(): Bar { +//// return { +//// Foo +//// }; +//// } +//// +//// someFunction() {} +//// }|]; +//// +//// // Class declaration that gets used in a bar implementation. This class has multiple definitions +//// // (the class declaration and the interface above), but we only want the class returned +//// [|class Foo { +//// +//// }|] +//// +//// function createBarUsingClassDeclaration(): Bar { +//// return { +//// Foo +//// }; +//// } +//// +//// // Class expression that does not get used in a bar implementation +//// var y = class Foo { +//// someFunction() {} +//// }; +//// +//// createBarUsingClassDeclaration().Fo/*reference*/o; + +verify.allRangesAppearInImplementationList("reference"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts new file mode 100644 index 00000000000..a27480c8272 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts @@ -0,0 +1,21 @@ +/// + +// Should go to implementation of properties that are assigned to implementations of an interface using shorthand notation + +//// interface Foo { +//// hello(): void; +//// } +//// +//// function createFoo(): Foo { +//// return { +//// hello +//// }; +//// +//// [|function hello() {}|] +//// } +//// +//// function whatever(x: Foo) { +//// x.h/*function_call*/ello(); +//// } + +verify.allRangesAppearInImplementationList("function_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationSuper_00.ts b/tests/cases/fourslash/goToImplementationSuper_00.ts new file mode 100644 index 00000000000..53377bdcdb0 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationSuper_00.ts @@ -0,0 +1,15 @@ +/// + +// Should go to super class declaration when invoked on a super call expression + +//// [|class Foo { +//// constructor() {} +//// }|] +//// +//// class Bar extends Foo { +//// constructor() { +//// su/*super_call*/per(); +//// } +//// } + +verify.allRangesAppearInImplementationList("super_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationSuper_01.ts b/tests/cases/fourslash/goToImplementationSuper_01.ts new file mode 100644 index 00000000000..fffa7caf716 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationSuper_01.ts @@ -0,0 +1,15 @@ +/// + +// Should go to the super class declaration when invoked on the super keyword in a property access expression + +//// [|class Foo { +//// hello() {} +//// }|] +//// +//// class Bar extends Foo { +//// hello() { +//// sup/*super_call*/er.hello(); +//// } +//// } + +verify.allRangesAppearInImplementationList("super_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationThis_00.ts b/tests/cases/fourslash/goToImplementationThis_00.ts new file mode 100644 index 00000000000..19212c9a77a --- /dev/null +++ b/tests/cases/fourslash/goToImplementationThis_00.ts @@ -0,0 +1,13 @@ +/// + +// Should go to class declaration when invoked on this keyword in property access expression + +//// [|class Bar extends Foo { +//// hello() { +//// thi/*this_call*/s.whatever(); +//// } +//// +//// whatever() {} +//// }|] + +verify.allRangesAppearInImplementationList("this_call"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationThis_01.ts b/tests/cases/fourslash/goToImplementationThis_01.ts new file mode 100644 index 00000000000..6761c6ec6c9 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationThis_01.ts @@ -0,0 +1,11 @@ +/// + +// Should go to class declaration when invoked on a this type reference + +//// [|class Bar extends Foo { +//// hello(): th/*this_type*/is { +//// return this; +//// } +//// }|] + +verify.allRangesAppearInImplementationList("this_type"); \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocFunctionSignatures10.ts b/tests/cases/fourslash/jsDocFunctionSignatures10.ts new file mode 100644 index 00000000000..60810c46e70 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures10.ts @@ -0,0 +1,15 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Do some foo things +//// * @template T A Foolish template +//// * @param {T} x a parameter +//// */ +////function foo(x) { +////} +//// +////fo/**/o() + +goTo.marker(); +verify.quickInfoIs("function foo(x: T): void", "Do some foo things"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures11.ts b/tests/cases/fourslash/jsDocFunctionSignatures11.ts new file mode 100644 index 00000000000..26b2cda6d2a --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures11.ts @@ -0,0 +1,9 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @type {{ [name: string]: string; }} variables +//// */ +////const vari/**/ables = {}; +goTo.marker(); +verify.quickInfoIs("const variables: {\n [name: string]: string;\n}"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures12.ts b/tests/cases/fourslash/jsDocFunctionSignatures12.ts new file mode 100644 index 00000000000..29a8ac4caeb --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures12.ts @@ -0,0 +1,13 @@ + +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {{ stringProp: string, +//// * numProp: number }} o +//// */ +////function f1(o) { +//// o/**/; +////} +goTo.marker(); +verify.quickInfoIs("(parameter) o: any"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures2.ts b/tests/cases/fourslash/jsDocFunctionSignatures2.ts index 174ea7d6560..e6430cba5bd 100644 --- a/tests/cases/fourslash/jsDocFunctionSignatures2.ts +++ b/tests/cases/fourslash/jsDocFunctionSignatures2.ts @@ -9,4 +9,4 @@ //// f6('', /**/false) goTo.marker(); -verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number') +verify.currentSignatureHelpIs('f6(arg0: string, arg1?: boolean): number') diff --git a/tests/cases/fourslash/jsDocFunctionSignatures5.ts b/tests/cases/fourslash/jsDocFunctionSignatures5.ts new file mode 100644 index 00000000000..08d0da990bc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures5.ts @@ -0,0 +1,18 @@ +/// +// @allowJs: true +// @Filename: Foo.js + +/////** +//// * Filters a path based on a regexp or glob pattern. +//// * @param {String} basePath The base path where the search will be performed. +//// * @param {String} pattern A string defining a regexp of a glob pattern. +//// * @param {String} type The search pattern type, can be a regexp or a glob. +//// * @param {Object} options A object containing options to the search. +//// * @return {Array} A list containing the filtered paths. +//// */ +////function pathFilter(basePath, pattern, type, options){ +//////... +////} +////pathFilter(/**/'foo', 'bar', 'baz', {}); +goTo.marker(); +verify.currentSignatureHelpDocCommentIs("Filters a path based on a regexp or glob pattern."); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures6.ts b/tests/cases/fourslash/jsDocFunctionSignatures6.ts new file mode 100644 index 00000000000..10b290d6d02 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures6.ts @@ -0,0 +1,19 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p1 - A string param +//// * @param {string?} p2 - An optional param +//// * @param {string} [p3] - Another optional param +//// * @param {string} [p4="test"] - An optional param with a default value +//// */ +////function f1(p1, p2, p3, p4){} +////f1(/*1*/'foo', /*2*/'bar', /*3*/'baz', /*4*/'qux'); +goTo.marker('1'); +verify.currentParameterHelpArgumentDocCommentIs("- A string param"); +goTo.marker('2'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param "); +goTo.marker('3'); +verify.currentParameterHelpArgumentDocCommentIs("- Another optional param"); +goTo.marker('4'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param with a default value"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures7.ts b/tests/cases/fourslash/jsDocFunctionSignatures7.ts new file mode 100644 index 00000000000..6bbb8a34dcc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures7.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p0 +//// * @param {string} [p1] +//// */ +////function Test(p0, p1) { +//// this.P0 = p0; +//// this.P1 = p1; +////} +//// +//// +////var /**/test = new Test(""); +goTo.marker(); +verify.quickInfoIs('var test: {\n P0: string;\n P1: string;\n}'); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures8.ts b/tests/cases/fourslash/jsDocFunctionSignatures8.ts new file mode 100644 index 00000000000..3dbe38e34df --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures8.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Represents a person +//// * @constructor +//// * @param {string} name The name of the person +//// * @param {number} age The age of the person +//// */ +////function Person(name, age) { +//// this.name = name; +//// this.age = age; +////} +////var p = new Pers/**/on(); +goTo.marker(); +verify.quickInfoIs("function Person(name: string, age: number): void", "Represents a person"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures9.ts b/tests/cases/fourslash/jsDocFunctionSignatures9.ts new file mode 100644 index 00000000000..26361bfe106 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures9.ts @@ -0,0 +1,22 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** first line of the comment +//// +////third line */ +////function foo() {} +////foo/**/(); +goTo.marker(); +verify.verifyQuickInfoDisplayParts('function', + '', + { start: 63, length: 3 }, + [{"text": "function", "kind": "keyword"}, + {"text": " ", "kind": "space"}, + {"text": "foo", "kind": "functionName"}, + {"text": "(", "kind": "punctuation"}, + {"text": ")", "kind": "punctuation"}, + {"text": ":", "kind": "punctuation"}, + {"text": " ", "kind": "space"}, + {"text": "void", "kind": "keyword"} + ], + [{"text": "first line of the comment\n\nthird line ", "kind": "text"}]); diff --git a/tests/cases/fourslash/jsdocReturnsTag.ts b/tests/cases/fourslash/jsdocReturnsTag.ts new file mode 100644 index 00000000000..9203bd9e036 --- /dev/null +++ b/tests/cases/fourslash/jsdocReturnsTag.ts @@ -0,0 +1,17 @@ +/// +// @allowJs: true +// @Filename: dummy.js +/////** +//// * Find an item +//// * @template T +//// * @param {T[]} l +//// * @param {T} x +//// * @returns {?T} The names of the found item(s). +//// */ +////function find(l, x) { +////} +////find(''/**/); + +goTo.marker(); +verify.currentSignatureHelpIs("find(l: T[], x: T): T") +// There currently isn't a way to display the return tag comment diff --git a/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts new file mode 100644 index 00000000000..8746f135e4d --- /dev/null +++ b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts @@ -0,0 +1,18 @@ +/// + +/////** Test */ +////export const Test = {} + +verify.navigationBar([ + { + "text": "\"navigationBarJsDocCommentWithNoTags\"", + "kind": "module", + "childItems": [ + { + "text": "Test", + "kind": "const", + "kindModifiers": "export" + } + ] + } +]); diff --git a/tests/cases/fourslash/server/implementation01.ts b/tests/cases/fourslash/server/implementation01.ts new file mode 100644 index 00000000000..24d5f935bda --- /dev/null +++ b/tests/cases/fourslash/server/implementation01.ts @@ -0,0 +1,9 @@ +/// + +// @Filename: a.ts +//// interface Fo/*1*/o {} +//// /*2*/class Bar implements Foo {} + +goTo.marker('1'); +goTo.implementation(); +verify.caretAtMarker('2'); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts b/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts new file mode 100644 index 00000000000..a509922f919 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: goToImplementationDifferentFile_Implementation.ts +//// /*fooClassImplementation*/class FooImpl implements Foo {} +//// +//// /*barClassImplementation*/class Bar { +//// /*barHelloFunctionImplementation*/hello() {} +//// } +//// + +// @Filename: goToImplementationDifferentFile_Consumption.ts +//// interface Fo/*fooClassReference*/o {} +//// +//// var x = new B/*barClassReference*/ar(); +//// +//// x.hel/*barHelloFunctionReference*/lo(); +//// +//// /*thisImplementation*/class SomeClass { +//// someMethod() { +//// thi/*thisReference*/s.someMethod(); +//// } +//// } + +var markerList = [ + "fooClass", + "barClass", + "barHelloFunction", + "this" +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.implementation(); + verify.caretAtMarker(marker + 'Implementation'); +}); diff --git a/tests/cases/fourslash/shims/getImplementationAtPosition.ts b/tests/cases/fourslash/shims/getImplementationAtPosition.ts new file mode 100644 index 00000000000..a509922f919 --- /dev/null +++ b/tests/cases/fourslash/shims/getImplementationAtPosition.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: goToImplementationDifferentFile_Implementation.ts +//// /*fooClassImplementation*/class FooImpl implements Foo {} +//// +//// /*barClassImplementation*/class Bar { +//// /*barHelloFunctionImplementation*/hello() {} +//// } +//// + +// @Filename: goToImplementationDifferentFile_Consumption.ts +//// interface Fo/*fooClassReference*/o {} +//// +//// var x = new B/*barClassReference*/ar(); +//// +//// x.hel/*barHelloFunctionReference*/lo(); +//// +//// /*thisImplementation*/class SomeClass { +//// someMethod() { +//// thi/*thisReference*/s.someMethod(); +//// } +//// } + +var markerList = [ + "fooClass", + "barClass", + "barHelloFunction", + "this" +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.implementation(); + verify.caretAtMarker(marker + 'Implementation'); +});