TypeScript/tests/baselines/reference/jsDeclarationsParameterTagReusesInputNodeInEmit1.js
Nathan Shively-Sanders d2443a5df1
@typedef: Improve error spans from declaration emit (#42501)
* @typedef: Improve error spans from declaration emit

This is a proof-of-concept fix. I think it could be expanded for all of
jsdoc, but I only set it up for jsdoc type aliases. It could use a lot
of polish too.

* track error node in isSymbolAccessible instead

* Switch to using enclosingDeclaration

Remove trueErrorNode

* add test of @callback and @enum

* Better error + fix @enum error

Since enums don't have a name property, you *have* to call
`getNameOfDeclaration` to go looking through the AST for one.
2021-01-28 08:35:05 -08:00

70 lines
1.3 KiB
TypeScript

//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsParameterTagReusesInputNodeInEmit1.ts] ////
//// [base.js]
class Base {
constructor() {}
}
const BaseFactory = () => {
return new Base();
};
BaseFactory.Base = Base;
module.exports = BaseFactory;
//// [file.js]
/** @typedef {import('./base')} BaseFactory */
/**
* @callback BaseFactoryFactory
* @param {import('./base')} factory
*/
/** @enum {import('./base')} */
const couldntThinkOfAny = {}
/**
*
* @param {InstanceType<BaseFactory["Base"]>} base
* @returns {InstanceType<BaseFactory["Base"]>}
*/
const test = (base) => {
return base;
};
//// [base.js]
class Base {
constructor() { }
}
const BaseFactory = () => {
return new Base();
};
BaseFactory.Base = Base;
module.exports = BaseFactory;
//// [file.js]
/** @typedef {import('./base')} BaseFactory */
/**
* @callback BaseFactoryFactory
* @param {import('./base')} factory
*/
/** @enum {import('./base')} */
const couldntThinkOfAny = {};
/**
*
* @param {InstanceType<BaseFactory["Base"]>} base
* @returns {InstanceType<BaseFactory["Base"]>}
*/
const test = (base) => {
return base;
};
//// [base.d.ts]
export = BaseFactory;
declare function BaseFactory(): Base;
declare namespace BaseFactory {
export { Base };
}
declare class Base {
}