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

Typescript error: Property 'children' does not exist on type 'IntrinsicAttributes & Props' (TailwindProvider) #169

Open
yhanssens opened this issue May 5, 2022 · 17 comments

Comments

@yhanssens
Copy link

I'm getting this error on a typescript project I'm currently working on but also occurs when initing a new typescript project.

I think this could be fixed by adding children?: React.ReactNode | React.ReactNode[] to the interface Props but I'm not entirely sure.

@yhanssens yhanssens changed the title Typescript error: Property 'children' does not exist on type 'IntrinsicAttributes & Props' (TailwindProvider). Typescript error: Property 'children' does not exist on type 'IntrinsicAttributes & Props' (TailwindProvider) May 5, 2022
@nivethan-me
Copy link

i'm also getting same error for the TailwindProvider

@bereket42
Copy link

Me too

@Jackmekiss
Copy link

Same

@fcastaneda9725
Copy link

Any update on this?

@frannale
Copy link

frannale commented Jun 7, 2022

You can edit your TailwindProvider interface definition props in node_modules/tailwind-rn/dist/tailwind-provider.d.ts like:

interface Props {
children: React.ReactNode;
utilities: Utilities;
colorScheme?: ColorSchemeName;
}

Can i do a pull request with this, but i need confirmation of some collaborator for the scope of the change

@brianarpie-forme
Copy link

Hey, any idea how can we can override this error without modifying node_modules?

@frannale
Copy link

frannale commented Jun 8, 2022

The unique solution is add the fix to master branch. The node_modules is genertaed by that.

@neo773
Copy link

neo773 commented Jun 28, 2022

Temporary workaround is to use patch-package module

npm i patch-package  --save-dev

Edit package.json and add this in scripts

"postinstall": "npx patch-package"

Edit TailwindProvider interface definition props in node_modules/tailwind-rn/dist/tailwind-provider.d.ts (Credit to frannale)

interface Props {
    utilities: Utilities;
    colorScheme?: ColorSchemeName;
    children?: React.ReactNode | React.ReactNode[]
}

Run

npx patch-package tailwind-rn

Done! the package will be auto patched whenever you reinstall the dependencies

@dan-online
Copy link

If anyone else is experiencing this, feel free to use my fork

@vadimdemedes
Copy link
Owner

I need to update tailwind-rn to support React 18 and new types from @types/react to make this error go away.

@marcelo-earth
Copy link

I need to update tailwind-rn to support React 18 and new types from @types/react to make this error go away.

I still have the same error with React 18.

  "dependencies": {
    "expo": "~46.0.8",
    "expo-status-bar": "~1.4.0",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-native": "0.69.4",
    "react-native-web": "~0.18.7",
    "tailwind-rn": "^4.2.0",
    "@expo/webpack-config": "^0.17.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@types/react": "~18.0.14",
    "@types/react-native": "~0.69.1",
    "concurrently": "^7.3.0",
    "postcss": "^8.4.16",
    "tailwindcss": "^3.1.8",
    "typescript": "~4.3.5"
  },

@ryantbrown
Copy link

What's going on here?

@marcelo-earth
Copy link

What's going on here?

I'm not sure

@dan-online
Copy link

See #158

@Gregoirevda
Copy link

Gregoirevda commented Mar 13, 2023

Without a patch, but overriding type definition

// app-env.d.ts

declare module 'tailwind-rn' {
  export * from 'tailwind-rn';

  interface Props {
    utilities: Utilities;
    colorScheme?: ColorSchemeName;
    children?: React.ReactNode | React.ReactNode[]
  }

  export const TailwindProvider: React.FC<Props>;
}

// tsconfig.json

  "include": ["app-env.d.ts", ...],

@groom7
Copy link

groom7 commented Sep 7, 2023

Without a patch, but overriding type definition

// app-env.d.ts

declare module 'tailwind-rn' {
  export * from 'tailwind-rn';

  interface Props {
    utilities: Utilities;
    colorScheme?: ColorSchemeName;
    children?: React.ReactNode | React.ReactNode[]
  }

  export const TailwindProvider: React.FC<Props>;
}

// tsconfig.json

  "include": ["app-env.d.ts", ...],

It helped me, but now I have a new error when importing useTilewind, do you know how to fix it?
import { useTailwind, TailwindProvider } from 'tailwind-rn';

Module '"tailwind-rn"' has no exported member 'useTailwind'.ts(2305)

@rolandin
Copy link

rolandin commented Oct 22, 2023

@groom7 typing the hook in a generic mode will help you at least get rid of the type issue until this gets fixed:

// app.env.d.ts

declare module 'tailwind-rn' {
 export * from 'tailwind-rn';

 export function useTailwind(): (classes: string) => any; // Generic type for useTailwind

 interface Props {
   utilities: Utilities;
   colorScheme?: ColorSchemeName;
   children?: React.ReactNode | React.ReactNode[];
 }

 export const TailwindProvider: React.FC<Props>;
}

Although I keep getting error with the classes, Im just gonna try an old version of the package

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

No branches or pull requests