Repository navigation
Description
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed.
- I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
WithReactNativeCSSOptions in src/metro/index.ts documents typescriptEnvPath and disableTypeScriptGeneration with Defaults types-env.d.ts, where setupTypeScript writes react-native-css-env.d.ts (src/metro/typescript.ts), and writes both comments as /* */, which the built declaration drops, so an editor shows neither. The interface also repeats hexColors?: boolean, which CompilerOptions, the interface it extends, declares.
Library version
main at df32ce3
Environment info
System:
OS: Windows 11 10.0.26300
CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor "
Memory: 160.57 GB / 255.67 GB
Binaries:
Node:
version: 26.12.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 4.9.2
path: C:\Users\<user>\AppData\Roaming\npm\yarn.CMD
npm:
version: 12.2.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.26100.0
IDEs:
Android Studio: AI-262.9437.185.2621.16467767
Visual Studio: Not Found
Languages:
Java:
version: 17.0.20.1
path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 19.2.3
wanted: 19.2.3
react-native:
installed: 0.86.3
wanted: 0.86.3
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not foundSteps to reproduce
- Clone the reproducer branch, which is
mainat df32ce3 with one file added,reproduce.sh:git clone --branch repro/metro-option-comments https://github.com/YevheniiKotyrlo/react-native-css cd react-native-css - Run
./reproduce.sh. It runsyarn install --immutable, reads the default the two comments name against the filesetupTypeScriptwrites, runsyarn build, and reads the comments in the built declaration. It ends with one line:DEFECT: …and exit status 1 while a comment namestypes-env.d.tsor the declaration drops one,FIXED: …and 0 once neither holds,ERROR: …and 2 when the install or the build fails or a file no longer declares an option the check reads.
reproduce.sh:
#!/usr/bin/env bash
# Compares the default the Metro options' comments name with the file setupTypeScript writes, then builds the package and reads
# those comments in the declaration it publishes.
# Exits 1 while a comment names types-env.d.ts or the declaration drops a comment, 0 once neither holds, and 2 when a step before
# the check fails or a file no longer holds what the check reads.
set -uo pipefail
options_file=src/metro/index.ts
setup_file=src/metro/typescript.ts
declaration=dist/typescript/module/src/metro/index.d.ts
options=(typescriptEnvPath disableTypeScriptGeneration)
verdict() {
printf '%s\n' "$2"
exit "$1"
}
system=$(uname -sr) || verdict 2 "ERROR: uname failed"
node_version=$(node --version) || verdict 2 "ERROR: node is not on PATH"
yarn_version=$(yarn --version) || verdict 2 "ERROR: yarn is not on PATH"
revision=$(git rev-parse --short HEAD) || verdict 2 "ERROR: this is not a git checkout"
echo "System: $system, Node $node_version, Yarn $yarn_version, react-native-css $revision"
if ! install_output=$(yarn install --immutable 2>&1); then
printf '%s\n' "$install_output" | tail -n 15
verdict 2 "ERROR: yarn install --immutable failed, so nothing was built"
fi
echo "yarn install --immutable: done"
written=$(sed -n -E 's/^ *envPath = "([^"]+)",?$/\1/p' "$setup_file") || verdict 2 "ERROR: $setup_file cannot be read"
[ -n "$written" ] || verdict 2 "ERROR: $setup_file no longer sets envPath's default"
echo "$setup_file: setupTypeScript writes $written"
for option in "${options[@]}"; do
grep -n -B1 -E "^ +$option\?:" "$options_file" || verdict 2 "ERROR: $options_file no longer declares $option"
done
stale=$(grep -c -E '(^|[^-])types-env\.d\.ts' "$options_file")
if ! build_output=$(yarn build 2>&1); then
printf '%s\n' "$build_output" | tail -n 15
verdict 2 "ERROR: yarn build failed, so there is no declaration to read"
fi
echo "yarn build: done"
[ -f "$declaration" ] || verdict 2 "ERROR: yarn build wrote no $declaration"
documented=0
for option in "${options[@]}"; do
line=$(grep -n -E "^ +$option\?:" "$declaration" | head -n 1)
[ -n "$line" ] || verdict 2 "ERROR: $declaration no longer declares $option"
number=${line%%:*}
above=$(sed -n "$((number - 1))p" "$declaration")
printf '%s:%s: %s\n%s\n' "$declaration" "$((number - 1))" "$above" "$line"
if [[ $above =~ \*/[[:space:]]*$ ]]; then
documented=$((documented + 1))
fi
done
parts=()
if [ "$stale" -gt 0 ]; then
parts+=("$options_file names types-env.d.ts in $stale comments")
fi
if [ "$documented" -lt "${#options[@]}" ]; then
parts+=("$declaration documents $documented of ${#options[@]} options")
fi
if [ "${#parts[@]}" -eq 0 ]; then
verdict 0 "FIXED: the Metro options' comments name $written, and $declaration keeps both"
fi
summary=$(IFS=';' && echo "${parts[*]}")
verdict 1 "DEFECT: the Metro options' comments name another file than setupTypeScript writes, or leave the published declaration: ${summary//;/; }"Expected: the documented default is react-native-css-env.d.ts, and each option keeps its comment in dist/typescript/module/src/metro/index.d.ts; the options, their defaults and the file setupTypeScript writes stay as they are. The script ends with FIXED: the Metro options' comments name react-native-css-env.d.ts, and dist/typescript/module/src/metro/index.d.ts keeps both and exits 0.
Actual: both comments name types-env.d.ts, and the built declaration has neither; the script ends with this line and exits 1:
DEFECT: the Metro options' comments name another file than setupTypeScript writes, or leave the published declaration: src/metro/index.ts names types-env.d.ts in 2 comments; dist/typescript/module/src/metro/index.d.ts documents 0 of 2 options
The run's output on main at df32ce3, Windows 11, Node 26.12.1
System: MINGW64_NT-10.0-26300 3.6.10-5a1665c8.x86_64, Node v26.12.1, Yarn 4.9.2, react-native-css b6512d5
yarn install --immutable: done
src/metro/typescript.ts: setupTypeScript writes react-native-css-env.d.ts
13- /* Specify the path to the TypeScript environment file. Defaults types-env.d.ts */
14: typescriptEnvPath?: string;
15- /* Disable generation of the types-env.d.ts file. Defaults false */
16: disableTypeScriptGeneration?: boolean;
yarn build: done
dist/typescript/module/src/metro/index.d.ts:4: export interface WithReactNativeCSSOptions extends CompilerOptions {
5: typescriptEnvPath?: string;
dist/typescript/module/src/metro/index.d.ts:5: typescriptEnvPath?: string;
6: disableTypeScriptGeneration?: boolean;
DEFECT: the Metro options' comments name another file than setupTypeScript writes, or leave the published declaration: src/metro/index.ts names types-env.d.ts in 2 comments; dist/typescript/module/src/metro/index.d.ts documents 0 of 2 options
Reproducible example repository
https://github.com/YevheniiKotyrlo/react-native-css/tree/repro/metro-option-comments
Activity