iTwin / viewer-sample-angular

An Angular implementation of the iTwin Viewer.
MIT License
1 stars 3 forks source link

Build failure with "skipLibCheck=false" #16

Closed ckddbs closed 1 year ago

ckddbs commented 1 year ago
Error: node_modules/@itwin/core-bentley/lib/cjs/Tracing.d.ts:1:15 - error TS2614: Module '"@opentelemetry/api"' has no exported member 'SpanAttributes'. Did you mean to use 'import SpanAttributes from "@opentelemetry/api"' instead?

1 import type { SpanAttributes, SpanContext, SpanOptions, Tracer } from "@opentelemetry/api";
Screenshot 2022-12-16 at 3 36 40 PM
aruniverse commented 1 year ago

Check your lockfile, what version of @opentelemetry/api is getting pulled into your node_modules? I see it's available in 1.0.4 which is the version we use and have pinned in core-bentley.

image
ckddbs commented 1 year ago

Same version with https://github.com/iTwin/viewer-sample-angular/blob/main/package-lock.json. And @itwin/core-bentley has @opentelemetry/api as devDependencies.

aruniverse commented 1 year ago
image

So there are multiple copies of opentelemetry/api, mostly due to other dependencies pulling in a different version.

image

If you look closely, on our side we're just importing a type, which when compiled to javascript will not exist.

I recommend always turning on the skipLibCheck flag, mostly due to being unable to control transitive deps being pulled into your app.

ckddbs commented 1 year ago

Our app has many dependencies besides iTwin, so we don't want to turn on the skipLibCheck flag. If core-bently uses the library, why don't you add it as dependencies or peer-dependencies?

aruniverse commented 1 year ago

We're only using the package for types, theres no reason for it to be direct or peer dependency.

https://www.typescriptlang.org/tsconfig#skipLibCheck

"Rather than doing a full check of all d.ts files, TypeScript will type check the code you specifically refer to in your app’s source code."

Why would you want to type check everything in your node modules?