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

tauri.ts errors when using typescript strict null checks #2594

Closed
Worble opened this issue Sep 12, 2021 · 1 comment
Closed

tauri.ts errors when using typescript strict null checks #2594

Worble opened this issue Sep 12, 2021 · 1 comment

Comments

@Worble
Copy link

Worble commented Sep 12, 2021

Describe the bug

Attempting to compile typescript after enabling strict null checks fails.

To Reproduce

Steps to reproduce the behavior:

  • Set strictNullChecks compiler option to true in tsconfig.json
  • Attempt to use any module from @tauri-apps/api
  • The following error should appear on compilation:
    ERROR in node_modules/@tauri-apps/api/tauri.ts:30:54
    TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
      Type 'undefined' is not assignable to type 'number'.
        28 |   const length = new Int8Array(1)
        29 |   window.crypto.getRandomValues(length)
      > 30 |   const array = new Uint8Array(Math.max(16, Math.abs(length[0])))
           |                                                      ^^^^^^^^^
        31 |   window.crypto.getRandomValues(array)
        32 |   return array.join('')
        33 | }
    

Expected behavior

The application should compile without errors.

Platform and Versions (required):

Operating System - Arch Linux, version Rolling Release X64

Node.js environment
  Node.js - 16.9.1
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 7.23.0
  yarn - Not installed

Rust environment
  rustc - 1.55.0
  cargo - 1.55.0

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

App
  tauri.rs - 1.0.0-beta.8
  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:8080
  framework - React
  bundler - Webpack
@amrbashir
Copy link
Member

closing in favor of #2598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants