prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

Rich Text Typings #47

Closed Gholgot closed 4 years ago

Gholgot commented 4 years ago

In order to fix the following issue : #42 Implementing a definition type for : RichText stateless component.

The Date export might be called differently in the future, to avoid overwriting the default Date JS class.

german-bortoli commented 4 years ago

Any update on this ?

imjasonmiller commented 4 years ago

It has been merged @german-bortoli thanks to @hypervillain :-)

Perhaps you are aware on what is the best way to go about including the types as of right now @Gholgot? Due to the package not yet being updated, npm i prismic-reactjs seemingly still gives you the package without the types.

I currently created types/prismic-reactjs and added the contents of typings/index.d.ts to it. This seems to work.

tsconfig.json

{
    "compilerOptions": {
        "typeRoots": ["./types", "./node_modules/@types"]    
    }
}

types/prismic-reactjs/index.d.ts

declare module "prismic-reactjs" {
    // content of typings/index.d.ts
}

Another option might be to pull it via GitHub as below, but having to build it yourself might be more of a hassle?

npm i @git://github.com/prismicio/prismic-reactjs.git#6682fe1 
haf commented 4 years ago

@imjasonmiller It would seem they have not released since this was merged. 1.2 is from jan.