microsoft / microsoft/typespec

[playground] react, react-dom and @fluentui/* should be peerDependencies

Open
#11,992 1 comment 1 reaction 1 assignee Claimed by @iscai-msft View on GitHub
bug design:needed triaged:core ui:playground
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

`@typespec/playground@0.17.1` declares `react`/`react-dom` (`^19.2.8`) and exact
`@fluentui/react-components@9.74.3` / `@fluentui/react-icons@2.0.333` as regular
`dependencies` and has no `peerDependencies` at all (`@typespec/html-program-viewer@0.86.0`
does the same).

If a consuming app pins a different exact version — e.g. `react@19.2.7` or
`@fluentui/react-components@~9.73.8` — npm installs a nested second copy under
`node_modules/@typespec/playground/node_modules/`. The app then renders nothing and the console
shows:

```
Invalid hook call. Hooks can only be called inside of the body of a function component.
...
3. You might have more than one copy of React in the same app
Uncaught TypeError: Cannot read properties of null (reading 'useState')
```

Declaring react, react-dom and the Fluent UI packages as `peerDependencies` (with a permissive
range) would make a duplicate installation impossible and let consumers control the versions.
```

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Read the [docs](https://typespec.io/docs/).
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.