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 npm packages contain .ts files #2598

Closed
probablykasper opened this issue Sep 13, 2021 · 5 comments
Closed

Tauri npm packages contain .ts files #2598

probablykasper opened this issue Sep 13, 2021 · 5 comments
Labels
good first issue Good for newcomers priority: 2 medium scope: api.js The @tauri-apps/api npm package type: bug

Comments

@probablykasper
Copy link
Member

Describe the bug

When importing @tauri-apps/api, I get TypeScript errors/warnings/hints from inside node_modules.

I thought this was an issue with svelte-check, but as explained in sveltejs/language-tools#1056 (comment) this happens because .ts files are being imported from node_modules.

This might also be the cause of #2594

Platform and Versions

Details
Operating System - Mac OS, version 10.15.7 X64

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

Global packages
  npm - 6.14.11
  yarn - 1.22.10

Rust environment
  rustc - 1.54.0
  cargo - 1.54.0

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

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 - ../build
  devPath - http://localhost:5000
  framework - Svelte

Stack Trace

Details
> @ check /Users/kasper/dev/git/kryp
> svelte-check --tsconfig ./tsconfig.json


====================================
Loading svelte-check in workspace: /Users/kasper/dev/git/kryp
Getting Svelte diagnostics...

/Users/kasper/dev/git/kryp/node_modules/@tauri-apps/api/helpers/event.ts:7:1
Error: This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'. 

import { WindowLabel } from '../window'
import { invokeTauriCommand } from './tauri'


/Users/kasper/dev/git/kryp/node_modules/@tauri-apps/api/event.ts:15:1
Error: This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'. 
import { transformCallback } from './tauri'
import { LiteralUnion } from 'type-fest'



/Users/kasper/dev/git/kryp/node_modules/@tauri-apps/api/helpers/os-check.ts:8:20
Hint: 'appVersion' is deprecated. 
function isLinux(): boolean {
  return navigator.appVersion.includes('Linux')
}


/Users/kasper/dev/git/kryp/node_modules/@tauri-apps/api/helpers/os-check.ts:12:20
Hint: 'appVersion' is deprecated. 
function isWindows(): boolean {
  return navigator.appVersion.includes('Win')
}


/Users/kasper/dev/git/kryp/node_modules/@tauri-apps/api/helpers/os-check.ts:16:20
Hint: 'appVersion' is deprecated. 
function isMacOS(): boolean {
  return navigator.appVersion.includes('Mac')
}


/Users/kasper/dev/git/kryp/src/lib/NumericInput.svelte:36:9
Error: Object is possibly 'null'. (ts)
      } else {
        start -= 1
        end -= 1


/Users/kasper/dev/git/kryp/src/lib/NumericInput.svelte:37:9
Error: Object is possibly 'null'. (ts)
        start -= 1
        end -= 1
      }


====================================
@amrbashir
Copy link
Member

We are aware of that and we were thinking of removing it as it is hard to support all typescript configurations.

@probablykasper
Copy link
Member Author

We are aware of that and we were thinking of removing it as it is hard to support all typescript configurations.

It's not really about supporting all typescript configurations, it's more that as far as I know typescript files generally shouldn't be in npm packages, instead it should just be .js and d.ts files

@amrbashir
Copy link
Member

Yeah generally npm packages don't ship .ts sources because they can fail on different tsconfig, something we didn't consider when we started shipping them in the published package.

@gotjoshua
Copy link

gotjoshua commented Jan 30, 2022

is this the cause of #1699 ?
and maybe of my current problem using isMac():
Screen Shot 2022-01-30 at 17 18 03

??

@amrbashir
Copy link
Member

@gotjoshua yes, next release won't have this issue

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

No branches or pull requests

3 participants