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

chore: improve compatibility with modern module resolution #719

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

dextertanyj
Copy link
Contributor

Problem

The modern "bundler" and "NodeNext" module resolution options do not support transitive dependencies properly, leading to errors such as "The inferred type of X cannot be named without reference to Y."

Solution

A fix is possible by explicitly importing transitive types when they are re-exported.

This results in the generated declaration build changing from

import { TextareaAutosizeProps } from 'react-textarea-autosize';
import { TextareaProps as ChakraTextareaProps } from '@chakra-ui/react';
export interface TextareaProps extends ChakraTextareaProps {
    /**
     * The minimum rows the textarea displays on render.
     * Defaults to `3`.
     */
    minAutosizeRows?: TextareaAutosizeProps['minRows'];
    /**
     * The maximum rows the textarea will automatically resize to.
     * Defaults to `6`.
     */
    maxAutosizeRows?: TextareaAutosizeProps['maxRows'];
    /**
     * Whether the input is in a prefilled state.
     */
    isPrefilled?: boolean;
    /**
     * Whether the input is in a success state.
     */
    isSuccess?: boolean;
}
export declare const Textarea: import("@chakra-ui/system/dist/system.types.js").ComponentWithAs<"textarea", TextareaProps>;

to

import { TextareaAutosizeProps } from 'react-textarea-autosize';
import { ComponentWithAs as _, TextareaProps as ChakraTextareaProps } from '@chakra-ui/react';
export interface TextareaProps extends ChakraTextareaProps {
    /**
     * The minimum rows the textarea displays on render.
     * Defaults to `3`.
     */
    minAutosizeRows?: TextareaAutosizeProps['minRows'];
    /**
     * The maximum rows the textarea will automatically resize to.
     * Defaults to `6`.
     */
    maxAutosizeRows?: TextareaAutosizeProps['maxRows'];
    /**
     * Whether the input is in a prefilled state.
     */
    isPrefilled?: boolean;
    /**
     * Whether the input is in a success state.
     */
    isSuccess?: boolean;
}
export declare const Textarea: _<"textarea", TextareaProps>;

@dextertanyj dextertanyj requested a review from karrui May 30, 2024 01:49
The modern "bundler" and "NodeNext" module resolution options do not support transitive dependencies properly, leading to errors such as "The inferred type of X cannot be named without reference to Y." A fix is possible by explicitly importing transitive types when they are re-exported.
@dextertanyj dextertanyj force-pushed the chore/bundler-module-resolution branch from 03fb977 to 23ad195 Compare May 30, 2024 02:14
@karrui karrui merged commit 6476d5f into update-chakra-ui Jun 10, 2024
10 checks passed
@karrui karrui deleted the chore/bundler-module-resolution branch June 10, 2024 02:56
dextertanyj added a commit that referenced this pull request Jun 12, 2024
The modern "bundler" and "NodeNext" module resolution options do not support transitive dependencies properly, leading to errors such as "The inferred type of X cannot be named without reference to Y." A fix is possible by explicitly importing transitive types when they are re-exported.
karrui added a commit that referenced this pull request Jun 18, 2024
…669)

* fix(deps): bump @chakra-ui/react and dependencies to latest versions

* fix: import chakra ui imports from main /react folder

* chore: improve compatibility with modern module resolution (#719)

The modern "bundler" and "NodeNext" module resolution options do not support transitive dependencies properly, leading to errors such as "The inferred type of X cannot be named without reference to Y." A fix is possible by explicitly importing transitive types when they are re-exported.

---------

Co-authored-by: Dexter Tan <[email protected]>
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