adam-26 / react-script-tag

A react <script> tag that supports universal rendering
MIT License
19 stars 6 forks source link

Error: Could not find a declaration file for module 'react-script-tag' #24

Closed dylannirvana closed 3 years ago

dylannirvana commented 3 years ago

Attempting a pretty simple usage after npm i --save react-script-tag

import React from 'react';
import Container from 'react-bootstrap/Container'
import ScriptTag from 'react-script-tag'

class Convertkit extends React.Component {
      render() {       
          return (
              <div >
                <Container className="section">
                   <ScriptTag async data-uid="e9274113f5" src="https://astounding-creator-7935.ck.page/e9274113f5/index.js" />
                </Container>
            </div>
        )
    }
}

export default Convertkit;

I am getting this error:

_Could not find a declaration file for module 'react-script-tag'. '/Users/dylannirvana/Documents/website/dylannirvana/client/nodemodules/react-script-tag/lib/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/react-script-tag if it exists or add a new declaration (.d.ts) file containing declare module 'react-script-tag';ts(7016)

dylannirvana commented 3 years ago

The error completely breaks the site

adam-26 commented 3 years ago

Your using typescript, this package has no typescript definitions. Your can define them yourself if you require them.

I'm no longer maintaining this repo.

grcodemonkey commented 2 years ago

This was my solution to this issue:

react-script-tag.d.ts

type ScriptTagProps = JSX.IntrinsicElements['script']

interface ReactScriptTagProps extends ScriptTagProps {
  /**
   * True if the <ScriptTag> is being hydrated on the client, otherwise false.
   */
  isHydrating?: boolean
}

declare module 'react-script-tag' {
  const content: React.FC<ReactScriptTagProps>
  export default content
}