Skip to content
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

fix(wasm): remove type defs for ArrayExpressionElement and Elision #6683

Open
wants to merge 1 commit into
base: 10-19-refactor_ast_tools_use_spaces_not_tabs_in_ts_type_defs
Choose a base branch
from

Conversation

overlookmotel
Copy link
Collaborator

@overlookmotel overlookmotel commented Oct 19, 2024

Follow-on after #6404.

ArrayExpressionElement and Elision are not used in the TS types, because ArrayExpression has an override for the field it uses.

pub struct ArrayExpression<'a> {
#[estree(flatten)]
pub span: Span,
#[tsify(type = "Array<SpreadElement | Expression | null>")]
pub elements: Vec<'a, ArrayExpressionElement<'a>>,
/// Array trailing comma
/// <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#arrays>
#[estree(skip)]
pub trailing_comma: Option<Span>,
}

Prevent these TS type defs being emitted by introducing a new #[estree(custom_ts_def)] attr, to go with #[estree(custom_serialize)].

Copy link

graphite-app bot commented Oct 19, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

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

@overlookmotel overlookmotel force-pushed the 10-19-refactor_ast_tools_use_spaces_not_tabs_in_ts_type_defs branch from e1c7f40 to af4c74e Compare October 19, 2024 09:34
@overlookmotel overlookmotel force-pushed the 10-19-fix_wasm_remove_type_def_for_arrayexpressionelement_ branch from 8938d54 to a798ae6 Compare October 19, 2024 09:34
@github-actions github-actions bot added A-ast Area - AST A-ast-tools Area - AST tools C-bug Category - Bug labels Oct 19, 2024
@overlookmotel overlookmotel changed the title fix(wasm): remove type def for ArrayExpressionElement fix(wasm): remove type defs for ArrayExpressionElement and Elision Oct 19, 2024
@overlookmotel overlookmotel marked this pull request as ready for review October 19, 2024 09:42
@overlookmotel overlookmotel force-pushed the 10-19-fix_wasm_remove_type_def_for_arrayexpressionelement_ branch from a798ae6 to 13f22eb Compare October 19, 2024 09:47
@overlookmotel
Copy link
Collaborator Author

@ottomated This is the most substantial change in this stack of PRs. The change is correct, but implementation is maybe a bit hacky. You may see a better way to achieve this.

Copy link

codspeed-hq bot commented Oct 19, 2024

CodSpeed Performance Report

Merging #6683 will not alter performance

Comparing 10-19-fix_wasm_remove_type_def_for_arrayexpressionelement_ (e865bb8) with 10-19-refactor_ast_tools_use_spaces_not_tabs_in_ts_type_defs (e4e1deb)

Summary

✅ 30 untouched benchmarks

let ts_type_def = quote! {
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = #ts_type_def;
let ts_type_def = if let Some(ts_type_def) = ts_type_def {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Option::map_or would make this easier to read? I think the implementation is fine especially since it'll be temporary.

@overlookmotel overlookmotel force-pushed the 10-19-refactor_ast_tools_use_spaces_not_tabs_in_ts_type_defs branch from af4c74e to e4e1deb Compare October 19, 2024 20:09
@overlookmotel overlookmotel force-pushed the 10-19-fix_wasm_remove_type_def_for_arrayexpressionelement_ branch from 13f22eb to e865bb8 Compare October 19, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-ast-tools Area - AST tools C-bug Category - Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants