futurepress / react-native-static-server

HTTP static file server for React Native
MIT License
362 stars 184 forks source link

Doesn't seem to support TypeScript #103

Open codthing opened 3 years ago

codthing commented 3 years ago

expo install react-native-static-server

image

Prompt that the module cannot be found

image

image

image

Version: win10 "expo": "~40.0.0" "react": "16.13.1" "react-dom": "16.13.1" "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz" "react-native-static-server": "^0.5.0"

zholmes1 commented 3 years ago
declare module 'react-native-static-server' {
  export default class StaticServer {
    constructor(port: number, path?: string)
    start: () => Promise<string>
    stop: () => void
    isRunning: () => Promise<boolean>
  }
}

Here's what I'm using. I didn't send a PR because it seems the constructor parameters are a little wonky. So I just typed for the constructor for how I use it. Put this in index.d.ts at the root of your project and you should be good to go.

smellman commented 3 years ago

I added typescript supports after 0.5.0 release. My PR was merged at last year but @fchasen didn't release it.