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

[api-extractor]: Internal Error: Unable to follow symbol for "WebdriverIO" #4766

Open
Jym77 opened this issue Jun 6, 2024 · 0 comments
Open

Comments

@Jym77
Copy link

Jym77 commented Jun 6, 2024

Summary

Tried to run API extractor on a file using the WebdriverIO type from webdriverio package.
API extractor does not manage to find the type. I think this is linked to the fact that webdriverio declares WebdriverIO as a global symbol (using declare global { namespace WebdriverIO { … } }) whose typing (in my code) is ensured through a triple-slash directive (/// <reference types="webdriverio" />).

API extractor just crashes in that situation (instead of, e.g., exporting a plain text symbol).

This used to work on previous version of webdriver, where the triple-slash was on webdriverio/async, but that's not the way to go with latest version.

The TS code builds without problems (crashes if I remove the directive). The code is stripped down to just using the WebdriveIO.Browser type.

Repro steps

Failing action on a minimal repro repository.

Successful extraction on the real repo, using the previous major version of webdriverio.

Expected result: API extractor should be able to find the global type through the triple-slash directive, the same way TS does. Otherwise, outputting a plain text symbol would be better than crashing.

Actual result: Crash with error Internal Error: Unable to follow symbol for "WebdriverIO"

Details

Single file in my repo:

/// <reference types="webdriverio" />

/**
 * @public
 */
  export function foo(browser: WebdriverIO.Browser): void {
    return
}

TS config:

{
  "$schema": "http://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "incremental": true,
    "sourceMap": true,

    "target": "es2020",
    "lib": ["es2020", "DOM"],
    "module": "commonjs",
    "esModuleInterop": true,
    "strict": true
  }
}

The esModuleInterop may have something to do with this. It is needed due to how the latest webdriverio is packaged. It is a change in the config compared to previous (working) iteration.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version?
Operating system? Linux Debian in a WSL1 box
API Extractor scenario? reporting
Would you consider contributing a PR? No (no idea what goes wrong)
TypeScript compiler version? 5.4.5
Node.js version (node -v)? 20.7.0

WebdriverIO version: 8.38.2 (worked with 7.20.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: AE/AD
Development

No branches or pull requests

1 participant