TypeScript/tests/cases/conformance/jsdoc/jsdocAccessibilityTagsDeclarations.ts

43 lines
851 B
TypeScript
Raw Normal View History

Add jsdoc support for @public/@private/@protected (#35731) * Add @private/@protected/@public test * Fix @declaration * draft abstraction + one usage * Fill in necessary parsing etc * make general getEffectiveModifierFlags move to utilities, make the right things call it * reorder public/private/protected * JS declaration emit works with @public/@private/@protected * revert unneeded/incorrect changes * Update baselines and skip @public/etc when parsing 1. Update the API baselines with the new functions. 2. Do not check for @public/etc during parsing, because parent pointers aren't set, so non-local tags will be missed; this wrong answer will then be cached. * Parser: don't call hasModifier(s) anymore. Then move jsdoc modifier tag checks into getModifierFlagsNoCache where they should be. The jsdoc checks are skipped when the parent is undefined. There are 3 cases when this can happen: 1. The code is in the parser (or a few places in the binder, notably declareSymbol of module.exports assignments). 2. The node is a source file. 3. The node is synthetic, which I assume to be from the transforms. It is fine to call getModifierFlags in cases (2) and (3). It is not fine for (1), so I removed these calls and replaced them with simple iteration over the modifiers. Worth noting: Ron's uniform node construction PR removes these calls anyway; this PR just does it early. * Fix constructor emit 1. Emit protected for protected, which I missed earlier. 2. Emit a constructor, not a property named "constructor". 3. Split declaration emit tests out so that errors are properly reported there.
2019-12-18 21:58:12 +01:00
// @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 }
}
// https://github.com/microsoft/TypeScript/issues/38401
class C {
constructor(/** @public */ x, /** @protected */ y, /** @private */ z) {
}
}