Search code examples
javascripttypescriptjsxtsx

How to include a JavaScript file inside a TypeScript code?


carousel.js is my JavaScript code.Its purpose is to add Events like previous and next on a carousel.How should I use it in my TypeScript??

Down below is the render method where I have used some basic HTML.

  public render(): React.ReactElement<IReactCarouselProps> {

return (
   <div className={styles.image_carousel}>
        <div className={styles.inner}>
            <img className={styles.img} src="1.jpeg"/>
            <img className={styles.img} src="2.jpeg"/>
            <img className={styles.img} src="3.jpeg"/>
        </div>
        <div className={styles.bubbles}></div>
        <div className={styles.prev}></div>
        <div className={styles.next}></div>
   </div>


   );
}

Solution

  • You should not add JavaScripts into your TypeScript file.

    To get the work done, find a similar reference in TypeScript, as you want to have carousel, below are some npm packages which you can include.