mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
A project can now patch a package's declarations in package.json:
"scriptc": { "typePatches": { "<package>@<range>": { "declarations":
{ "<selector>": "<type>" } } } }. A leading "|" widens the declared type,
any other type replaces it. Selectors name declarations by path
(Type.member, fn(), fn(param), list()[], Env[string], export=(), default,
file.js:local()) and apply to the package's .d.ts, its JSDoc and its
@types twin alike.
Patches edit file text where every consumer reads it: the program host's
source reads (both checker worlds) and the npm-static passes that read
package files themselves. Only type nodes and JSDoc type tags change, and
no edit adds or removes a line. Installed copies are selected by version;
an @types twin by the runtime package's installed version. Patches that do
not apply as written warn (SC8030-SC8033) and the warnings repeat on
executable cache hits. Without the setting nothing changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
410 B
JSON
19 lines
410 B
JSON
{
|
|
"name": "commander-calc-fixture",
|
|
"private": true,
|
|
"type": "module",
|
|
"dependencies": {
|
|
"commander": "15.0.0"
|
|
},
|
|
"scriptc": {
|
|
"typePatches": {
|
|
"commander@^15.0.0": {
|
|
"note": "off a TTY, _getOutputContext() returns helpWidth undefined although the @typedef says number",
|
|
"declarations": {
|
|
"HelpContext.helpWidth": "| undefined"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|