Skip to content

TypeScript errors with ClayUI v3.143 on React 18.2 #6136

@noahbowman

Description

@noahbowman

In a standalone React/TypeScript project, all v3.143 @clayui/* dependencies fail with the same TS error on React 18.2 as this one for @clayui/layout:

Could not find a declaration file for module '@clayui/layout'. '../node_modules/@clayui/layout/lib/esm/index.js' implicitly has an 'any' type.
  There are types at '../node_modules/@clayui/layout/lib/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@clayui/layout' library may need to update its package.json or typings.ts(7016)

I can workaround this error on all @clayui/* libraries by adding my own path resolution in tsconfig.json to fix the missing type exports

// tsconfig.json
{
"compilerOptions": {
    "baseUrl": ".",
    "paths": {
      // workaround for @clayui not exporting types
      "@clayui/alert": ["node_modules/@clayui/alert/lib"],
      "@clayui/button": ["node_modules/@clayui/button/lib"],
      "@clayui/core": ["node_modules/@clayui/core/lib"],
      "@clayui/css": ["node_modules/@clayui/css/lib"],
      "@clayui/drop-down": ["node_modules/@clayui/drop-down/lib"],
      "@clayui/form": ["node_modules/@clayui/form/lib"],
      "@clayui/icon": ["node_modules/@clayui/icon/lib"],
      "@clayui/label": ["node_modules/@clayui/label/lib"],
      "@clayui/layout": ["node_modules/@clayui/layout/lib"],
      "@clayui/link": ["node_modules/@clayui/link/lib"],
      "@clayui/loading-indicator": ["node_modules/@clayui/loading-indicator/lib"],
      "@clayui/modal": ["node_modules/@clayui/modal/lib"],
      "@clayui/shared": ["node_modules/@clayui/shared/lib"],
      "@clayui/sticker": ["node_modules/@clayui/sticker/lib"],
      "@clayui/tooltip": ["node_modules/@clayui/tooltip/lib"]
    }
}

However, the workaround surfaces a more deep-seated TS error in ContainerFluid.d.ts: Type '"view" | "size" | "onError" | "containerElement" | "className" | "children" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | ... 247 more ... | "key"' does not satisfy the constraint 'keyof IProps'. Type '"placeholder"' is not assignable to type 'keyof IProps'.ts(2344). This revealed itself when trying to use ClayLayout.ContainerFluid in my component as normal, like this:

<ClayLayout.ContainerFluid className="class-name" view>
    ....
</ClayLayout.ContainerFluid>

Also, I cannot simply use any other versions of React (say 18.3) because of this:

npm error Could not resolve dependency:
npm error peer react@"^18.2.0" from @clayui/alert@3.143.0
npm error node_modules/@clayui/alert
npm error   @clayui/alert@"^3.143.0" from the root project

Environment

Tech Version
Clay v3.143.0
React v18.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugIssues reporting that Component is not doing what should be done

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions