-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update or remove tsd-jsdoc #10455
Comments
I captured the warnings in a file to evaluate. There are 1234 warnings, and 1230 of them are "Failed to find parent of doclet...". I think this is a known issue with the tsd-jsdoc plugin. The plugin repo seems to be dead. I think we might be better off switching to typescript itself to generate the type definitions. Typescript added this functionality shortly after the tsd-jsdoc plugin was developed. My first quick test of the typescript compiler is throwing a few errors about "requires using private name from module". This may be worth another look when we have time. |
While declare const _default: Readonly<{
/**
* Straight line that does not conform to the surface of the ellipsoid.
*
* @type {Number}
* @constant
*/
NONE: number;
/**
* Follow geodesic path.
*
* @type {Number}
* @constant
*/
GEODESIC: number;
/**
* Follow rhumb or loxodrome path.
*
* @type {Number}
* @constant
*/
RHUMB: number;
}>;
export default _default; If I go from: export default Object.freeze(ArcType); to export default ArcType; then I lose documentation for the enum values: export default ArcType;
/**
* ArcType defines the path that should be taken connecting vertices.
*/
type ArcType = number;
declare namespace ArcType {
const NONE: number;
const GEODESIC: number;
const RHUMB: number;
} This is with |
The JSDoc to |
ts-jsdoc is also stopping us from updating our version of |
We can use I started work on this in
Some potential follow ups:
After that is completed and verified, I think we should also be able to enable type checking via tsconfig.json. But that will also turn up loads of errors so it should probably be a separate effort. |
Some initial issues that are going to be fundamental across the library Extending classesSimply put, TS completely ignores the CesiumJS is a very OOP oriented JS library and we make use of extending classes in a decent number of places like cesium/packages/engine/Source/Scene/OpenStreetMapImageryProvider.js Lines 120 to 126 in dc667cd
Converting objects into keyword Speaking with @ggetz she found a way to make it work for the cesium/packages/engine/Source/DataSources/Property.js Lines 64 to 67 in b4df54b
Class properties and
|
Is it valid to say that the first points would be completely obsolete if we consistently changed from I know, doing this consistently may be a considerable effort and a big change. But I'm trying to understand ~"which problem is solved how": We could invest a considerable amount of time to solve the issues of "extending/ |
Thanks for all the info so far @jjspace! @javagl I think using @jjspace You mentioned that jsDoc is running into errors with certain tags like
Regarding importing types, I one of the most important aspects is that we should make sure we are importing types only, rather than the entire module. TypeScript does something called "import elision" that, when generating JS, drops imports which it knows are type-only imports. The effects of this are described in more detail here. |
Re:
|
@javagl Given my current understanding that is correct. I modified one of my examples above to include the same class using I'm still going to spend a little more time trying to see if I can get it working without the |
Hm, maybe there's a way we can define the function parameter and return types without using arrow functions? |
As I mentioned this is achievable with the JSDoc callbacksShowing one of the previously added type casts. Instead of Property.prototype.getValue =
/** @type {(time?: JulianDate, result?: any|any[]) => any|any[]|undefined} */ (
DeveloperError.throwInstantiationError
); This works /**
* @callback PropertyGetValue
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {any|any[]} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {any|any[]|undefined} The modified result parameter or a new instance if the result parameter was not supplied.
*/
/**
* Gets the value of the property at the provided time.
* @function
*
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {any|any[]} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {any|any[]|undefined} The modified result parameter or a new instance if the result parameter was not supplied.
*/
Property.prototype.getValue = /** @type {PropertyGetValue} */ (
DeveloperError.throwInstantiationError
); And generates this extra type in the type definitions export type PropertyGetValue = (time?: JulianDate | undefined, result?: any | any[]) => any | any[] | undefined; This makes TS and JSDoc happy but I feel like the duplicated docs are bad. There may be a way to combine them but I didn't dig too deep. I also think defining these extra types at the JSDoc level just to appease TS could be a code smell. I did not verify yet if they get generated in the docs as well which could pollute them. |
I might be missing some context, but ... looking at that |
The more time I spend trying to find a way to minimally make both TS and JSDoc happy with our class definitions the more it feels like the logical, and necessary, route forward is to use keyword Some relevant issues I've found around the
I'm going to leave a comment over in #8359 about a path forward to keep the two issues more focused |
As part of the build process, CesiumJS generates TypeScript definitions based off our jsdoc comments.
While we're generally pretty meticulous about having accurate documentation, there are a few instances of invalid jsdoc that have slipped through. The
build-ts
scripts, which converts our jsdoc to TypeScript definitions, has recently been spitting out a ton of warnings indicating probable issues with our meta tags.There is a helpful list of common pitfalls the link above, including:
This list likely covers most of the warnings. We should fix theses to ensure we have accurate documentation and accurate TYpeScript definitions.
The text was updated successfully, but these errors were encountered: