Git Product home page Git Product logo

Comments (17)

shreedhan avatar shreedhan commented on May 10, 2024 3

@jonthomp I created a pull request here #341. Not sure, if this is the correct way to do it though.

from tabler-react.

AaronCoplan avatar AaronCoplan commented on May 10, 2024 1

The main reason I ask is if it were to be defined manually, it would be difficult to maintain as the tabler-react library changes or individual components' props change

from tabler-react.

m8r1x avatar m8r1x commented on May 10, 2024 1

Alright. I'll get started with that.

from tabler-react.

zoubarevm avatar zoubarevm commented on May 10, 2024 1

@m8r1x My first attempt at typings (so I'm not sure it's right).

#42

from tabler-react.

ellis avatar ellis commented on May 10, 2024 1

@jonthomp Can you say how the pull request from @shreedhan looks to you? I'd love to see it merged if it's ok.

from tabler-react.

levino avatar levino commented on May 10, 2024 1

This should be done at DT not here!

from tabler-react.

m8r1x avatar m8r1x commented on May 10, 2024

I could take this.
My approach would be to define the .d.ts files then copy them, maybe using cpx for cross-platform compatiblility sake, to the dist when the npm build script is triggered, hence bundling them together with the package.
If that's alright I can get started asap.

from tabler-react.

AaronCoplan avatar AaronCoplan commented on May 10, 2024

@m8r1x That approach sounds good to me - just a quick question first. I am by no means an expert in TypeScript, so I was wondering how you would be defining the .d.ts files? Would it be done manually or will there be some way of converting the flow types to ts types?

from tabler-react.

m8r1x avatar m8r1x commented on May 10, 2024

I've always opted for manual definition since I've never really found a great tool to auto generate from flow/js as intended.
Whenever I need the auto generate typings feature I opt to use Typescript from the start and let the compiler know that I need it using the declaration flag set to true.
react-to-typescript-definitions does a decent job but it relies on propTypes object definition to get the props type ts definitions.
I've also never used this package before but from the README it seems to also need propTypes definitions for stateless components.

from tabler-react.

AaronCoplan avatar AaronCoplan commented on May 10, 2024

This is the closest thing I can find https://github.com/bcherny/flow-to-typescript and that doesn't look super stable at the moment. Might be best to do manually for now, and then migrate to something like that once something mature is available

from tabler-react.

m8r1x avatar m8r1x commented on May 10, 2024

It looks great @zoubarevm
It'd be nice to get your feedback/thoughts on this variation as well

tabler-react-typings 2

from tabler-react.

zoubarevm avatar zoubarevm commented on May 10, 2024

@m8r1x I was wondering how you would do the NestedComponents. Looks good to me!

from tabler-react.

shreedhan avatar shreedhan commented on May 10, 2024

Is this going to be merged anytime soon?

from tabler-react.

jonthomp avatar jonthomp commented on May 10, 2024

@shreedhan I imagine this needs updating before being merged, would you be able to take a look and see? I've recently been having to use Typescript on some projects so will also try to have a look at some point

from tabler-react.

panmona avatar panmona commented on May 10, 2024

@levino Depends on how the project wants to handle it.

from tabler-react.

levino avatar levino commented on May 10, 2024

I would rather say it depends on whether or not the maintainers want to follow best practices or do something funky their own way. https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

Publishing
Now that you have authored a declaration file following the steps of this guide, it is time to publish it to > npm. There are two main ways you can publish your declaration files to npm:

  • bundling with your npm package, or
  • publishing to the @types organization on npm.

If your package is written in TypeScript then the first approach is favored. Use the --declaration flag to > generate declaration files. This way, your declarations and JavaScript will always be in sync.

If your package is not written in TypeScript then the second is the preferred approach

from tabler-react.

levino avatar levino commented on May 10, 2024

Maybe someone could open an issue over there and reference it here.

from tabler-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.