d2443a5df1
* @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.
95 lines
1.9 KiB
TypeScript
95 lines
1.9 KiB
TypeScript
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsImportAliasExposedWithinNamespace.ts] ////
|
|
|
|
//// [file.js]
|
|
/**
|
|
* @namespace myTypes
|
|
* @global
|
|
* @type {Object<string,*>}
|
|
*/
|
|
const myTypes = {
|
|
// SOME PROPS HERE
|
|
};
|
|
|
|
/** @typedef {string|RegExp|Array<string|RegExp>} myTypes.typeA */
|
|
|
|
/**
|
|
* @typedef myTypes.typeB
|
|
* @property {myTypes.typeA} prop1 - Prop 1.
|
|
* @property {string} prop2 - Prop 2.
|
|
*/
|
|
|
|
/** @typedef {myTypes.typeB|Function} myTypes.typeC */
|
|
|
|
export {myTypes};
|
|
//// [file2.js]
|
|
import {myTypes} from './file.js';
|
|
|
|
/**
|
|
* @namespace testFnTypes
|
|
* @global
|
|
* @type {Object<string,*>}
|
|
*/
|
|
const testFnTypes = {
|
|
// SOME PROPS HERE
|
|
};
|
|
|
|
/** @typedef {boolean|myTypes.typeC} testFnTypes.input */
|
|
|
|
/**
|
|
* @function testFn
|
|
* @description A test function.
|
|
* @param {testFnTypes.input} input - Input.
|
|
* @returns {number|null} Result.
|
|
*/
|
|
function testFn(input) {
|
|
if (typeof input === 'number') {
|
|
return 2 * input;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export {testFn, testFnTypes};
|
|
|
|
|
|
|
|
//// [file.d.ts]
|
|
export namespace myTypes {
|
|
type typeA = string | RegExp | Array<string | RegExp>;
|
|
type typeB = {
|
|
/**
|
|
* - Prop 1.
|
|
*/
|
|
prop1: myTypes.typeA;
|
|
/**
|
|
* - Prop 2.
|
|
*/
|
|
prop2: string;
|
|
};
|
|
type typeC = myTypes.typeB | Function;
|
|
const myTypes: {
|
|
[x: string]: any;
|
|
};
|
|
}
|
|
//// [file2.d.ts]
|
|
export namespace testFnTypes {
|
|
type input = boolean | myTypes.typeC;
|
|
}
|
|
/** @typedef {boolean|myTypes.typeC} testFnTypes.input */
|
|
/**
|
|
* @function testFn
|
|
* @description A test function.
|
|
* @param {testFnTypes.input} input - Input.
|
|
* @returns {number|null} Result.
|
|
*/
|
|
export function testFn(input: testFnTypes.input): number | null;
|
|
import { myTypes } from "./file.js";
|
|
/**
|
|
* @namespace testFnTypes
|
|
* @global
|
|
* @type {Object<string,*>}
|
|
*/
|
|
export const testFnTypes: {
|
|
[x: string]: any;
|
|
};
|