typed-rocks / ts-worksheet

The Repository for Issues of the Plugin
MIT License
45 stars 0 forks source link

Error told me to create an issue #1

Open adamhinckley opened 9 months ago

adamhinckley commented 9 months ago

I work with a few repos at work that us TS. When I add //ts-worksheet at the top of any file and save I get this error:

ts-worksheet: An Error happend during the running of the worksheet. If you think there is something wrong with the plugin, please file an issue: : Error: Manipulation error: A syntax error was inserted. Users/adam.hinckley/projects/exit-offer-customizer-ui/src/util/.toedit.ts:123:13 - error TS1005: '>' expected. 123 status="error"    ~~~~~~ Users/adam.hinckley/projects/exit-offer-customizer-ui/src/util/.toedit.ts:123:19 - error TS1005: ',' expected. 123 status="error"    ~ Users/adam.hinckley/projects/exit-offer-customizer-ui/src/util/.toedit.ts:124:13 - error TS1005: ',' expected. 124 message={    ~~~~~~~ Users/adam.hinckley/projects/exit-offer-customizer-ui/src/util/.toedit.ts:[93...

It looks like it's saying there is a file called .toedit.ts in my util folder, but that file does not exist in my repo anywhere.

chwoerz commented 9 months ago

Hi thanks for opening this issue. Could you show me the file you added //ts-worksheet to it? This .toedit.ts is a temporary file which gets created by ts-morph.

chwoerz commented 9 months ago

This error means that I don't create valid wrapper code for your file. I should be able to fix it if I have the source code of the file or a minimal reproducible codesample.

smol-honk commented 9 months ago

I'm getting the same thing. It seems to break on my stitches components.

chwoerz commented 9 months ago

@smol-honk do you have a code example?

smol-honk commented 9 months ago

@smol-honk do you have a code example?

Unfortunately it's my work code. I'll try to put together something with the same stack to share.

chwoerz commented 9 months ago

Would be great. A minimal reproducible example would be nice.

chwoerz commented 9 months ago

I've done a basic example with styled and createStitches but did not receive any errors. Would be great to see where it fails for you. Which function for example.

adamhinckley commented 8 months ago

Sorry I'm late to this, but here's one file that I don't feel too bad sharing from my work code. Hopefully it's enough context to be helpful.

//ts-worksheet-with-variables
/** @jsxImportSource @emotion/react */
//libraries
import AddCircleIcon from '@mui/icons-material/AddCircle';
import { css } from '@emotion/react';
import { Typography } from '@mui/material';
import { useContext } from 'react';

//Local
import { BuilderContext } from '../../context/BuilderContext';
import { ViewModeEnum } from '../../util/globalTypes';

const AddContentStyles = (zonePrimaryColor: string, zoneHoverColor: string) => {
    return css`
        display: flex;
        flex-direction: row;
        color: ${zonePrimaryColor};
        align-items: center;
        width: 100%;
        min-height: 72px;
        justify-content: center;

        &.is-over {
            box-shadow: 0 0 0 2px ${zoneHoverColor};
        }

        p {
            margin-left: 10px;
            font-weight: 700;
            font-size: 0.875rem;
            letter-spacing: 1px;
            text-transform: uppercase;
        }
    `;
};

type AddContentProps = {
    isOver: boolean;
    zonePrimaryColor: string;
    zoneHoverColor: string;
};

const AddContent = ({ isOver, zonePrimaryColor, zoneHoverColor }: AddContentProps) => {
    const { viewMode } = useContext(BuilderContext);

    const isMobileView = viewMode === ViewModeEnum.MOBILE;

    return (
        <div
            css={AddContentStyles(zonePrimaryColor, zoneHoverColor)}
            className={`${isOver ? 'is-over ' : ''}${isMobileView ? 'mobile-add-content ' : ''}`}
        >
            <AddCircleIcon className="add-icon" />
            <Typography>Drop Module Here</Typography>
        </div>
    );
};

export default AddContent;

This is the error

ts-worksheet: An Error happend during the running of the worksheet. If you think there is something wrong with the plugin, please file an issue: : Error: Manipulation error: A syntax error was inserted. Users/adam.hinckley/projects/exit-offer-customizer-ui/src/components/mainDisplay/.toedit.ts:50:4 - error TS1005: '>' expected. 50 css={AddContentStyles(zonePrimaryColor, zoneHoverColor)}    ~~~ Users/adam.hinckley/projects/exit-offer-customizer-ui/src/components/mainDisplay/.toedit.ts:50:7 - error TS1005: ')' expected. 50 css={AddContentStyles(zonePrimaryColor, zoneHoverColor)}    ~ Users/adam.hinckley/projects/exit-offer-customizer-ui/src/components/mainDisplay/.toedit.ts:51:90 - error TS1136: Property assignment expected. 51 tsWorksheetWatch({type: 'expression', variab...
chwoerz commented 8 months ago

Thanks. I will look into it :)