MauiHybridWebView
MauiHybridWebView copied to clipboard
Typescript definitions
Just Trying to use it with a React Typescript SPA, but i don't get the javascript working in a typescript.
Already tried to make a global.d.ts, and make there the extends Operation to Window interface, but i get some Compiler Errors.
Can anybody help?
Hi, that would be a good area to improve for HybridWebView. Unfortunately I'm not very familiar with how this works with TypeScript or React, so if anyone can offer suggestions on how to do this, it'd be greatly appreciated!
Hi @Benni08
In my sample project, I am using the following type definition and calling it from React. The key points here as follows
- Type definition for window global in the hooks file.
https://github.com/yamachu/PokedexWithDotnetWebTechnologies/blob/73be030054d6a78b7e9f4921a9f6b0d21a480a78/react/packages/interop-hybridwebview/src/hooks/useHybridWebView.ts#L4-L8
This is the case when offered as a separate package, but of course it is also possible to offer them together as a single package. Type definitions can be enabled by creating a types directory, for example, and creating a d.ts file like the following
src/types/global.d.ts
export declare global {
interface Window {
HybridWebView: HybridWebView;
}
}
type HybridWebView = {
// actual HybridWebView types...
}