Skip to content

[api-extractor] .d.ts rollup sometimes emits names that conflict with global names #1095

@octogonz

Description

@octogonz

Consider this example:

import { Promise as MyPromise } from './file1';

export function f(p1: Promise<void>, p2: MyPromise<void>): void {
  // p1 is using the ambient Promise from the compiler runtime
  // p2 is using the declaration from file1, which happens to use the same name "Promise"
  // in that file
}

In the .d.ts rollup, p1 and p2 accidentally end up with the same type:

declare class Promise<T> {
    private x;
}

export declare function f(p1: Promise<void>, p2: Promise<void>): void;

This happens because the algorithm doesn't realize that Promise is a global name introduced by lib.es2015.promise.d.ts, which comes in via this part of tsconfig.json:

    "lib": [
      "es5",
      "scripthost",
      "es2015.collection",
      "es2015.promise",
      "es2015.iterable",
      "dom"
    ],

This is breaking @microsoft/sp-application-base.

@iclanton

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions