Transformer don't take source_type
param
#6248
Labels
A-transformer
Area - Transformer / Transpiler
C-cleanup
Category - technical debt or refactoring. Solution not expected to change behavior
Currently
Transformer::new
takes asource_type
param:oxc/crates/oxc_transformer/src/lib.rs
Lines 76 to 86 in bc757c8
Can we get rid of it?
source_type
is present inProgram
and parser updates it from "unambiguous" to either "script" or "module".It seems to make more sense to use the value of
source_type
present inProgram
, than allow user to over-ride it.I can't see any circumstance in which that's a useful thing to do, and it's a potential footgun. It's confusing that in transformer it's possible that
self.ctx.source_type.is_script() != !self.ctx.source_type.is_module()
, because it can also be "unambiguous". That's not theoretical - I hit this problem while trying to pass some TypeScript tests.If for some obscure reason, the user does want to override it, they can always alter the value of
Program::source_type
before passingProgram
to transformer.The text was updated successfully, but these errors were encountered: