fix(typescript-fetch): compile runtime.ts with noUncheckedIndexedAccess
Fixes #25643.
Since 7.26.0 the generated runtime.ts of typescript-fetch does not compile in a project that enables noUncheckedIndexedAccess. The Content-Disposition parsing added in #24957 and #24974 reads regex capture groups by index without a guard, and under this option every indexed access has the type string | undefined. Consuming projects compile the generated clients with their own compiler options, so the update broke the build of such projects.
Changes
- fix: guard the three accesses in
typescript-fetch/runtime.mustache, as suggested in the issue, and regenerate the 25 typescript-fetch samples. The guarded groups always participate in a successful match, so the behaviour does not change. - test: add the type-check project
samples/client/petstore/typescript-fetch/tests/unchecked-indexed-access. It compiles every sampleruntime.tswithstrictandnoUncheckedIndexedAccess. It follows the model oftests/isolated-declarationsfrom #25277 and runs in the samepreteststep oftests/default, so the existing "Samples TS clients" workflow covers it.
I kept the new check separate from tests/isolated-declarations, because the README of that project says the option is disabled there on purpose, to keep the test focused on declaration emission.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
I built the CLI module with its dependencies, skipping the Java tests, and regenerated the./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exitbin/configs/typescript-fetch-*samples only. The change adds no generator option, so the generator docs are unchanged. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
cc @wing328
cc @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim @thekhegay
Summary by cubic
Fixes the typescript-fetch runtime.ts so it compiles in projects that enable noUncheckedIndexedAccess. The Content-Disposition parsing added in 7.26.0 read regex capture groups without a guard, breaking the build of consuming projects that compile the generated client with this compiler option. The guarded groups always participate in a successful match, so parsing behavior is unchanged; all 25 sample runtimes were regenerated.
Testing
- Adds a type-check project that compiles every sample
runtime.tswithstrictandnoUncheckedIndexedAccess, wired into the existingtests/defaultpretest step so CI covers it. The samples-typescript-fetch-client workflow now also watches the new test directory,tests/isolated-declarations, and generatedruntime.tsfiles directly.