react-native-webview / react-native-webview

React Native Cross-Platform WebView
https://github.com/react-native-community/discussions-and-proposals/pull/3
MIT License
6.31k stars 2.96k forks source link

TypeScript support is broken starting from the `13.8.3` version #3374

Open anton-patrushev opened 2 months ago

anton-patrushev commented 2 months ago

Bug description: Both the latest (at the moment) 13.8.4 and 13.8.3 versions have broken TypeScript support. Props are not typified on these versions.

To Reproduce:

install 13.8.4 or 13.8.3 into TS configured project

yarn add react-native-webview@13.8.4

// OR

yarn add react-native-webview@13.8.3

I noticed that it doesn't have .d.ts files for each js file under node_modules/react-native-webview/lib/ folder

Here is what it looks like on 13.8.4

image

And it leads to issues like this:

image

Expected behavior:

It should have working TS support. So it should have TS support for WebView props.

Screenshot from the 13.8.2 version:

image

I believe it should have .d.ts file for each file under node_modules/react-native-webview/lib/ folder:

Screenshot from the 13.8.2version:

image

Environment:

netmaxt3r commented 2 months ago

I see types are moved to /index.d.ts ( better approach imho) , but index.d.ts is referencing ./lib/WebViewTypes which are pure js files without any type info. probably some ts build config issue, i am looking into permanent fix , meanwhile you can try below patch

diff --git a/node_modules/react-native-webview/index.d.ts b/node_modules/react-native-webview/index.d.ts
index 394b444..1cc0753 100644
--- a/node_modules/react-native-webview/index.d.ts
+++ b/node_modules/react-native-webview/index.d.ts
@@ -1,8 +1,8 @@
 import { Component } from 'react';
 // eslint-disable-next-line
-import { IOSWebViewProps, AndroidWebViewProps, WindowsWebViewProps } from './lib/WebViewTypes';
+import { IOSWebViewProps, AndroidWebViewProps, WindowsWebViewProps } from './src/WebViewTypes';

-export { FileDownload, WebViewMessageEvent, WebViewNavigation } from "./lib/WebViewTypes";
+export { FileDownload, WebViewMessageEvent, WebViewNavigation } from "./src/WebViewTypes";

 export type WebViewProps = IOSWebViewProps & AndroidWebViewProps & WindowsWebViewProps;
netmaxt3r commented 2 months ago

PR #3378 will fix typings , sourceMaps are still not linked let me know if sourcemap is required

eithe commented 2 months ago

Works in 2.8.6, this can probably be closed.

github-actions[bot] commented 1 week ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically