swc-project/swc · error
unable to access unknown nodes
Error message
unable to access unknown nodes
What it means
babelify maps TS function-parameter kinds (Ident, Array, Rest, Object) to TsFnParamOutput for signatures in interfaces and type literals. The `_` arm is compiled only under the `swc_ast_unknown` cfg and panics on a TsFnParam variant this build of swc_estree_compat does not recognize.
Source
Thrown at crates/swc_estree_compat/src/babelify/typescript.rs:89
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TsFnParamOutput {
Id(Identifier),
Array(ArrayPattern),
Rest(RestElement),
Object(ObjectPattern),
}
impl Babelify for TsFnParam {
type Output = TsFnParamOutput;
fn babelify(self, ctx: &Context) -> Self::Output {
match self {
TsFnParam::Ident(i) => TsFnParamOutput::Id(i.babelify(ctx)),
TsFnParam::Array(a) => TsFnParamOutput::Array(a.babelify(ctx)),
TsFnParam::Rest(r) => TsFnParamOutput::Rest(r.babelify(ctx)),
TsFnParam::Object(o) => TsFnParamOutput::Object(o.babelify(ctx)),
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
}
}
}
impl From<TsFnParamOutput> for IdOrRest {
fn from(o: TsFnParamOutput) -> Self {
match o {
TsFnParamOutput::Id(i) => IdOrRest::Id(i),
TsFnParamOutput::Rest(r) => IdOrRest::Rest(r),
_ => panic!("illegal conversion: Cannot convert {:?} to IdOrRest", &o),
}
}
}
impl From<TsFnParamOutput> for Identifier {
fn from(o: TsFnParamOutput) -> Self {
match o {
TsFnParamOutput::Id(i) => i,View on GitHub (pinned to 5176682b65)
Solutions
- Build the babelify path without `--cfg=swc_ast_unknown`
- Pin all swc crates to one swc_core release
- Cross boundaries via serialization so unknown variants error at decode
- Add the missing TsFnParam arm in typescript.rs upstream
Example fix
# before RUSTFLAGS="--cfg=swc_ast_unknown" cargo build # after cargo build
Defensive patterns
Strategy: validation
Validate before calling
#[cfg(swc_ast_unknown)]
compile_error!("babelify panics on Unknown TsFnParam nodes; build without --cfg=swc_ast_unknown"); Try / catch
use std::panic::{catch_unwind, AssertUnwindSafe};
catch_unwind(AssertUnwindSafe(|| program.babelify()))
.map_err(|p| anyhow!("babelify panicked: {:?}", p))?; Prevention
- Build estree hosts without --cfg=swc_ast_unknown
- Keep swc_ecma_ast / swc_estree_compat versions aligned
- Use serialization for ASTs crossing swc versions
- Track TypeScript AST additions in swc releases you adopt
When it happens
Trigger: Babelify a TypeScript interface/method signature whose parameter node carries an Unknown/newer TsFnParam variant while built with `--cfg=swc_ast_unknown` — e.g. converting an AST from a newer swc_ecma_ast inside a plugin host.
Common situations: Plugin development with the cfg auto-set; version drift between swc_ecma_ast and swc_estree_compat; converting deserialized ASTs across swc versions.
Related errors
- unable to access unknown nodes
- unable to access unknown nodes
- unable to access unknown nodes
- Cannot convert {p:?} to Param
- illegal conversion: Cannot convert {:?} to BabelParam
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/5481bda67d318dd2.
Report an issue: GitHub.