deep-foundation / deepcase-app

https://deep-foundation.github.io/deepcase-app/
The Unlicense
11 stars 6 forks source link

Add possibility to write tsx in tsx #302

Open FreePhoenix888 opened 3 months ago

FreePhoenix888 commented 3 months ago

Description

I want to write code like this:

import { DeepClient } from "@deep-foundation/deeplinks/imports/client";
import type { Link } from "@deep-foundation/deeplinks/imports/minilinks";

async ({ deep }: {deep: DeepClient}) => {
  const React = await deep.import('react');
  const { Box } = await deep.import('@chakra-ui/react');

  return ({ style, link }: {style: object, link: Link<number>}) => {
    return <Box
        style={{ width: 300, height: 300, ...style }}
        bg={'bgColor'}
        color={'text'}
        borderColor={'borderColor'}
        borderWidth='1px'
        borderRadius='lg'
        padding={1}
    >
      UI for {link?.id || 0} goes here.
    </Box>
  }
}

And see its preview. But the only thing I see is error editor evalClientHandler error SyntaxError: Unexpected token 'export'

Expected Behavior

This code to work

Actual behavior

This code not working

Why I need this

I write in VSCode and like to have strong types and auto completion. I write this way for async handlers by using workaround (removing export statement in output code). I think we should fix this for both types of handlers