Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support SyntaxKind.Identifier #83

Merged
merged 2 commits into from
Oct 23, 2023
Merged

support SyntaxKind.Identifier #83

merged 2 commits into from
Oct 23, 2023

Conversation

StringKe
Copy link
Contributor

support export identifier

export const abc = () => {
}
abc.A = 1

@imjuni
Copy link
Owner

imjuni commented Oct 20, 2023

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
Copy link
Contributor Author

StringKe commented Oct 21, 2023

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
Copy link
Owner

imjuni commented Oct 21, 2023

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
Copy link

codecov bot commented Oct 23, 2023

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
@@            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 Coverage Δ
src/compilers/getIsIsolatedModules.ts 86.11% <50.00%> (-2.13%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imjuni imjuni merged commit 8ec2ea1 into imjuni:master Oct 23, 2023
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants