microsoft / microsoft/fluentui

api-extractor & build issue: Internal Error: The "MenuTrigger" symbol has a ts.SyntaxKind.Identifier declaration which is not (yet?) supported by API Extractor

Open
#19,360 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Build System Resolution: Soft Close Status: Fixed
Dominant language
TypeScript
Stars
20.3k
Forks
2.9k
Avg merge
2d 9h
Merged PRs (30d)
46

Description

Describe the issue:

While migrating react-components suite to new DX (https://github.com/microsoft/fluentui/pull/19040), an interesting error appeared both on local and CI:

Error: Internal Error: The "MenuTrigger" symbol has a ts.SyntaxKind.Identifier declaration which is not (yet?) supported by API Extractor

2021-08-11 at 10 19

Actual behavior:
Expected behavior:

api-extractor task should succeed


Troubleshooting

I was able to find 2 similar kind of issue on api-extractor repo:

Although none of those were exact match to this issue, so I dig deeper.

After reverse engineering api-extractor source I was able to find the issue:

The issue surfaced only now, because react-components re-exports multiple packages from N packages, which is not happening per narrowed package scope.

To better understand lets check following visualization of how build task is being executed (in simplified manner):

2021-08-11 at 10 42

the build was failing while running api-extractor task, with aforementioned error Error: Internal Error: The "MenuTrigger" symbol has a ts.SyntaxKind.Identifier declaration which is not (yet?) supported by API Extractor...

Why is that happening ?

IF take a look at MenuTrigger implementation

export const MenuTrigger: React.FC<MenuTriggerProps> = props => {
  const state = useMenuTrigger(props);

  return renderMenuTrigger(state);
};

MenuTrigger.displayName = 'MenuTrigger';

There is nothing suspicious right? If we remove MenuTrigger.displayName = 'MenuTrigger'; the error will go away. Most of other component is using forwardRef so probably that's where the problem lies ?

NOPE

The problem is ts.SyntaxKind.Identifier which means, parser has issues with const. Which brings us to -> wait why is api-extractor parsing implementation files instead of declaration types ?

Note: based on api-extractor docs, it stops parsing external packages completely

After many hours :D , I finally found the culprit:

  • our new DX is leveraging TS path aliases, so thats what is happening when executing API-extractor.
  • lets check the workflow that showcases the issue:

2021-08-11 at 11 08

How to fix this ?

  • just-scripts scope:
    • we'll need to provide similar processing like we do for ts task execution ( which is aware if package is using new DX thus turns off path aliases )
  • local:build scope:
    • we'll need to provide similar logic to just-scripts for api-extractor.local.json overrides for react-components initially, later on for all vNext packages

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the just-scripts TypeScript task processing and the local:build handling of api-extractor.local.json overrides for react-components. Compare how the TypeScript task handles new DX packages and path aliases. Done means the api-extractor task succeeds for react-components and its path aliases are handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.