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

ast: serialize TSImportType.options as ObjectExpression #9663

Closed
Boshen opened this issue Mar 11, 2025 · 1 comment · Fixed by #9902
Closed

ast: serialize TSImportType.options as ObjectExpression #9663

Boshen opened this issue Mar 11, 2025 · 1 comment · Fixed by #9902
Assignees
Labels
C-enhancement Category - New feature or request

Comments

@Boshen
Copy link
Member

Boshen commented Mar 11, 2025

See #9662

https://github.com/typescript-eslint/typescript-eslint/blob/9aa0b6b49807599b1c2b704b778df74c91084a7c/packages/ast-spec/src/type/TSImportType/spec.ts#L8

export interface TSImportType extends BaseNode {
  type: AST_NODE_TYPES.TSImportType;
  argument: TypeNode;
  options: ObjectExpression | null;
  qualifier: EntityName | null;
  typeArguments: TSTypeParameterInstantiation | null;
}
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Mar 13, 2025

It looks like ts eslint changed this quite recently in typescript-eslint/typescript-eslint#10691. The rational is explained in typescript-eslint/typescript-eslint#10691 (comment). Since typescript ast lacks some span, they probes tokens to restore it.

For Oxc, I think the span for the inner braces { ... } is missing, so this probably prevents serialization to preserve spans propertly.

type A = import("foo", {  with:  {  foo: "foo"  }  })
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- TSImportAttributes.span
                          ^^^^                       <-- TSImportAttributes.attributes_keyword.span
                                 ^^^^^^^^^^^^^^^^    <-- ???
                                    ^^^^^^^^^^       <-- TSImportAttribute.span

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
2 participants