fix: fix config-array
and object-schema
types
#294
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.
Prerequisites checklist
What is the purpose of this pull request?
Correct several issues with the types for
config-array
andobject-schema
.StackBlitz Repro
What changes did you make? (Give an overview)
Renamed
dist/cts/types.ts
todist/cts/types.cts
In both
config-array
andobject-schema
,dist/cjs/index.d.cts
imports types from"./types.cts"
, but there is no such module. The corresponding file is namedtypes.ts
: https://app.unpkg.com/@eslint/config-array@0.21.0/files/dist/cjs/index.d.cts#L4, https://app.unpkg.com/@eslint/object-schema@2.1.6/files/dist/cjs/index.d.cts#L1-2.To fix this, I've update the Rollup config of both packages to ensure the generated type module in
dist/cjs
is correctly namedtypes.cts
rather thantypes.ts
.Removed type export for
@jsr/std__path
:@jsr/std__path
is a dev dependency ofconfig-array
. Its types are not visible outside the repo and are not supposed to be exported, as it is currently the case: https://app.unpkg.com/@eslint/config-array@0.21.0/files/dist/esm/index.d.ts#L7.I've converted a
@typedef
tag into an@import
to avoid exporting the types of the@jsr/std__path
package.Removed symbol signature from
ConfigArray
classThere is an unintentional indexed type with
symbol
key on theConfigArray
class that is incompatible with the baseArray
type: https://app.unpkg.com/@eslint/config-array@0.21.0/files/dist/esm/index.d.ts#L14.I've added a type cast to
never
on the expressions of the two computed keys to prevent TypeScript from adding the signature.Excluded
std_path
from type checkingThe files under
dist/*/std_path
inconfig-array
are extracted from a JSR package during the build. When TypeScript compiles the other sources, it reports several type errors for these files that can be disregarded.I've updated the Rollup config to add a
@ts-nocheck
comment to the files indist/*/std_path
.Added type tests
I've added minimal type tests to
config-array
andobject-schema
to catch compiler errors like to ones above. The type export from@jsr/std__path
is a special case, because those types are visible throughout the repo and TypeScript only reports an error when the dependency is not found.Related Issues
Is there anything you'd like reviewers to focus on?