-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Labels
Description
Describe the bug
Invokes the evaluator to check if an expression is a constant or not, however when run on a TSX file this triggers a debug_unreachable statement deep in the Compressor
thread 'styled_tsx_fixture_swc_tests__fixture__tsx_expressions__input_tsx' panicked at /Users/lukesandberg/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swc_ecma_visit-14.0.0/src/lib.rs:618:9:
internal error: entered unreachable code: This visitor does not support TypeScript. This method fails for optimization purposes. Encountered in unreachable visitor: visit_ts_interface_decl
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Context: Decl(TsInterface(TsInterfaceDecl { span: 3..40, id: Ident { span: 13..18, ctxt: #2, sym: "Props", optional: false }, declare: false, type_params: None, extends: [], body: TsInterfaceBody { span: 19..40, body: [TsPropertySignature(TsPropertySignature { span: 25..38, readonly: false, key: Ident(Ident { span: 25..30, ctxt: #0, sym: "color", optional: false }), computed: false, optional: false, type_ann: Some(TsTypeAnn { span: 30..38, type_ann: TsKeywordType(TsKeywordType { span: 32..38, kind: TsStringKeyword }) }) })] } }))
lukesandberg/plugins#1 provides a simple repro
Not sure if i should file here or against styled-jsx, they do the exact same thing in babel
So perhaps the compressor should just ignore typescript code rather than crash? or perhaps there is a different API the plugin should be using?
Input code
interface Props {
color: string
}
export default (p:Props) => (
<div>
<p>test</p>
<style jsx>{`
span {
color: ${p.color};
}
`}</style>
</div>
);Config
Link to the code that reproduces this issue
SWC Info output
No response
Expected behavior
i would expect the program not to crash
Actual behavior
No response
Version
34
Additional context
No response