Importing from `@storybook/react-native` pollutes the React Native TypeScript environment with Node.js types
Describe the bug
Importing @storybook/react-native in a file that is part of a TypeScript program causes @types/node global types (Buffer, process, NodeJS.*, etc.) to leak into that entire program — including React Native application source that should have no Node globals.
The leak happens through a triple-slash directive: storybook/dist/node-logger/index.d.ts starts with /// <reference types="node" />. Because a /// <reference types="..." /> directive applies to the whole compilation, not just the file that declares it, @types/node is force-loaded globally. It is reachable from @storybook/react-native because its public type entry imports storybook/internal/{types,preview-api,csf,channels}, and Storybook 10 bundles those into shared .d.ts chunks that also import storybook/internal/node-logger.
The effect is that compilerOptions.types (e.g. ["jest"] from @react-native/typescript-config) is silently overridden: Node globals become available in RN code that will crash at runtime on device, and tsc reports no error.
To Reproduce
Minimal standalone project (pnpm, single tsconfig). Key files:
package.json
{
"name": "storybook-node-types-repro",
"private": true,
"packageManager": "[email protected]",
"dependencies": {
"@storybook/react-native": "10.6.0",
"react": "19.3.0",
"react-native": "0.87.1",
"react-native-safe-area-context": "5.9.1",
"storybook": "10.6.0"
},
"devDependencies": {
"@react-native/typescript-config": "0.87.1",
"@types/jest": "30.0.0",
"@types/react": "19.3.0",
"typescript": "7.0.2"
}
}
tsconfig.json — note types is not set here; the extended @react-native/typescript-config restricts it to ["jest"], so @types/node should not be in scope:
{
"extends": "@react-native/typescript-config",
"compilerOptions": {
"noEmit": true,
"jsx": "preserve",
"paths": { "src/*": ["./src/*"] }
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx",
"./.storybook/storybook.requires.ts",
"./.storybook/preview.ts"
]
}
.storybook/storybook.requires.ts — the only thing that imports @storybook/react-native:
/// <reference types="@storybook/react-native/metro-env" />
import { start } from '@storybook/react-native';
void start;
src/app.tsx — plain RN component; the last line is the probe. Buffer is a Node global and should be a type error, but it compiles cleanly:
import { View } from 'react-native';
export const App = () => <View />;
const _nodeGlobalProbe: Buffer = Buffer.from('probe');
Run:
pnpm install
pnpm exec tsc -p tsconfig.json --noEmit # exits 0 (bug); expected: error on Buffer
Confirm @types/node is force-loaded and trace why:
pnpm exec tsc -p tsconfig.json --listFilesOnly | grep '@types/node/index.d.ts'
pnpm exec tsc -p tsconfig.json --explainFiles | grep "Type library referenced via 'node'"
--explainFiles output shows the source of the leak:
Type library referenced via 'node' from file '.../storybook/dist/node-logger/index.d.ts'
And storybook/dist/node-logger/index.d.ts begins with:
/// <reference types="node" />
Expected behavior
Importing @storybook/react-native (or any storybook browser/preview API) should not inject @types/node global types into the whole TypeScript program. compilerOptions.types should be respected, and Buffer should be a type error in a React Native app file. Node-only globals should stay confined to Storybook's Node-side modules (e.g. node-logger) and not be reachable through the shared .d.ts chunks pulled in by browser/preview APIs.
Screenshots
N/A
Code snippets
See the files under To Reproduce above.
System:
Storybook Environment Info:
System:
OS: macOS 26.6.2
CPU: (18) arm64 Apple M5 Pro
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.21.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.19.0 - /opt/homebrew/bin/npm
pnpm: 12.3.1 - /opt/homebrew/bin/pnpm <----- active
npmPackages:
@storybook/react-native: 10.6.0 => 10.6.0
storybook: 10.6.0 => 10.6.0
Source: storybookjs/react-native