v2.0.0
#377
Replies: 1 comment 1 reply
-
Can we please get some examples about how to port older typescript code to the new 2.0 version? We now gets lots of errors and is not clear how we should update the imports. Few examples below: test/utils/yaml.test.ts:2:48 - error TS2307: Cannot find module 'yaml/types' or its corresponding type declarations.
2 import { Node, Scalar, YAMLMap, YAMLSeq } from "yaml/types";
src/utils/yaml.ts:3:29 - error TS2305: Module '"yaml"' has no exported member 'parseCST'.
3 import { Document, Options, parseCST } from "yaml";
src/utils/docsParser.ts:4:10 - error TS2305: Module '"yaml/util"' has no exported member 'YAMLError'.
4 import { YAMLError } from "yaml/util"; If someone already made the switch, it would be awesome to put a link here, as it would make easier to figure out the list of changes we will need. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This update has been in the works for the last year and a half. Its prerelease versions have been thoroughly tested by a wide number of users, and I think it's finally ready for "actual" release, for use in the mythical "production".
The breaking changes introduced here are mostly originating from the v1 CST parser having become a rather difficult beast to work with. So it's here rewritten pretty much completely, now with a lexer as a first stage. Along the way, the whole project was rewritten in TypeScript and the export paths and options refactored pretty deeply.
If you've been using the library just via its
parse()
,parseDocument()
andstringify()
functions, then it's quite likely that none of the changes affect your experience in any way. However, if you've been doing something more involved, then I would strongly recommend that you review the library's documentation site for the v2 docs.Going forward, it's finally time to start experimenting with new YAML spec features that may eventually be included in YAML 1.3 and later. Those will be made available by specifying the
version: 'next'
option. However, beware! Any features available this way may be removed or have their API broken by any minor release of this library, and no compatibility guarantees with other libraries are given. In general, semver compatibility is guaranteed for features that are explicitly included in the documentation; everything else should be considered as internal implementation details.The following is an overview of the breaking changes and new features introduced in each of the prerelease steps leading up to this release; the individual releases' notes and the PRs will contain more detail, along with specific migration guides.
BREAKING CHANGES
v2.0.0-0
set()
in mappings & sequences (Update value with saving comment #185)v2.0.0-1
resolve()
API (Refactor tag resolve() API #201)v2.0.0-3
'yaml/parse-cst'
endpoint (Drop 'yaml/parse-cst' endpoint #223)v2.0.0-4
'yaml/types'
and some of'yaml/util'
into'yaml'
(Merge 'yaml/types' into 'yaml' & fiddle with 'yaml/util' #234)type
property from all but Scalar nodes (Droptype
property from all but Scalar nodes #240)v2.0.0-5
tokens
namespace asCST
(Add CST tools #252)[start, value-end, node-end]
(Refactor Node range as [start, value-end, node-end] #259)error.offset
witherror.pos: [number, number]
(Replace error.offset with error.pos: [number, number] #260)v2.0.0-6
v2.0.0-9
v2.0.0-10
doc.directives
now indicates it as optional (Allow for Schema instance as schema option #344)v2.0.0-11
YAML.defaultOptions
is removed (Remove YAML.defaultOptions #346)directives.marker
is renamed asdirectives.docStart
(Add directives.docEnd, for ... marker #371)v2.0.0
New Features
v2.0.0-0
set()
&setIn()
on doc with empty contents (Document setIn() should work if document contents are empty #174)defaultKeyType
option for finer control of scalar output (Surrounding array with items with quotes #179)v2.0.0-1
asBigInt
option for sexagesimal integer valuesv2.0.0-3
logLevel
option (Refactor logging control, adding logLevel option #215)visit(node, visitor)
to'yaml'
(Add visit(node, visitor) to 'yaml' #225)v2.0.0-4
'yaml/util'
that weren't exposed beforev2.0.0-5
v2.0.0-6
uniqueKeys
option (Check key uniqueness; add uniqueKeys option #271)COMMENT_SPACE
error; useMISSING_CHAR
for it insteadv2.0.0-7
<<
merge keys, in addition to alias valuesv2.0.0-8
aliasDuplicateObjects
(Add a new createNode option aliasDuplicateObjects #299)clone()
methods to Document, Directives, Schema and all Nodes (Add clone() methods to Document, Directives, Schema and all Nodes #304)v2.0.0-9
keepSoureToken
parse option, addingsrcToken
values to Nodes (Add keepSoureToken parse option, adding srcToken values to Nodes #309)customTags
is defined (Fixes & exports for custom composers #325)v2.0.0-10
v2.0.0-11
directives.docEnd
, for...
marker (Add directives.docEnd, for ... marker #371)YAML.visitAsync()
(AddYAML.visitAsync()
#372)v2.0.0
'next'
YAML versionThis discussion was created from the release v2.0.0.
Beta Was this translation helpful? Give feedback.
All reactions