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

isolatedDeclarations omits import of type used in infer constraint #4018

Open
MichaelMitchell-at opened this issue Jul 2, 2024 · 1 comment · Fixed by #4043
Open

isolatedDeclarations omits import of type used in infer constraint #4018

MichaelMitchell-at opened this issue Jul 2, 2024 · 1 comment · Fixed by #4043
Labels
A-ast Area - AST C-bug Category - Bug

Comments

@MichaelMitchell-at
Copy link

Tested version: 0.16.3

> require('oxc-transform').isolatedDeclaration('hello.ts', `
    import {type Foo, type Bar} from '.';

    export type F<X extends Bar> = X extends infer U extends Foo ? U : never;
`)
{
  sourceText: "import { type Bar } from '.';\n" +
    'export type F<X extends Bar> = X extends infer U extends Foo ? U : never;\n',
  errors: []
}

Expected:

import { type Foo, type Bar } from '.';
export type F<X extends Bar> = X extends infer U extends Foo ? U : never;

Actual:

import { type Bar } from '.';
export type F<X extends Bar> = X extends infer U extends Foo ? U : never;
@MichaelMitchell-at MichaelMitchell-at added the C-bug Category - Bug label Jul 2, 2024
@Dunqing Dunqing added A-isolated-declarations Isolated Declarations A-ast Area - AST and removed A-isolated-declarations Isolated Declarations labels Jul 2, 2024
@Dunqing
Copy link
Member

Dunqing commented Jul 2, 2024

We need to visit all the fields of TSInferType in the Visit.

pub fn walk_ts_infer_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSInferType<'a>) {
let kind = AstKind::TSInferType(visitor.alloc(ty));
visitor.enter_node(kind);
visitor.visit_ts_type_parameter(&ty.type_parameter);
visitor.leave_node(kind);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST C-bug Category - Bug
Projects
None yet
2 participants