-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Bundle JSDoc-built TypeScript declaration file #34
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
…alue of `unionWith`)
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
/**
* Get visitor keys of a given node.
* @param {object} node The AST node to get keys.
* @returns {readonly string[]} Visitor keys of the node.
*/
export function getKeys(node: object): readonly string[];
/**
* Make the union set with `KEYS` and given keys.
* @param {KeysStrictReadonly} additionalKeys The additional keys.
* @returns {KeysStrictReadonly} The union set.
*/
export function unionWith(additionalKeys: KeysStrictReadonly): KeysStrictReadonly;
export { KEYS };
export type KeysStrict = {
[type: string]: readonly string[];
};
export type KeysStrictReadonly = {
readonly [type: string]: readonly string[];
};
import KEYS from "./visitor-keys.js";
//# sourceMappingURL=index.d.ts.map It exports some types, so someone might use them in their project. Should we aim for this to be stable (e.g., to avoid renaming exported types), and would it be possible to add some tests for |
FWIW, export interface VisitorKeys {
readonly [type: string]: ReadonlyArray<string> | undefined;
}
export const KEYS: VisitorKeys;
export function getKeys(node: {}): ReadonlyArray<string>;
export function unionWith(keys: VisitorKeys): VisitorKeys; ...and has some kind of pseudo-tests at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint-visitor-keys/eslint-visitor-keys-tests.ts . TypeScript itself recommends |
I looked into preparing tests, but ran into an issue with the |
I think it isn't critical to test |
…donly -> VisitorKeys
Ok, I've added some simple tests. I also added a commit on top of that to rename per your type renaming suggestions. |
Co-authored-by: Milos Djermanovic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
It looks like all comments by @nzakas have been addressed, so I'm merging this now for the release. The two new files we'll publish now have the following content.
/**
* Get visitor keys of a given node.
* @param {object} node The AST node to get keys.
* @returns {readonly string[]} Visitor keys of the node.
*/
export function getKeys(node: object): readonly string[];
/**
* Make the union set with `KEYS` and given keys.
* @param {VisitorKeys} additionalKeys The additional keys.
* @returns {VisitorKeys} The union set.
*/
export function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
export { KEYS };
export type VisitorKeys = {
readonly [type: string]: readonly string[];
};
import KEYS from "./visitor-keys.js";
//# sourceMappingURL=index.d.ts.map
export default KEYS;
export type VisitorKeys = import('./index.js').VisitorKeys;
/**
* @typedef {import('./index.js').VisitorKeys} VisitorKeys
*/
/**
* @type {VisitorKeys}
*/
declare const KEYS: VisitorKeys;
//# sourceMappingURL=visitor-keys.d.ts.map I verified that DefinitelyTyped/types/eslint-visitor-keys/eslint-visitor-keys-tests.ts works well with |
In the process of preparing ESLint for more type awareness, I figured we might avoid the need for an external
@types
package with the ability to maintain the types here (and to generate it out of JSDoc where possible as per eslint/js#529 (comment) ).One item I noticed in comparing with the declaration file in
@types/eslint-visitor-keys
is thatundefined
was allowed on properties, e.g.:In the PR, I have sought to preserve this ability, but I noticed that with the
unionWith
function, the additional keys argument couldn't include such properties as the current code would fail.