Fix: declare @types/js-yaml in core/package.json devDependencies - #680
Open
AmaadMartin wants to merge 1 commit into
Open
Fix: declare @types/js-yaml in core/package.json devDependencies#680AmaadMartin wants to merge 1 commit into
AmaadMartin wants to merge 1 commit into
Conversation
core/src imports js-yaml from two files, but js-yaml ships no bundled type declarations. @types/js-yaml was declared only in the workspace root manifest, and npm workspace hoisting resolved it into core. Delete the root declaration and core stops typechecking with two TS7016 errors. The range ^4.0.9 is copied verbatim from the root manifest, so npm resolves both declarations to the one existing tree and no second copy of the type package enters node_modules. It is a devDependency, not a dependency, because no js-yaml type reaches core/dist/types: yaml.load returns unknown in @types/js-yaml v4, and both call sites consume that unknown immediately. This follows the precedent already set in the same manifest by @types/adm-zip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
N/A
Problem:
core/srcimportsjs-yamlin two files, andjs-yamlships no bundled type declarations.@types/js-yamlis declared only in the root manifest, so npm workspace hoisting is the only reasoncoretypechecks today.core/package.jsontherefore does not declare everythingcoreneeds in order to build.Solution: I declared
@types/js-yamlincore/package.jsondevDependencies. The range^4.0.9is copied verbatim from the root manifest, so npm resolves both declarations to the one existing tree and no second copy entersnode_modules. It is adevDependencybecause nojs-yamltype reachescore/dist/types:yaml.loadreturnsunknownin@types/js-yamlv4, and both call sites consume thatunknownimmediately. This follows the precedent already in the same manifest,@types/adm-zip.The root declaration stays.
dev/srcalso importsjs-yamlanddev/package.jsondoes not declare the types yet, so removing the root entry would breakdev.Collision check: I listed all 379 open pull requests on the fork and diffed the 9 that touch
core/package.json(#273, #291, #292, #323, #327, #445, #541, #544, #635). None adds@types/js-yaml. #273, #323 and #541 moveopenapi-typesout of the same block and will conflict textually if one lands first; the resolution is to keep both edits.Testing Plan
This change adds no executable code, so it adds no test. The verification is the manifest reproduction, run in both directions.
Proof the change is load-bearing. The mutation is to delete the root declaration, which removes the hoisting accident.
Before the fix,
npx tsc --noEmit -p core/tsconfig.jsonfails:After the fix, with the root declaration still deleted, the same command exits 0. Core's own declaration supplies the types. I then restored the root manifest, so the final diff is
core/package.jsonandpackage-lock.jsononly.Unit Tests:
yaml.loadare the regression net.)npx vitest run core/test/skills/loader_test.ts core/test/tools/openapi_tool/openapi_toolset_integration_test.ts --project unit:core— 49 passed.npx vitest run --project unit:core --project unit:dev— 2583 passed, 1 failed. The failure isdev/test/cli/cli_create_test.ts > should handle Vertex AI selection with gcloud defaults. It reads localgclouddefaults and fails identically on the unmodified tree, so it is unrelated to this change.Other gates, all from the repository root:
npm install— changes only the two files above. The lockfile diff is one added line inpackages.core.devDependencies.npm run build— succeeds.grep -rn "js-yaml" core/dist/types/— no match, so no type leaks into the published declarations.npm run lint,npm run format:check,npx secretlint "**/*"— clean.npm run ts:check— 281 errors, the same count before and after this change. They are pre-existing and unrelated.Manual End-to-End (E2E) Tests:
Confirm the entry cannot reach consumers:
It lists
package.json,README.md,LICENSEanddist/**only, with no@typespayload.Checklist