Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript compilation errors when using @tauri-apps/api@1.0.0-beta.5 #2249

Closed
Dragoteryx opened this issue Jul 19, 2021 · 3 comments
Closed
Labels
scope: api.js The @tauri-apps/api npm package type: bug

Comments

@Dragoteryx
Copy link

Describe the bug

Currently working on an app using Tauri and Angular, I noticed that I get TypeScript compilation errors when using the latest version of Tauri. This doesn't happen when using @tauri-apps/api@1.0.0-beta.4.

To Reproduce

Create a new Angular project, then use tauri init.
Once that's done, use @tauri-apps/api in your project, then try compiling it.
I've only tested this issue using Angular, but someone on Discord said they encountered the same issue using Vue and TypeScript, so this doesn't seem to be Angular related.

Expected behavior

No compilation errors.

Screenshots

image

Platform and Versions (required):

Operating System - Windows, version 10.0.19042 X64
Webview2 - 91.0.864.70

Node.js environment
  Node.js - 16.5.0
  @tauri-apps/cli - 1.0.0-beta.6
  @tauri-apps/api - 1.0.0-beta.5

Global packages
  npm - 7.19.1
  yarn - Not installed

Rust environment      
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/.git
/dist
/node_modules
/src
/src-tauri

App
  tauri.rs - 1.0.0-beta.5
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:4200
  framework - Angular
  bundler - Webpack
@lemarier lemarier added the scope: api.js The @tauri-apps/api npm package label Jul 19, 2021
@scarmuega
Copy link

I'm experiencing the exact same behaviour. Would you kindly elaborate on how to fix or why the issue was closed? Thanks!

@amrbashir
Copy link
Member

@scarmuega this issue has been fixed in the dev branch, and will be available in the next release.

@8
Copy link

8 commented Aug 8, 2021

While waiting for the next release, I fixed it locally for me by moving the two lines with // @ts-expect-error one line down, so that the end result looks like:

/**
 * Get an instance of `WebviewWindow` for the current webview window.
 *
 * @return The current WebviewWindow.
 */
function getCurrent(): WebviewWindow {
  return new WebviewWindow(window.__TAURI__.__currentWindow.label, {
    // @ts-expect-error
    skip: true
  })
}

/**
 * Gets an instance of `WebviewWindow` for all available webview windows.
 *
 * @return The list of WebviewWindow.
 */
function getAll(): WebviewWindow[] {
  return window.__TAURI__.__windows.map(
    // @ts-expect-error
    (w) => new WebviewWindow(w, { skip: true })
  )
}

Take care,
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: api.js The @tauri-apps/api npm package type: bug
Projects
None yet
Development

No branches or pull requests

5 participants