You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Align parser and Issue classes with hed-typescript; fix five bugs - #933
Phases 1 and 2 of the hed-typescript realignment: the parser layer and the Issue classes now follow hed-typescript's idioms. Where the two repositories behave differently, the hed-javascript behavior is kept.
Parser:
ParsedHedTag has value, splitValue, remainder, takesValue and hasUnitClass getters and a two-argument constructor. Other classes no longer read its private fields.
The tokenizer keeps the last delimiter as two fields. GroupSpec defaults end to -1 and children to [].
The splitter caches its result.
recursiveMap takes (array, fn). New iteratePairwiseCombinations and src/utils/types.js.
ParsedHedString, ParsedHedSubstring and ParsedHedColumnSplice have a default export only.
normalized keeps the code-unit sort order, written as toSorted().
Issues:
Issue.message is computed from the current parameters. addParameters keeps an existing parameter instead of overwriting it, and generateMessage is now a no-op.
addIssueParameters replaces updateIssueParameters, which stays as an alias.
New IssueError.generateAndRethrow.
issueMessageTemplate replaces stringTemplate.
unmatchedLibrarySchema takes a prefix parameter instead of library.
BidsHedIssue gains toString and a static addIssueParameters, copies with cloneDeep, and turns unrecognized input into an internal error.
datasetParser and paths throw IssueError instead of Error.
types/index.d.ts and types/test.ts updated to match.
Fixed:
ParsedHedTag.unitClasses was always empty.
ParsedHedTag.checkValue accepted a value for a tag that takes none.
parseHedStrings ignored fullValidation.
subParsedGroupIterator(tagName) yielded every group.
The sidecar validator's second error check never stopped validation.
BidsDataset.create reported an internal error as a plain object without a severity.
21 new tests. npm test: 903 passed (was 882). npm run testSpecs: 1251 passed, 1 skipped (unchanged).
Phases 1 and 2 of the hed-typescript realignment: the parser layer and the
Issue classes now follow hed-typescript's idioms. Where the two repositories
behave differently, the hed-javascript behavior is kept.
Parser:
- ParsedHedTag has value, splitValue, remainder, takesValue and hasUnitClass
getters and a two-argument constructor. Other classes no longer read its
private fields.
- The tokenizer keeps the last delimiter as two fields. GroupSpec defaults
end to -1 and children to [].
- The splitter caches its result.
- recursiveMap takes (array, fn). New iteratePairwiseCombinations and
src/utils/types.js.
- ParsedHedString, ParsedHedSubstring and ParsedHedColumnSplice have a
default export only.
- normalized keeps the code-unit sort order, written as toSorted().
Issues:
- Issue.message is computed from the current parameters. addParameters keeps
an existing parameter instead of overwriting it, and generateMessage is now
a no-op.
- addIssueParameters replaces updateIssueParameters, which stays as an alias.
- New IssueError.generateAndRethrow.
- issueMessageTemplate replaces stringTemplate.
- unmatchedLibrarySchema takes a prefix parameter instead of library.
- BidsHedIssue gains toString and a static addIssueParameters, copies with
cloneDeep, and turns unrecognized input into an internal error.
- datasetParser and paths throw IssueError instead of Error.
- types/index.d.ts and types/test.ts updated to match.
Fixed:
- ParsedHedTag.unitClasses was always empty.
- ParsedHedTag.checkValue accepted a value for a tag that takes none.
- parseHedStrings ignored fullValidation.
- subParsedGroupIterator(tagName) yielded every group.
- The sidecar validator's second error check never stopped validation.
- BidsDataset.create reported an internal error as a plain object without a
severity.
21 new tests. npm test: 903 passed (was 882). npm run testSpecs: 1251
passed, 1 skipped (unchanged).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- BidsHedIssue.addIssueParameters refreshes line from the tsvLine parameter.
- Replacing Issue.parameters also clears the old bounds.
- The splitter again reports a HED string that is not a string as
invalidTagString instead of throwing a TypeError.
- iteratePairwiseCombinations yields pairs lazily instead of building all of
them first.
npm test: 905 passed. npm run testSpecs: 1251 passed, 1 skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
types/index.d.ts declared generateIssue, addIssueParameters and
updateIssueParameters as package exports, but index.js has never exported
them, so code that compiled against them failed at runtime. hed-typescript
does not export them either. They remain exported from src/issues/issues.js.
types/test.ts now builds its issues with the exported Issue constructor, and
npm run test-types runs to completion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@copilot: Your last review "A missing runtime export and mismatched TypeScript contracts can cause consumer compilation failures or runtime errors." was did not give useful information.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Public type contracts still mismatch runtime behavior, and dataset creation errors lose their location context.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Preserve dataset path when wrapping errors
src/bids/types/dataset.js:116
Passing null drops the dataset location previously included with unexpected errors. BidsHedIssue derives location from file?.path, so an error such as the new test's accessor failure now has neither the dataset path in its message nor a structured location. Pass the dataset-root path (or Uploaded files) when wrapping the error to preserve that diagnostic context.
Return defined values for valueless tags
src/parser/parsedHedTag.js:358
For a tag without a value, such as Red, _handleRemainder() returns before assigning _value or _splitValue, so both new getters return undefined. Their public declarations promise string and string | null, allowing calls such as tag.value.length to type-check but throw at runtime. Return an empty string and null for absent values so the getters match their declared contract without changing the backing fields.
Addresses the two issues in Copilot's summary review of PR #933 at
0a4892e. BidsDataset.create wrapped a dataset-level error with no file,
so it lost the location it had before (the dataset root, or "Uploaded
files" for browser input); it now passes that location. ParsedHedTag's
value and splitValue getters returned undefined for a tag without a
value although they are declared string and string | null; they now
return '' and null, leaving the backing fields unchanged.
hed-typescript has the same getter gap (parsedHedTag.ts:220-225) and
passes null in BidsDataset.create (dataset.ts:121); both go on the port
list. Three regression tests and two CHANGELOG clauses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
Phases 1 and 2 of the hed-typescript realignment: the parser layer and the Issue classes now follow hed-typescript's idioms. Where the two repositories behave differently, the hed-javascript behavior is kept.
Parser:
Issues:
Fixed:
21 new tests. npm test: 903 passed (was 882). npm run testSpecs: 1251 passed, 1 skipped (unchanged).