diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e7235914f8ae..4095b0b4b5c7a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5838,6 +5838,8 @@ namespace ts { initializer: Expression | undefined ) => T, methodKind: SyntaxKind, useAccessors: boolean): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => (T | AccessorDeclaration | (T | AccessorDeclaration)[]) { return function serializePropertySymbol(p: Symbol, isStatic: boolean, baseType: Type | undefined) { + const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); + const isPrivate = !!(modifierFlags & ModifierFlags.Private); if (isStatic && (p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members @@ -5849,7 +5851,7 @@ namespace ts { && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)!))) { return []; } - const staticFlag = isStatic ? ModifierFlags.Static : 0; + const flag = modifierFlags | (isStatic ? ModifierFlags.Static : 0); const name = getPropertyNameNodeForSymbol(p, context); const firstPropertyLikeDecl = find(p.declarations, or(isPropertyDeclaration, isAccessor, isVariableDeclaration, isPropertySignature, isBinaryExpression, isPropertyAccessExpression)); if (p.flags & SymbolFlags.Accessor && useAccessors) { @@ -5857,7 +5859,7 @@ namespace ts { if (p.flags & SymbolFlags.SetAccessor) { result.push(setTextRange(createSetAccessor( /*decorators*/ undefined, - createModifiersFromModifierFlags(staticFlag), + createModifiersFromModifierFlags(flag), name, [createParameter( /*decorators*/ undefined, @@ -5865,18 +5867,19 @@ namespace ts { /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, - serializeTypeForDeclaration(getTypeOfSymbol(p), p) + isPrivate ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p) )], /*body*/ undefined ), find(p.declarations, isSetAccessor) || firstPropertyLikeDecl)); } if (p.flags & SymbolFlags.GetAccessor) { + const isPrivate = modifierFlags & ModifierFlags.Private; result.push(setTextRange(createGetAccessor( /*decorators*/ undefined, - createModifiersFromModifierFlags(staticFlag), + createModifiersFromModifierFlags(flag), name, [], - serializeTypeForDeclaration(getTypeOfSymbol(p), p), + isPrivate ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p), /*body*/ undefined ), find(p.declarations, isGetAccessor) || firstPropertyLikeDecl)); } @@ -5887,10 +5890,10 @@ namespace ts { else if (p.flags & (SymbolFlags.Property | SymbolFlags.Variable)) { return setTextRange(createProperty( /*decorators*/ undefined, - createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | staticFlag), + createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), name, p.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined, - serializeTypeForDeclaration(getTypeOfSymbol(p), p), + isPrivate ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined @@ -5899,13 +5902,24 @@ namespace ts { if (p.flags & (SymbolFlags.Method | SymbolFlags.Function)) { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, SignatureKind.Call); + if (flag & ModifierFlags.Private) { + return setTextRange(createProperty( + /*decorators*/ undefined, + createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), + name, + p.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined, + /*type*/ undefined, + /*initializer*/ undefined + ), find(p.declarations, isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + } + const results = []; for (const sig of signatures) { // Each overload becomes a separate method declaration, in order const decl = signatureToSignatureDeclarationHelper(sig, methodKind, context) as MethodDeclaration; decl.name = name; // TODO: Clone - if (staticFlag) { - decl.modifiers = createNodeArray(createModifiersFromModifierFlags(staticFlag)); + if (flag) { + decl.modifiers = createNodeArray(createModifiersFromModifierFlags(flag)); } if (p.flags & SymbolFlags.Optional) { decl.questionToken = createToken(SyntaxKind.QuestionToken); @@ -6093,6 +6107,20 @@ namespace ts { } } } + let privateProtected: ModifierFlags = 0; + for (const s of signatures) { + if (s.declaration) { + privateProtected |= getSelectedModifierFlags(s.declaration, ModifierFlags.Private | ModifierFlags.Protected); + } + } + if (privateProtected) { + return [setTextRange(createConstructor( + /*decorators*/ undefined, + createModifiersFromModifierFlags(privateProtected), + /*parameters*/ [], + /*body*/ undefined, + ), signatures[0].declaration)]; + } } const results = []; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0cda1e4d1d8c2..6e4e168e2ca77 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -506,6 +506,9 @@ namespace ts { return forEach((node as JSDocTypeLiteral).jsDocPropertyTags, cbNode); case SyntaxKind.JSDocTag: case SyntaxKind.JSDocClassTag: + case SyntaxKind.JSDocPublicTag: + case SyntaxKind.JSDocPrivateTag: + case SyntaxKind.JSDocProtectedTag: return visitNode(cbNode, (node as JSDocTag).tagName); case SyntaxKind.PartiallyEmittedExpression: return visitNode(cbNode, (node).expression); @@ -2581,7 +2584,7 @@ namespace ts { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); - if (getFullWidth(node.name) === 0 && !hasModifiers(node) && isModifierKind(token())) { + if (getFullWidth(node.name) === 0 && !node.modifiers && isModifierKind(token())) { // in cases like // 'use strict' // function foo(static) @@ -3600,7 +3603,7 @@ namespace ts { return undefined; } - const isAsync = hasModifier(arrowFunction, ModifierFlags.Async); + const isAsync = hasModifierOfKind(arrowFunction, SyntaxKind.AsyncKeyword); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. @@ -3806,7 +3809,7 @@ namespace ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction | undefined { const node = createNodeWithJSDoc(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); - const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; + const isAsync = hasModifierOfKind(node, SyntaxKind.AsyncKeyword) ? SignatureFlags.Await : SignatureFlags.None; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -5002,7 +5005,7 @@ namespace ts { node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); const isGenerator = node.asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; - const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; + const isAsync = hasModifierOfKind(node, SyntaxKind.AsyncKeyword) ? SignatureFlags.Await : SignatureFlags.None; node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -5831,9 +5834,9 @@ namespace ts { node.kind = SyntaxKind.FunctionDeclaration; parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - node.name = hasModifier(node, ModifierFlags.Default) ? parseOptionalIdentifier() : parseIdentifier(); + node.name = hasModifierOfKind(node, SyntaxKind.DefaultKeyword) ? parseOptionalIdentifier() : parseIdentifier(); const isGenerator = node.asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; - const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; + const isAsync = hasModifierOfKind(node, SyntaxKind.AsyncKeyword) ? SignatureFlags.Await : SignatureFlags.None; fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected); return finishNode(node); @@ -5866,7 +5869,7 @@ namespace ts { node.kind = SyntaxKind.MethodDeclaration; node.asteriskToken = asteriskToken; const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; - const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; + const isAsync = hasModifierOfKind(node, SyntaxKind.AsyncKeyword) ? SignatureFlags.Await : SignatureFlags.None; fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); @@ -6508,7 +6511,7 @@ namespace ts { } function isAnExternalModuleIndicatorNode(node: Node) { - return hasModifier(node, ModifierFlags.Export) + return hasModifierOfKind(node, SyntaxKind.ExportKeyword) || node.kind === SyntaxKind.ImportEqualsDeclaration && (node).moduleReference.kind === SyntaxKind.ExternalModuleReference || node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ExportAssignment @@ -6525,6 +6528,11 @@ namespace ts { return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } + /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */ + function hasModifierOfKind(node: Node, kind: SyntaxKind) { + return some(node.modifiers, m => m.kind === kind); + } + function isImportMeta(node: Node): boolean { return isMetaProperty(node) && node.keywordToken === SyntaxKind.ImportKeyword && node.name.escapedText === "meta"; } @@ -6826,7 +6834,16 @@ namespace ts { break; case "class": case "constructor": - tag = parseClassTag(start, tagName); + tag = parseSimpleTag(start, SyntaxKind.JSDocClassTag, tagName); + break; + case "public": + tag = parseSimpleTag(start, SyntaxKind.JSDocPublicTag, tagName); + break; + case "private": + tag = parseSimpleTag(start, SyntaxKind.JSDocPrivateTag, tagName); + break; + case "protected": + tag = parseSimpleTag(start, SyntaxKind.JSDocProtectedTag, tagName); break; case "this": tag = parseThisTag(start, tagName); @@ -7192,8 +7209,8 @@ namespace ts { return node; } - function parseClassTag(start: number, tagName: Identifier): JSDocClassTag { - const tag = createNode(SyntaxKind.JSDocClassTag, start); + function parseSimpleTag(start: number, kind: SyntaxKind, tagName: Identifier): JSDocTag { + const tag = createNode(kind, start); tag.tagName = tagName; return finishNode(tag); } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index e6413af8e85ea..460eb64563898 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -840,13 +840,11 @@ namespace ts { ensureType(input, input.type) )); case SyntaxKind.Constructor: { - const isPrivate = hasModifier(input, ModifierFlags.Private); // A constructor declaration may not have a type annotation const ctor = createSignatureDeclaration( SyntaxKind.Constructor, - isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), - // TODO: GH#18217 - isPrivate ? undefined! : updateParamsList(input, input.parameters, ModifierFlags.None), + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters, ModifierFlags.None), /*type*/ undefined ); ctor.modifiers = createNodeArray(ensureModifiers(input)); @@ -865,15 +863,14 @@ namespace ts { return cleanup(sig); } case SyntaxKind.GetAccessor: { - const isPrivate = hasModifier(input, ModifierFlags.Private); const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(updateGetAccessor( input, /*decorators*/ undefined, ensureModifiers(input), input.name, - updateAccessorParamsList(input, isPrivate), - !isPrivate ? ensureType(input, accessorType) : undefined, + updateAccessorParamsList(input, hasModifier(input, ModifierFlags.Private)), + ensureType(input, accessorType), /*body*/ undefined)); } case SyntaxKind.SetAccessor: { @@ -892,7 +889,7 @@ namespace ts { ensureModifiers(input), input.name, input.questionToken, - !hasModifier(input, ModifierFlags.Private) ? ensureType(input, input.type) : undefined, + ensureType(input, input.type), ensureNoInitializer(input) )); case SyntaxKind.PropertySignature: @@ -901,7 +898,7 @@ namespace ts { ensureModifiers(input), input.name, input.questionToken, - !hasModifier(input, ModifierFlags.Private) ? ensureType(input, input.type) : undefined, + ensureType(input, input.type), ensureNoInitializer(input) )); case SyntaxKind.MethodSignature: { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1e0e32bcc45f0..393e48695a2a6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -468,6 +468,9 @@ namespace ts { JSDocAugmentsTag, JSDocAuthorTag, JSDocClassTag, + JSDocPublicTag, + JSDocPrivateTag, + JSDocProtectedTag, JSDocCallbackTag, JSDocEnumTag, JSDocParameterTag, @@ -2617,6 +2620,18 @@ namespace ts { kind: SyntaxKind.JSDocClassTag; } + export interface JSDocPublicTag extends JSDocTag { + kind: SyntaxKind.JSDocPublicTag; + } + + export interface JSDocPrivateTag extends JSDocTag { + kind: SyntaxKind.JSDocPrivateTag; + } + + export interface JSDocProtectedTag extends JSDocTag { + kind: SyntaxKind.JSDocProtectedTag; + } + export interface JSDocEnumTag extends JSDocTag, Declaration { parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 879fc1eaeb04e..0ed664b2703d7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4125,6 +4125,15 @@ namespace ts { } } + if (isInJSFile(node) && !!node.parent) { + // getModifierFlagsNoCache should only be called when parent pointers are set, + // or when !(node.flags & NodeFlags.Synthesized) && node.kind !== SyntaxKind.SourceFile) + const tags = (getJSDocPublicTag(node) ? ModifierFlags.Public : ModifierFlags.None) + | (getJSDocPrivateTag(node) ? ModifierFlags.Private : ModifierFlags.None) + | (getJSDocProtectedTag(node) ? ModifierFlags.Protected : ModifierFlags.None); + flags |= tags; + } + if (node.flags & NodeFlags.NestedNamespace || (node.kind === SyntaxKind.Identifier && (node).isInJSDocNamespace)) { flags |= ModifierFlags.Export; } diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 9311cb44f3ac4..4f27c261938c3 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -673,6 +673,21 @@ namespace ts { return getFirstJSDocTag(node, isJSDocClassTag); } + /** Gets the JSDoc public tag for the node if present */ + export function getJSDocPublicTag(node: Node): JSDocPublicTag | undefined { + return getFirstJSDocTag(node, isJSDocPublicTag); + } + + /** Gets the JSDoc private tag for the node if present */ + export function getJSDocPrivateTag(node: Node): JSDocPrivateTag | undefined { + return getFirstJSDocTag(node, isJSDocPrivateTag); + } + + /** Gets the JSDoc protected tag for the node if present */ + export function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined { + return getFirstJSDocTag(node, isJSDocProtectedTag); + } + /** Gets the JSDoc enum tag for the node if present */ export function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined { return getFirstJSDocTag(node, isJSDocEnumTag); @@ -1547,6 +1562,18 @@ namespace ts { return node.kind === SyntaxKind.JSDocClassTag; } + export function isJSDocPublicTag(node: Node): node is JSDocPublicTag { + return node.kind === SyntaxKind.JSDocPublicTag; + } + + export function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag { + return node.kind === SyntaxKind.JSDocPrivateTag; + } + + export function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag { + return node.kind === SyntaxKind.JSDocProtectedTag; + } + export function isJSDocEnumTag(node: Node): node is JSDocEnumTag { return node.kind === SyntaxKind.JSDocEnumTag; } @@ -2469,4 +2496,4 @@ namespace ts { } // #endregion -} \ No newline at end of file +} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 831fa82701400..923a9a4257b0f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -383,23 +383,26 @@ declare namespace ts { JSDocAugmentsTag = 305, JSDocAuthorTag = 306, JSDocClassTag = 307, - JSDocCallbackTag = 308, - JSDocEnumTag = 309, - JSDocParameterTag = 310, - JSDocReturnTag = 311, - JSDocThisTag = 312, - JSDocTypeTag = 313, - JSDocTemplateTag = 314, - JSDocTypedefTag = 315, - JSDocPropertyTag = 316, - SyntaxList = 317, - NotEmittedStatement = 318, - PartiallyEmittedExpression = 319, - CommaListExpression = 320, - MergeDeclarationMarker = 321, - EndOfDeclarationMarker = 322, - SyntheticReferenceExpression = 323, - Count = 324, + JSDocPublicTag = 308, + JSDocPrivateTag = 309, + JSDocProtectedTag = 310, + JSDocCallbackTag = 311, + JSDocEnumTag = 312, + JSDocParameterTag = 313, + JSDocReturnTag = 314, + JSDocThisTag = 315, + JSDocTypeTag = 316, + JSDocTemplateTag = 317, + JSDocTypedefTag = 318, + JSDocPropertyTag = 319, + SyntaxList = 320, + NotEmittedStatement = 321, + PartiallyEmittedExpression = 322, + CommaListExpression = 323, + MergeDeclarationMarker = 324, + EndOfDeclarationMarker = 325, + SyntheticReferenceExpression = 326, + Count = 327, FirstAssignment = 62, LastAssignment = 74, FirstCompoundAssignment = 63, @@ -428,9 +431,9 @@ declare namespace ts { LastStatement = 240, FirstNode = 152, FirstJSDocNode = 292, - LastJSDocNode = 316, + LastJSDocNode = 319, FirstJSDocTagNode = 304, - LastJSDocTagNode = 316, + LastJSDocTagNode = 319, } export enum NodeFlags { None = 0, @@ -1620,6 +1623,15 @@ declare namespace ts { export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } + export interface JSDocPublicTag extends JSDocTag { + kind: SyntaxKind.JSDocPublicTag; + } + export interface JSDocPrivateTag extends JSDocTag { + kind: SyntaxKind.JSDocPrivateTag; + } + export interface JSDocProtectedTag extends JSDocTag { + kind: SyntaxKind.JSDocProtectedTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; @@ -3454,6 +3466,12 @@ declare namespace ts { function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; /** Gets the JSDoc class tag for the node if present */ function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc public tag for the node if present */ + function getJSDocPublicTag(node: Node): JSDocPublicTag | undefined; + /** Gets the JSDoc private tag for the node if present */ + function getJSDocPrivateTag(node: Node): JSDocPrivateTag | undefined; + /** Gets the JSDoc protected tag for the node if present */ + function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined; /** Gets the JSDoc this tag for the node if present */ @@ -3658,6 +3676,9 @@ declare namespace ts { function isJSDocAuthorTag(node: Node): node is JSDocAuthorTag; function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag; function isJSDocClassTag(node: Node): node is JSDocClassTag; + function isJSDocPublicTag(node: Node): node is JSDocPublicTag; + function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; + function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; function isJSDocThisTag(node: Node): node is JSDocThisTag; function isJSDocParameterTag(node: Node): node is JSDocParameterTag; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3f1c97df0fed0..2d934840e7304 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -383,23 +383,26 @@ declare namespace ts { JSDocAugmentsTag = 305, JSDocAuthorTag = 306, JSDocClassTag = 307, - JSDocCallbackTag = 308, - JSDocEnumTag = 309, - JSDocParameterTag = 310, - JSDocReturnTag = 311, - JSDocThisTag = 312, - JSDocTypeTag = 313, - JSDocTemplateTag = 314, - JSDocTypedefTag = 315, - JSDocPropertyTag = 316, - SyntaxList = 317, - NotEmittedStatement = 318, - PartiallyEmittedExpression = 319, - CommaListExpression = 320, - MergeDeclarationMarker = 321, - EndOfDeclarationMarker = 322, - SyntheticReferenceExpression = 323, - Count = 324, + JSDocPublicTag = 308, + JSDocPrivateTag = 309, + JSDocProtectedTag = 310, + JSDocCallbackTag = 311, + JSDocEnumTag = 312, + JSDocParameterTag = 313, + JSDocReturnTag = 314, + JSDocThisTag = 315, + JSDocTypeTag = 316, + JSDocTemplateTag = 317, + JSDocTypedefTag = 318, + JSDocPropertyTag = 319, + SyntaxList = 320, + NotEmittedStatement = 321, + PartiallyEmittedExpression = 322, + CommaListExpression = 323, + MergeDeclarationMarker = 324, + EndOfDeclarationMarker = 325, + SyntheticReferenceExpression = 326, + Count = 327, FirstAssignment = 62, LastAssignment = 74, FirstCompoundAssignment = 63, @@ -428,9 +431,9 @@ declare namespace ts { LastStatement = 240, FirstNode = 152, FirstJSDocNode = 292, - LastJSDocNode = 316, + LastJSDocNode = 319, FirstJSDocTagNode = 304, - LastJSDocTagNode = 316, + LastJSDocTagNode = 319, } export enum NodeFlags { None = 0, @@ -1620,6 +1623,15 @@ declare namespace ts { export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } + export interface JSDocPublicTag extends JSDocTag { + kind: SyntaxKind.JSDocPublicTag; + } + export interface JSDocPrivateTag extends JSDocTag { + kind: SyntaxKind.JSDocPrivateTag; + } + export interface JSDocProtectedTag extends JSDocTag { + kind: SyntaxKind.JSDocProtectedTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; @@ -3454,6 +3466,12 @@ declare namespace ts { function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; /** Gets the JSDoc class tag for the node if present */ function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc public tag for the node if present */ + function getJSDocPublicTag(node: Node): JSDocPublicTag | undefined; + /** Gets the JSDoc private tag for the node if present */ + function getJSDocPrivateTag(node: Node): JSDocPrivateTag | undefined; + /** Gets the JSDoc protected tag for the node if present */ + function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined; /** Gets the JSDoc this tag for the node if present */ @@ -3658,6 +3676,9 @@ declare namespace ts { function isJSDocAuthorTag(node: Node): node is JSDocAuthorTag; function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag; function isJSDocClassTag(node: Node): node is JSDocClassTag; + function isJSDocPublicTag(node: Node): node is JSDocPublicTag; + function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; + function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; function isJSDocThisTag(node: Node): node is JSDocThisTag; function isJSDocParameterTag(node: Node): node is JSDocParameterTag; diff --git a/tests/baselines/reference/jsdocAccessibilityTags.errors.txt b/tests/baselines/reference/jsdocAccessibilityTags.errors.txt new file mode 100644 index 0000000000000..bcbad8b95eaf2 --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTags.errors.txt @@ -0,0 +1,101 @@ +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(21,9): error TS2379: Getter and setter accessors do not agree in visibility. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(23,9): error TS2379: Getter and setter accessors do not agree in visibility. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(59,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(59,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(60,9): error TS2341: Property 'priv2' is private and only accessible within class 'C'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(60,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and only accessible within class 'C'. +tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. + + +==== tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js (12 errors) ==== + class A { + /** + * Ap docs + * + * @private + */ + priv = 4; + /** + * Aq docs + * + * @protected + */ + prot = 5; + /** + * Ar docs + * + * @public + */ + pub = 6; + /** @public */ + get ack() { return this.priv } + ~~~ +!!! error TS2379: Getter and setter accessors do not agree in visibility. + /** @private */ + set ack(value) { } + ~~~ +!!! error TS2379: Getter and setter accessors do not agree in visibility. + } + class C { + constructor() { + /** + * Cp docs + * + * @private + */ + this.priv2 = 1; + /** + * Cq docs + * + * @protected + */ + this.prot2 = 2; + /** + * Cr docs + * + * @public + */ + this.pub2 = 3; + } + h() { return this.priv2 } + } + class B extends A { + m() { + this.priv + this.prot + this.pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + } + } + class D extends C { + n() { + this.priv2 + this.prot2 + this.pub2 + ~~~~~ +!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. + } + } + new A().priv + new A().prot + new A().pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + ~~~~ +!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + new B().priv + new B().prot + new B().pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + ~~~~ +!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + new C().priv2 + new C().prot2 + new C().pub2 + ~~~~~ +!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. + ~~~~~ +!!! error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. + new D().priv2 + new D().prot2 + new D().pub2 + ~~~~~ +!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. + ~~~~~ +!!! error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocAccessibilityTags.symbols b/tests/baselines/reference/jsdocAccessibilityTags.symbols new file mode 100644 index 0000000000000..62f97b37a2e73 --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTags.symbols @@ -0,0 +1,162 @@ +=== tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js === +class A { +>A : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) + + /** + * Ap docs + * + * @private + */ + priv = 4; +>priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) + + /** + * Aq docs + * + * @protected + */ + prot = 5; +>prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) + + /** + * Ar docs + * + * @public + */ + pub = 6; +>pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) + + /** @public */ + get ack() { return this.priv } +>ack : Symbol(A.ack, Decl(jsdocAccessibilityTag.js, 18, 12), Decl(jsdocAccessibilityTag.js, 20, 34)) +>this.priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>this : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) +>priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) + + /** @private */ + set ack(value) { } +>ack : Symbol(A.ack, Decl(jsdocAccessibilityTag.js, 18, 12), Decl(jsdocAccessibilityTag.js, 20, 34)) +>value : Symbol(value, Decl(jsdocAccessibilityTag.js, 22, 12)) +} +class C { +>C : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) + + constructor() { + /** + * Cp docs + * + * @private + */ + this.priv2 = 1; +>this.priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>this : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) + + /** + * Cq docs + * + * @protected + */ + this.prot2 = 2; +>this.prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>this : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) + + /** + * Cr docs + * + * @public + */ + this.pub2 = 3; +>this.pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) +>this : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) + } + h() { return this.priv2 } +>h : Symbol(C.h, Decl(jsdocAccessibilityTag.js, 44, 5)) +>this.priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>this : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +} +class B extends A { +>B : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>A : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) + + m() { +>m : Symbol(B.m, Decl(jsdocAccessibilityTag.js, 47, 19)) + + this.priv + this.prot + this.pub +>this.priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>this : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>this.prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>this : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>this.pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) +>this : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) + } +} +class D extends C { +>D : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>C : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) + + n() { +>n : Symbol(D.n, Decl(jsdocAccessibilityTag.js, 52, 19)) + + this.priv2 + this.prot2 + this.pub2 +>this.priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>this : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>this.prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>this : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>this.pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) +>this : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) + } +} +new A().priv + new A().prot + new A().pub +>new A().priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>A : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) +>priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>new A().prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>A : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) +>prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>new A().pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) +>A : Symbol(A, Decl(jsdocAccessibilityTag.js, 0, 0)) +>pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) + +new B().priv + new B().prot + new B().pub +>new B().priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>B : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>priv : Symbol(A.priv, Decl(jsdocAccessibilityTag.js, 0, 9)) +>new B().prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>B : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>prot : Symbol(A.prot, Decl(jsdocAccessibilityTag.js, 6, 13)) +>new B().pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) +>B : Symbol(B, Decl(jsdocAccessibilityTag.js, 46, 1)) +>pub : Symbol(A.pub, Decl(jsdocAccessibilityTag.js, 12, 13)) + +new C().priv2 + new C().prot2 + new C().pub2 +>new C().priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>C : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>new C().prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>C : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>new C().pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) +>C : Symbol(C, Decl(jsdocAccessibilityTag.js, 23, 1)) +>pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) + +new D().priv2 + new D().prot2 + new D().pub2 +>new D().priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>D : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>priv2 : Symbol(C.priv2, Decl(jsdocAccessibilityTag.js, 25, 19)) +>new D().prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>D : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>prot2 : Symbol(C.prot2, Decl(jsdocAccessibilityTag.js, 31, 23)) +>new D().pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) +>D : Symbol(D, Decl(jsdocAccessibilityTag.js, 51, 1)) +>pub2 : Symbol(C.pub2, Decl(jsdocAccessibilityTag.js, 37, 23)) + diff --git a/tests/baselines/reference/jsdocAccessibilityTags.types b/tests/baselines/reference/jsdocAccessibilityTags.types new file mode 100644 index 0000000000000..18a364c4da843 --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTags.types @@ -0,0 +1,195 @@ +=== tests/cases/conformance/jsdoc/jsdocAccessibilityTag.js === +class A { +>A : A + + /** + * Ap docs + * + * @private + */ + priv = 4; +>priv : number +>4 : 4 + + /** + * Aq docs + * + * @protected + */ + prot = 5; +>prot : number +>5 : 5 + + /** + * Ar docs + * + * @public + */ + pub = 6; +>pub : number +>6 : 6 + + /** @public */ + get ack() { return this.priv } +>ack : number +>this.priv : number +>this : this +>priv : number + + /** @private */ + set ack(value) { } +>ack : number +>value : number +} +class C { +>C : C + + constructor() { + /** + * Cp docs + * + * @private + */ + this.priv2 = 1; +>this.priv2 = 1 : 1 +>this.priv2 : number +>this : this +>priv2 : number +>1 : 1 + + /** + * Cq docs + * + * @protected + */ + this.prot2 = 2; +>this.prot2 = 2 : 2 +>this.prot2 : number +>this : this +>prot2 : number +>2 : 2 + + /** + * Cr docs + * + * @public + */ + this.pub2 = 3; +>this.pub2 = 3 : 3 +>this.pub2 : number +>this : this +>pub2 : number +>3 : 3 + } + h() { return this.priv2 } +>h : () => number +>this.priv2 : number +>this : this +>priv2 : number +} +class B extends A { +>B : B +>A : A + + m() { +>m : () => void + + this.priv + this.prot + this.pub +>this.priv + this.prot + this.pub : number +>this.priv + this.prot : number +>this.priv : number +>this : this +>priv : number +>this.prot : number +>this : this +>prot : number +>this.pub : number +>this : this +>pub : number + } +} +class D extends C { +>D : D +>C : C + + n() { +>n : () => void + + this.priv2 + this.prot2 + this.pub2 +>this.priv2 + this.prot2 + this.pub2 : number +>this.priv2 + this.prot2 : number +>this.priv2 : number +>this : this +>priv2 : number +>this.prot2 : number +>this : this +>prot2 : number +>this.pub2 : number +>this : this +>pub2 : number + } +} +new A().priv + new A().prot + new A().pub +>new A().priv + new A().prot + new A().pub : number +>new A().priv + new A().prot : number +>new A().priv : number +>new A() : A +>A : typeof A +>priv : number +>new A().prot : number +>new A() : A +>A : typeof A +>prot : number +>new A().pub : number +>new A() : A +>A : typeof A +>pub : number + +new B().priv + new B().prot + new B().pub +>new B().priv + new B().prot + new B().pub : number +>new B().priv + new B().prot : number +>new B().priv : number +>new B() : B +>B : typeof B +>priv : number +>new B().prot : number +>new B() : B +>B : typeof B +>prot : number +>new B().pub : number +>new B() : B +>B : typeof B +>pub : number + +new C().priv2 + new C().prot2 + new C().pub2 +>new C().priv2 + new C().prot2 + new C().pub2 : number +>new C().priv2 + new C().prot2 : number +>new C().priv2 : number +>new C() : C +>C : typeof C +>priv2 : number +>new C().prot2 : number +>new C() : C +>C : typeof C +>prot2 : number +>new C().pub2 : number +>new C() : C +>C : typeof C +>pub2 : number + +new D().priv2 + new D().prot2 + new D().pub2 +>new D().priv2 + new D().prot2 + new D().pub2 : number +>new D().priv2 + new D().prot2 : number +>new D().priv2 : number +>new D() : D +>D : typeof D +>priv2 : number +>new D().prot2 : number +>new D() : D +>D : typeof D +>prot2 : number +>new D().pub2 : number +>new D() : D +>D : typeof D +>pub2 : number + diff --git a/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.js b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.js new file mode 100644 index 0000000000000..18031abf9cafc --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.js @@ -0,0 +1,92 @@ +//// [jsdocAccessibilityTagDeclarations.js] +class Protected { + /** @protected */ + constructor(c) { + /** @protected */ + this.c = c + } + /** @protected */ + m() { + return this.c + } + /** @protected */ + get p() { return this.c } + /** @protected */ + set p(value) { this.c = value } +} + +class Private { + /** @private */ + constructor(c) { + /** @private */ + this.c = c + } + /** @private */ + m() { + return this.c + } + /** @private */ + get p() { return this.c } + /** @private */ + set p(value) { this.c = value } +} + + +//// [foo.js] +class Protected { + /** @protected */ + constructor(c) { + /** @protected */ + this.c = c; + } + /** @protected */ + m() { + return this.c; + } + /** @protected */ + get p() { return this.c; } + /** @protected */ + set p(value) { this.c = value; } +} +class Private { + /** @private */ + constructor(c) { + /** @private */ + this.c = c; + } + /** @private */ + m() { + return this.c; + } + /** @private */ + get p() { return this.c; } + /** @private */ + set p(value) { this.c = value; } +} + + +//// [foo.d.ts] +declare class Protected { + /** @protected */ + protected constructor(); + /** @protected */ + protected c: any; + /** @protected */ + protected m(): any; + /** @protected */ + protected set p(arg: any); + /** @protected */ + protected get p(): any; +} +declare class Private { + /** @private */ + private constructor(); + /** @private */ + private c; + /** @private */ + private m; + /** @private */ + private set p(arg); + /** @private */ + private get p(); +} diff --git a/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.symbols b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.symbols new file mode 100644 index 0000000000000..0316e157d31fa --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.symbols @@ -0,0 +1,81 @@ +=== tests/cases/conformance/jsdoc/jsdocAccessibilityTagDeclarations.js === +class Protected { +>Protected : Symbol(Protected, Decl(jsdocAccessibilityTagDeclarations.js, 0, 0)) + + /** @protected */ + constructor(c) { +>c : Symbol(c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 16)) + + /** @protected */ + this.c = c +>this.c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>this : Symbol(Protected, Decl(jsdocAccessibilityTagDeclarations.js, 0, 0)) +>c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>c : Symbol(c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 16)) + } + /** @protected */ + m() { +>m : Symbol(Protected.m, Decl(jsdocAccessibilityTagDeclarations.js, 5, 5)) + + return this.c +>this.c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>this : Symbol(Protected, Decl(jsdocAccessibilityTagDeclarations.js, 0, 0)) +>c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) + } + /** @protected */ + get p() { return this.c } +>p : Symbol(Protected.p, Decl(jsdocAccessibilityTagDeclarations.js, 9, 5), Decl(jsdocAccessibilityTagDeclarations.js, 11, 29)) +>this.c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>this : Symbol(Protected, Decl(jsdocAccessibilityTagDeclarations.js, 0, 0)) +>c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) + + /** @protected */ + set p(value) { this.c = value } +>p : Symbol(Protected.p, Decl(jsdocAccessibilityTagDeclarations.js, 9, 5), Decl(jsdocAccessibilityTagDeclarations.js, 11, 29)) +>value : Symbol(value, Decl(jsdocAccessibilityTagDeclarations.js, 13, 10)) +>this.c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>this : Symbol(Protected, Decl(jsdocAccessibilityTagDeclarations.js, 0, 0)) +>c : Symbol(Protected.c, Decl(jsdocAccessibilityTagDeclarations.js, 2, 20), Decl(jsdocAccessibilityTagDeclarations.js, 13, 18)) +>value : Symbol(value, Decl(jsdocAccessibilityTagDeclarations.js, 13, 10)) +} + +class Private { +>Private : Symbol(Private, Decl(jsdocAccessibilityTagDeclarations.js, 14, 1)) + + /** @private */ + constructor(c) { +>c : Symbol(c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 16)) + + /** @private */ + this.c = c +>this.c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>this : Symbol(Private, Decl(jsdocAccessibilityTagDeclarations.js, 14, 1)) +>c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>c : Symbol(c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 16)) + } + /** @private */ + m() { +>m : Symbol(Private.m, Decl(jsdocAccessibilityTagDeclarations.js, 21, 5)) + + return this.c +>this.c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>this : Symbol(Private, Decl(jsdocAccessibilityTagDeclarations.js, 14, 1)) +>c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) + } + /** @private */ + get p() { return this.c } +>p : Symbol(Private.p, Decl(jsdocAccessibilityTagDeclarations.js, 25, 5), Decl(jsdocAccessibilityTagDeclarations.js, 27, 29)) +>this.c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>this : Symbol(Private, Decl(jsdocAccessibilityTagDeclarations.js, 14, 1)) +>c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) + + /** @private */ + set p(value) { this.c = value } +>p : Symbol(Private.p, Decl(jsdocAccessibilityTagDeclarations.js, 25, 5), Decl(jsdocAccessibilityTagDeclarations.js, 27, 29)) +>value : Symbol(value, Decl(jsdocAccessibilityTagDeclarations.js, 29, 10)) +>this.c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>this : Symbol(Private, Decl(jsdocAccessibilityTagDeclarations.js, 14, 1)) +>c : Symbol(Private.c, Decl(jsdocAccessibilityTagDeclarations.js, 18, 20), Decl(jsdocAccessibilityTagDeclarations.js, 29, 18)) +>value : Symbol(value, Decl(jsdocAccessibilityTagDeclarations.js, 29, 10)) +} + diff --git a/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.types b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.types new file mode 100644 index 0000000000000..88c6acd855d4e --- /dev/null +++ b/tests/baselines/reference/jsdocAccessibilityTagsDeclarations.types @@ -0,0 +1,85 @@ +=== tests/cases/conformance/jsdoc/jsdocAccessibilityTagDeclarations.js === +class Protected { +>Protected : Protected + + /** @protected */ + constructor(c) { +>c : any + + /** @protected */ + this.c = c +>this.c = c : any +>this.c : any +>this : this +>c : any +>c : any + } + /** @protected */ + m() { +>m : () => any + + return this.c +>this.c : any +>this : this +>c : any + } + /** @protected */ + get p() { return this.c } +>p : any +>this.c : any +>this : this +>c : any + + /** @protected */ + set p(value) { this.c = value } +>p : any +>value : any +>this.c = value : any +>this.c : any +>this : this +>c : any +>value : any +} + +class Private { +>Private : Private + + /** @private */ + constructor(c) { +>c : any + + /** @private */ + this.c = c +>this.c = c : any +>this.c : any +>this : this +>c : any +>c : any + } + /** @private */ + m() { +>m : () => any + + return this.c +>this.c : any +>this : this +>c : any + } + /** @private */ + get p() { return this.c } +>p : any +>this.c : any +>this : this +>c : any + + /** @private */ + set p(value) { this.c = value } +>p : any +>value : any +>this.c = value : any +>this.c : any +>this : this +>c : any +>value : any +} + diff --git a/tests/cases/conformance/jsdoc/jsdocAccessibilityTags.ts b/tests/cases/conformance/jsdoc/jsdocAccessibilityTags.ts new file mode 100644 index 0000000000000..b32944e8f87aa --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocAccessibilityTags.ts @@ -0,0 +1,67 @@ +// @allowJs: true +// @checkJs: true +// @target: esnext +// @noEmit: true +// @Filename: jsdocAccessibilityTag.js + +class A { + /** + * Ap docs + * + * @private + */ + priv = 4; + /** + * Aq docs + * + * @protected + */ + prot = 5; + /** + * Ar docs + * + * @public + */ + pub = 6; + /** @public */ + get ack() { return this.priv } + /** @private */ + set ack(value) { } +} +class C { + constructor() { + /** + * Cp docs + * + * @private + */ + this.priv2 = 1; + /** + * Cq docs + * + * @protected + */ + this.prot2 = 2; + /** + * Cr docs + * + * @public + */ + this.pub2 = 3; + } + h() { return this.priv2 } +} +class B extends A { + m() { + this.priv + this.prot + this.pub + } +} +class D extends C { + n() { + this.priv2 + this.prot2 + this.pub2 + } +} +new A().priv + new A().prot + new A().pub +new B().priv + new B().prot + new B().pub +new C().priv2 + new C().prot2 + new C().pub2 +new D().priv2 + new D().prot2 + new D().pub2 diff --git a/tests/cases/conformance/jsdoc/jsdocAccessibilityTagsDeclarations.ts b/tests/cases/conformance/jsdoc/jsdocAccessibilityTagsDeclarations.ts new file mode 100644 index 0000000000000..cfc488a972e4d --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocAccessibilityTagsDeclarations.ts @@ -0,0 +1,37 @@ +// @allowJs: true +// @checkJs: true +// @target: esnext +// @out: foo.js +// @declaration: true +// @Filename: jsdocAccessibilityTagDeclarations.js +class Protected { + /** @protected */ + constructor(c) { + /** @protected */ + this.c = c + } + /** @protected */ + m() { + return this.c + } + /** @protected */ + get p() { return this.c } + /** @protected */ + set p(value) { this.c = value } +} + +class Private { + /** @private */ + constructor(c) { + /** @private */ + this.c = c + } + /** @private */ + m() { + return this.c + } + /** @private */ + get p() { return this.c } + /** @private */ + set p(value) { this.c = value } +}