Skip to content

Using Prebid with Typescript requires specific (undocumented) settings in tsconfig.json #14412

@a-lopatin-muse

Description

@a-lopatin-muse

Description

I’m using webpack + babel to bundle prebid 10 as a module in my project. When I import a prebid lib like this:

import 'prebid.js/modules/gptPreAuction';

TypeScript starts reporting a large number of errors coming from prebid source files, for example:

../../../../node_modules/prebid.js/src/video.ts:72:47
TS7006: Parameter 'method' implicitly has an 'any' type.

It looks like TypeScript treats prebid source files as part of my project, not as vendor code, even though they live in node_modules.

Expected behavior

Prebid should be treated as a third-party dependency, and TypeScript should not type-check its internal source files.

Actual behavior

After importing a module from prebid.js/modules/*, TypeScript starts type-checking files under: node_modules/prebid.js/src/**/*.ts

This results in many TS errors inside Prebid itself.

Environment

Prebid.js version: 10.15.0, webpack, babel, tsc

tsconfig.json options includes:

{
"exclude": ["node_modules", "**/node_modules"],
"skipLibCheck": true,
"allowJs": true,
"checkJs": false
}

decs.d.ts: declare module 'prebid.js';

What is a right way to build it now as a npm module?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Ready for Dev

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions