Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rest of src/ as TypeScript #233

Merged
merged 24 commits into from Feb 27, 2021
Merged

Refactor rest of src/ as TypeScript #233

merged 24 commits into from Feb 27, 2021

Conversation

eemeli
Copy link
Owner

@eemeli eemeli commented Feb 27, 2021

In addition to internal changes, there are some external changes as well:

  • The base class used by nodes is no longer exported. Internally it's been renamed as NodeBase, and its existence should be considered an implementation detail. If you were using it e.g. for instanceof Node checks, similar functionality is now provided by:
import { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq } from 'yaml'
isNode(foo) // returns true or false
  • The AST and Schema TS namespaces are dropped, as everything now has proper types.
  • All output Node types are unions of implementations, with the above is* functions working as type guards for them.

There are two main reasons for switching away from relying on instanceof:

  1. Being able to separate the checks to a different internal module than their implementations allowed for all dependency loops to be resolved. It was getting rather hairy otherwise.
  2. This should make the library more resilient against dual package hazards.

I am aware that the docs aren't updated here yet; I'll need to get to that separately.

…loops!)

BREAKING CHANGE: The Node base class is no longer exported. Prior users
of it should instead use the new `isNode` function.
@eemeli eemeli merged commit a51a079 into master Feb 27, 2021
@eemeli eemeli deleted the ts-more branch February 27, 2021 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant