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] Error: The expression contains an import() type, which is not yet supported by API Extractor #2140

Closed
1 of 2 tasks
Tracked by #290
imtaotao opened this issue Aug 25, 2020 · 5 comments

Comments

@imtaotao
Copy link

Please prefix the issue title with the project name i.e. [rush], [api-extractor] etc.

Is this a feature or a bug?

  • Feature
  • Bug

Please describe the actual behavior.
This error occurred when I merged types.

index.ts

import { channel } from './channel';
const Gar = { channel };

index.d.ts

/// <reference types="node" />
import { channel } from './channel';
declare const Gar: {
    channel: import("events").EventEmitter;
};

./channel.ts

import { EventEmitter } from 'events';
export const channel = new EventEmitter();

./channel.d.ts

/// <reference types="node" />
import { EventEmitter } from 'events';
export declare const channel: EventEmitter;

What is the expected behavior?
The above .d.ts is generated by tsc. I hope this syntax is allowed,no error happend 😂 , Thank you.

If this is a bug, please provide the tool version, Node.js version, and OS.

  • Tool:
  • **Tool Version:7.9.2
  • **Node Version:v12.18.2
    • **Is this a LTS version?no
    • **Have you tested on a LTS version?no
  • OS:
@imtaotao imtaotao changed the title Error: The expression contains an import() type, which is not yet supported by API Extractor [api-extractor] Error: The expression contains an import() type, which is not yet supported by API Extractor Aug 25, 2020
@imtaotao
Copy link
Author

imtaotao commented Aug 31, 2020

I have set api-extractor.json, but still can't found solution 😭.

child json

{
  "extends": "../../api-extractor.json",
  "mainEntryPointFilePath": "./dist/packages/<unscopedPackageName>/src/index.d.ts",
  "dtsRollup": {
    "publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
  }
}

parent json

{
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

  "apiReport": {
    "enabled": true,
    "reportFolder": "<projectFolder>/temp/"
  },

  "docModel": {
    "enabled": true
  },

  "dtsRollup": {
    "enabled": true
  },

  "tsdocMetadata": {
    "enabled": false
  },

  "messages": {
    "compilerMessageReporting": {
      "default": {
        "logLevel": "warning"
      }
    },

    "extractorMessageReporting": {
      "default": {
        "logLevel": "warning",
        "addToApiReportFile": true
      },

      "ae-missing-release-tag": {
        "logLevel": "none"
      }
    },

    "tsdocMessageReporting": {
      "default": {
        "logLevel": "warning"
      },

      "tsdoc-undefined-tag": {
        "logLevel": "none"
      }
    }
  }
}

@achrinza
Copy link

achrinza commented Sep 5, 2020

This is a known limitation: #1050

Try adding import { EventEmitter } from 'events'; to index.ts to prevent lazy imports.

@imtaotao
Copy link
Author

imtaotao commented Sep 6, 2020

Add import { EventEmitter } from 'events' can indeed solve this problem, but actually, not useing EventEmitter may make my colleague delete this line of code

@kasperisager
Copy link

I imagine this has been solved by #1916 as well.

@octogonz
Copy link
Collaborator

octogonz commented Jul 8, 2021

I imagine this has been solved by #1916 as well.

It has! Check out API Extractor 7.18.0! 🎈

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

No branches or pull requests

4 participants