imjuni / ctix

CLI to generate barrel file for webpack, rollup entrypoint
MIT License
81 stars 21 forks source link

support SyntaxKind.Identifier #83

Closed StringKe closed 11 months ago

StringKe commented 11 months ago

support export identifier

export const abc = () => {
}
abc.A = 1
imjuni commented 11 months ago

If you export an arrow function, it will be handled by the SyntaxKind.VariableDeclaration. Are there any cases that cannot be handled by a VariableDeclaration?

StringKe commented 11 months ago

It cannot be exported using this, which should be Identifier.

CleanShot 2023-10-21 at 09 35 50@2x

ast view

import { Checkbox as $Checkbox } from '@mantine/core';
import { useController } from 'react-hook-form';

import type { CheckboxProps as $CheckboxProps } from '@mantine/core';
import type { FieldValues, UseControllerProps } from 'react-hook-form';

import { CheckboxGroup } from './CheckBoxGroup';

export type CheckboxProps<T extends FieldValues> = UseControllerProps<T> &
    Omit<$CheckboxProps, 'checked' | 'defaultValue'>;

export const Checkbox = <T extends FieldValues>({
    name,
    control,
    defaultValue,
    rules,
    shouldUnregister,
    onChange,
    ...props
}: CheckboxProps<T>) => {
    const {
        field: { value, onChange: fieldOnChange, ...field },
        fieldState,
    } = useController<T>({
        name,
        control,
        defaultValue,
        rules,
        shouldUnregister,
    });

    return (
        <$Checkbox
            error={fieldState.error?.message}
            value={value}
            checked={value}
            onChange={(e) => {
                fieldOnChange(e);
                onChange?.(e);
            }}
            {...field}
            {...props}
        />
    );
};

Checkbox.Group = CheckboxGroup;
Checkbox.Item = $Checkbox;
imjuni commented 11 months ago

The getIsIsolatedModules function is used to determine whether or not the type keyword can be applied to the export syntax. For example, a class cannot add the type keyword, but an interface can. Since identifiers are typically treated as variables, the type keyword cannot be applied to them. Therefore, the return value of SyntaxKind.Identifier should be false, not true.

codecov[bot] commented 11 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (e40dd84) 88.29% compared to head (ca5cc43) 88.22%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #83 +/- ## ========================================== - Coverage 88.29% 88.22% -0.08% ========================================== Files 65 65 Lines 1085 1087 +2 Branches 222 223 +1 ========================================== + Hits 958 959 +1 - Misses 123 124 +1 Partials 4 4 ``` | [Files](https://app.codecov.io/gh/imjuni/ctix/pull/83?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ByungJoon+Lee) | Coverage Δ | | |---|---|---| | [src/compilers/getIsIsolatedModules.ts](https://app.codecov.io/gh/imjuni/ctix/pull/83?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ByungJoon+Lee#diff-c3JjL2NvbXBpbGVycy9nZXRJc0lzb2xhdGVkTW9kdWxlcy50cw==) | `86.11% <50.00%> (-2.13%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.