Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Oct 15, 2025

#14589 added comments field to Program in Oxlint JS plugins AST. Add this field to the TS type def for Program.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-ast-tools Area - AST tools labels Oct 15, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-bug Category - Bug label Oct 15, 2025
@overlookmotel overlookmotel marked this pull request as ready for review October 15, 2025 12:35
Copilot AI review requested due to automatic review settings October 15, 2025 12:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the comments field to the TypeScript type definition for Program in the Oxlint JS plugins AST, addressing a missing type definition that was causing TypeScript errors when accessing ast.comments.

  • Updates the TypeScript code generator to inject a comments: Comment[] field into the Program interface
  • Imports the Comment type alongside Span from the plugins types module
  • Removes the @ts-expect-error suppression that was previously needed to access the comments field

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
tasks/ast_tools/src/generators/typescript.rs Modifies the code generator to add comments field to Program interface and import Comment type
apps/oxlint/src-js/plugins/source_code.ts Removes @ts-expect-error suppression now that comments field is properly typed

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@overlookmotel overlookmotel self-assigned this Oct 15, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Oct 15, 2025
Copy link
Member Author

overlookmotel commented Oct 15, 2025

Merge activity

#14626)

#14589 added `comments` field to `Program` in Oxlint JS plugins AST. Add this field to the TS type def for `Program`.
@graphite-app graphite-app bot force-pushed the 10-15-fix_linter_plugins_add_comments_field_to_ts_type_def_for_program_ branch from 02f5aea to 5238891 Compare October 15, 2025 12:40
@overlookmotel
Copy link
Member Author

overlookmotel commented Oct 15, 2025

@lilnasy FYI the reason we don't include Comment in TS type defs is an oddity related to how AST is transferred to JS in parser when not using raw transfer (the default). In that case Comments are sent to JS as NAPI objects, and the library NAPI-RS already generates a TS type def for types which it handles.

#[derive(Debug, Clone)]
#[napi(object)]
pub struct Comment {
#[napi(ts_type = "'Line' | 'Block'")]
pub r#type: String,
pub value: String,
pub start: u32,
pub end: u32,
}

It's the no_ts_def attribute here which tells the codegen not to create a type def for it:

#[estree(add_fields(value = CommentValue), no_ts_def, no_parent)]
pub struct Comment {

This is a bit of a messy situation, but I think it's OK for now.

@graphite-app graphite-app bot merged commit 5238891 into main Oct 15, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 10-15-fix_linter_plugins_add_comments_field_to_ts_type_def_for_program_ branch October 15, 2025 12:46
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-cli Area - CLI A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants