tauri-apps/tauri

[bug] TypeScript error when creating webviewWindow from the latest documentation example code

Opened this issue · 1 comments

Describe the bug

When I use the following example code from the latest Tauri documentation to create a WebviewWindow:

import { Window } from "@tauri-apps/api/window";
import { Webview } from "@tauri-apps/api/webview";

const appWindow = new Window("uniqueLabel");

// loading embedded asset:
const webview = new Webview(appWindow, "theUniqueLabel", {
  url: "path/to/page.html",
});

I encounter a TypeScript error that prevents the code from passing lint checks and strict mode compilation:

Argument of type '{ url: string; }' is not assignable to parameter of type 'WebviewOptions'.
  Property 'x' is missing in type '{ url: string; }' but required in type 'WebviewOptions'.

Cause of the Issue

The TypeScript definition for WebviewOptions in @tauri-apps/api/webview.d.ts requires the properties x, y, width, and height as mandatory fields. This conflicts with the example code provided in the documentation, where only the url field is specified.

Additionally, the behavior when these parameters are not provided is unclear. Should these values default to specific dimensions and positions, or is their omission invalid? This discrepancy creates confusion when using the API.

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.16.0
    - npm: 10.8.1

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-http 🦀: 2.0.4
    - @tauri-apps/plugin-http : 2.0.1 (outdated, latest: 2.2.0)
    - tauri-plugin-fs 🦀: 2.1.0
    - @tauri-apps/plugin-fs : not installed!
    - tauri-plugin-os 🦀: 2.0.1
    - @tauri-apps/plugin-os : 2.0.0 (outdated, latest: 2.2.0)
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1 (outdated, latest: 2.2.0)
    - tauri-plugin-log 🦀: 2.0.2
    - @tauri-apps/plugin-log : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../out
    - devUrl: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace

No response

Additional context

No response

Hi @FabianLars i can check this one ?