Skip to content

feat: validate type comments and generate .d.ts (take 2) #251

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

Merged
merged 2 commits into from
Apr 12, 2025

Conversation

ota-meshi
Copy link
Member

This PR makes the same change as #204 to generate types from JSDoc.
The difference from #204 is that it has been changed to work with Node v12, so there are no breaking changes in this PR.

fixes #150
closes #60
closes #204

@ota-meshi ota-meshi requested a review from a team April 11, 2025 01:22
Copy link

@scagood scagood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice to me!

Could we publish a prerelease with this so I can give it a little whirl in https://github.com/eslint-community/eslint-plugin-n? Or do you think its

Comment on lines +2 to +3
/** @typedef {import("eslint").Scope.Scope} Scope */
/** @typedef {import("eslint").Scope.Variable} Variable */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): Does the @import tag work here?

/**
 * @import { Scope } from "eslint"
 * @import { Identifier } from "estree"
 */

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried that already and strangely it shows ts warning as unused.

If I copy this code into an eslint-plugin-n project I get no warnings, so I think it's because this repository uses older TypeScript to support older Node.

image

Comment on lines +28 to +45
export type TraceMap<T = unknown> = {
[i: string]: TraceMapObject<T>
}

export type TraceMapObject<T> = {
[i: string]: TraceMapObject<T>
[CALL]?: T
[CONSTRUCT]?: T
[READ]?: T
[ESM]?: boolean
}

export type TrackedReferences<T> = {
info: T
node: Rule.Node
path: string[]
type: typeof CALL | typeof CONSTRUCT | typeof READ
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💜 Thank you

@ota-meshi ota-meshi merged commit d84fa55 into main Apr 12, 2025
17 checks passed
@ota-meshi ota-meshi deleted the generate-types2 branch April 12, 2025 13:58
Copy link

🎉 This PR is included in version 4.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding typescript declarations?
3 participants