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

[Web] tsc failure with 1.17.0 and "strict": true in tsconfig.json #19403

Closed
mrdomino opened this issue Feb 3, 2024 · 1 comment · Fixed by #19458
Closed

[Web] tsc failure with 1.17.0 and "strict": true in tsconfig.json #19403

mrdomino opened this issue Feb 3, 2024 · 1 comment · Fixed by #19458
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template release:1.17.0

Comments

@mrdomino
Copy link

mrdomino commented Feb 3, 2024

Describe the issue

tsc prints the following when type-checking a project that depends on onnxruntime-web 1.17.0. This did not happen with 1.16.x.

app/components/App.ts:3:22 - error TS7016: Could not find a declaration file for module 'onnxruntime-web'. '[…]/node_modules/onnxruntime-web/dist/esm/ort.min.js' implicitly has an 'any' type.
  There are types at '[…]/node_modules/onnxruntime-web/types.d.ts', but this result could not be resolved when respecting package.json "exports". The 'onnxruntime-web' library may need to update its package.json or typings.

3 import * as ort from 'onnxruntime-web'

To reproduce

npx [email protected] --no-eslint --no-tailwind --ts --app --no-src-dir --import-alias '@/*' test
cd test
npm i onnxruntime-web
mkdir app/components
cat > app/components/App.ts <<EOF
'use client'

import * as ort from 'onnxruntime-web'

export default function App() {
  console.log(ort.Tensor)
}
EOF
npx tsc

Make sure that tsconfig.json has "strict": true. If you change it so that it has "strict": false instead, the error goes away.

Urgency

This prevents using onnxruntime-web in default NextJS apps.

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.17.0

Execution Provider

'wasm'/'cpu' (WebAssembly CPU), 'webgpu' (WebGPU)

@mrdomino mrdomino added the platform:web issues related to ONNX Runtime web; typically submitted using template label Feb 3, 2024
@fs-eire
Copy link
Contributor

fs-eire commented Feb 8, 2024

Thank you for the feedback. I can reproduce this issue. I am currently working on a change to fix it.

guschmue pushed a commit that referenced this issue Feb 8, 2024
### Description

Since TypeScript v4.7, types need to specify inside "exports" field when
it is available. This PR appends types just before each "default" (which
is required by spec to be the last item).

Fixes #19403.
YUNQIUGUO pushed a commit that referenced this issue Feb 9, 2024
### Description

Since TypeScript v4.7, types need to specify inside "exports" field when
it is available. This PR appends types just before each "default" (which
is required by spec to be the last item).

Fixes #19403.
siweic0 pushed a commit to siweic0/onnxruntime-web that referenced this issue May 9, 2024
### Description

Since TypeScript v4.7, types need to specify inside "exports" field when
it is available. This PR appends types just before each "default" (which
is required by spec to be the last item).

Fixes microsoft#19403.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template release:1.17.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants