Skip to content

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

@mrdomino

Description

@mrdomino

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions