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

Typings with babel #8

Closed
valoricDe opened this issue May 13, 2021 · 3 comments
Closed

Typings with babel #8

valoricDe opened this issue May 13, 2021 · 3 comments

Comments

@valoricDe
Copy link
Contributor

Hi @forsigner I'm integrating fower into my project and would like to use the babel preset approach.

I noticed that the typings themself were not working as described in the docs as it seems that it does not pickup all AtomicProps interface declarations.

I added import { Box } from "@fower/react" to index.d.ts which in turn references

/// <reference types="react" />
/// <reference types="@fower/types" />
/// <reference types="fower-plugin-appearance" />
/// <reference types="fower-plugin-background" />
/// <reference types="fower-plugin-border" />
/// <reference types="fower-plugin-box-alignment" />
/// <reference types="fower-plugin-color" />
/// <reference types="fower-plugin-display" />
...

maybe it is necessary to reference these types in @fower/types as well?

@0xkee
Copy link
Owner

0xkee commented May 14, 2021

Hello @valoricDe, if you integrating with @fower/babel-preset-fower, your index.d.ts should be:

import { AtomicProps } from '@fower/types';

declare module 'react' {
  interface HTMLAttributes<T> extends AtomicProps {}
}

and see: https://fower.vercel.app/docs/use-with-react#use-in-html-elements

@valoricDe
Copy link
Contributor Author

I did I did. I created a sandbox to showcase: https://codesandbox.io/s/tender-meninsky-uxvqm
If you uncomment the import the error goes away

@0xkee
Copy link
Owner

0xkee commented May 14, 2021

I tried it with create-react-app, I found that we should name typing file with global.d.ts, not index.d.ts, see: https://github.com/forsigner/fower/tree/master/examples/example-cra, it works in vscode, nut not work in codesandbox .

@0xkee 0xkee closed this as completed Aug 18, 2021
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

2 participants