Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Could not find a declaration file for module 'react-ios-switch' #24

Open
naajil-aamir opened this issue May 2, 2021 · 2 comments
Open

Comments

@naajil-aamir
Copy link

When importing switch in react ts file, the error is shown.

image

@joeyfigaro
Copy link

joeyfigaro commented Aug 18, 2021

@naajil-aamir the library doesn't currently provide any types. You can silence the error by creating react-ios-switch.d.ts with the following contents:

declare module 'react-ios-switch' {}

...make sure typescript is using the path where you save it in include inside your tsconfig.

For example, if I saved it at <project_root>/@types/react-ios-switch.d.ts, my tsconfig.json would have an include key with this:

{
  // ...
  include: [
    './src',
    './@types'
  ]
}

@freynolds-bh
Copy link

freynolds-bh commented Feb 14, 2022

This works

declare module 'react-ios-switch' {

  export default class Switch extends React.Component<IOSSwitchProps, IOSSwitchState> {
    checked: boolean
    className: string
    disabled: boolean
    handleColor: string
    name: string
    offColor: string
    onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
    onColor: string
    pendingOffColor: string
    pendingOnColor: string
    readOnly: boolean
    style: React.CSSProperties
  }
}

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants