Skip to content

Commit 66b84f4

Browse files
committed
fix: Use separate rather than inline type keyword for TS compatibility
1 parent 3bec004 commit 66b84f4

35 files changed

+80
-50
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default [
5555
'@typescript-eslint/consistent-type-exports': 'error',
5656
'@typescript-eslint/consistent-type-imports': [
5757
'error',
58-
{ fixStyle: 'inline-type-imports' }
58+
{ fixStyle: 'separate-type-imports' }
5959
],
6060
'@typescript-eslint/no-explicit-any': 'off',
6161
'@typescript-eslint/no-namespace': 'off',

src/cli.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { resolve } from 'node:path'
22
import { parseArgs } from 'node:util'
33

4-
import { type Token, prettyToken } from './parse/cst.ts'
4+
import type { Token } from './parse/cst.ts'
5+
import { prettyToken } from './parse/cst.ts'
56
import { Lexer } from './parse/lexer.ts'
67
import { Parser } from './parse/parser.ts'
78
import { Composer } from './compose/composer.ts'
89
import { LineCounter } from './parse/line-counter.ts'
9-
import { type Document } from './doc/Document.ts'
10+
import type { Document } from './doc/Document.ts'
1011
import { prettifyError } from './errors.ts'
11-
import { visit, type visitor } from './visit.ts'
12+
import type { visitor } from './visit.ts'
13+
import { visit } from './visit.ts'
1214

1315
export const help = `\
1416
yaml: A command-line YAML processor and inspector

src/compose/compose-collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
FlowCollection,
1010
SourceToken
1111
} from '../parse/cst.ts'
12-
import { type CollectionTag } from '../schema/types.ts'
12+
import type { CollectionTag } from '../schema/types.ts'
1313
import type { ComposeContext, ComposeNode } from './compose-node.ts'
1414
import type { ComposeErrorHandler } from './composer.ts'
1515
import { resolveBlockMap } from './resolve-block-map.ts'

src/compose/composer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Directives } from '../doc/directives.ts'
22
import { Document } from '../doc/Document.ts'
3-
import { type ErrorCode, YAMLParseError, YAMLWarning } from '../errors.ts'
3+
import type { ErrorCode } from '../errors.ts'
4+
import { YAMLParseError, YAMLWarning } from '../errors.ts'
45
import { isCollection, isPair } from '../nodes/identity.ts'
56
import type { ParsedNode, Range } from '../nodes/Node.ts'
67
import type {

src/compose/resolve-block-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ParsedNode } from '../nodes/Node.ts'
22
import { Pair } from '../nodes/Pair.ts'
33
import { YAMLMap } from '../nodes/YAMLMap.ts'
44
import type { BlockMap } from '../parse/cst.ts'
5-
import { type CollectionTag } from '../schema/types.ts'
5+
import type { CollectionTag } from '../schema/types.ts'
66
import type { ComposeContext, ComposeNode } from './compose-node.ts'
77
import type { ComposeErrorHandler } from './composer.ts'
88
import { resolveProps } from './resolve-props.ts'

src/compose/resolve-block-scalar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Range } from '../nodes/Node.ts'
1+
import type { Range } from '../nodes/Node.ts'
22
import { Scalar } from '../nodes/Scalar.ts'
33
import type { BlockScalar } from '../parse/cst.ts'
44
import type { ComposeContext } from './compose-node.ts'

src/compose/resolve-block-seq.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { YAMLSeq } from '../nodes/YAMLSeq.ts'
22
import type { BlockSequence } from '../parse/cst.ts'
3-
import { type CollectionTag } from '../schema/types.ts'
3+
import type { CollectionTag } from '../schema/types.ts'
44
import type { ComposeContext, ComposeNode } from './compose-node.ts'
55
import type { ComposeErrorHandler } from './composer.ts'
66
import { resolveProps } from './resolve-props.ts'

src/compose/resolve-flow-collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Pair } from '../nodes/Pair.ts'
33
import { YAMLMap } from '../nodes/YAMLMap.ts'
44
import { YAMLSeq } from '../nodes/YAMLSeq.ts'
55
import type { FlowCollection, Token } from '../parse/cst.ts'
6-
import { type Schema } from '../schema/Schema.ts'
7-
import { type CollectionTag } from '../schema/types.ts'
6+
import type { Schema } from '../schema/Schema.ts'
7+
import type { CollectionTag } from '../schema/types.ts'
88
import type { ComposeContext, ComposeNode } from './compose-node.ts'
99
import type { ComposeErrorHandler } from './composer.ts'
1010
import { resolveEnd } from './resolve-end.ts'

src/compose/resolve-flow-scalar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type ErrorCode } from '../errors.ts'
2-
import { type Range } from '../nodes/Node.ts'
1+
import type { ErrorCode } from '../errors.ts'
2+
import type { Range } from '../nodes/Node.ts'
33
import { Scalar } from '../nodes/Scalar.ts'
44
import type { FlowScalar } from '../parse/cst.ts'
55
import type { ComposeErrorHandler } from './composer.ts'

src/compose/util-flow-indent-check.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type Token } from '../parse/cst.ts'
2-
import { type ComposeErrorHandler } from './composer.ts'
1+
import type { Token } from '../parse/cst.ts'
2+
import type { ComposeErrorHandler } from './composer.ts'
33
import { containsNewline } from './util-contains-newline.ts'
44

55
export function flowIndentCheck(

src/doc/Document.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
import type { Node, NodeType, ParsedNode, Range } from '../nodes/Node.ts'
1212
import { Pair } from '../nodes/Pair.ts'
1313
import type { Scalar } from '../nodes/Scalar.ts'
14-
import { toJS, type ToJSContext } from '../nodes/toJS.ts'
14+
import type { ToJSContext } from '../nodes/toJS.ts'
15+
import { toJS } from '../nodes/toJS.ts'
1516
import type { YAMLMap } from '../nodes/YAMLMap.ts'
1617
import type { YAMLSeq } from '../nodes/YAMLSeq.ts'
1718
import type {
@@ -26,7 +27,8 @@ import { Schema } from '../schema/Schema.ts'
2627
import { stringifyDocument } from '../stringify/stringifyDocument.ts'
2728
import { anchorNames, createNodeAnchors, findNewAnchor } from './anchors.ts'
2829
import { applyReviver } from './applyReviver.ts'
29-
import { createNode, type CreateNodeContext } from './createNode.ts'
30+
import type { CreateNodeContext } from './createNode.ts'
31+
import { createNode } from './createNode.ts'
3032
import { Directives } from './directives.ts'
3133

3234
export type Replacer = any[] | ((key: any, value: any) => unknown)

src/doc/anchors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Scalar } from '../nodes/Scalar.ts'
44
import type { YAMLMap } from '../nodes/YAMLMap.ts'
55
import type { YAMLSeq } from '../nodes/YAMLSeq.ts'
66
import { visit } from '../visit.ts'
7-
import { type CreateNodeContext } from './createNode.ts'
7+
import type { CreateNodeContext } from './createNode.ts'
88
import type { Document } from './Document.ts'
99

1010
/**

src/nodes/Alias.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import type { FlowScalar } from '../parse/cst.ts'
44
import type { StringifyContext } from '../stringify/stringify.ts'
55
import { visit } from '../visit.ts'
66
import { ALIAS, isAlias, isCollection, isPair } from './identity.ts'
7-
import { type Node, NodeBase, type Range } from './Node.ts'
7+
import type { Node, Range } from './Node.ts'
8+
import { NodeBase } from './Node.ts'
89
import type { Scalar } from './Scalar.ts'
9-
import { toJS, type ToJSContext } from './toJS.ts'
10+
import type { ToJSContext } from './toJS.ts'
11+
import { toJS } from './toJS.ts'
1012
import type { YAMLMap } from './YAMLMap.ts'
1113
import type { YAMLSeq } from './YAMLSeq.ts'
1214

src/nodes/Node.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { applyReviver } from '../doc/applyReviver.ts'
22
import type { Document } from '../doc/Document.ts'
33
import type { ToJSOptions } from '../options.ts'
4-
import { type Token } from '../parse/cst.ts'
4+
import type { Token } from '../parse/cst.ts'
55
import type { StringifyContext } from '../stringify/stringify.ts'
66
import type { Alias } from './Alias.ts'
77
import { isDocument, NODE_TYPE } from './identity.ts'
88
import type { Scalar } from './Scalar.ts'
9-
import { toJS, type ToJSContext } from './toJS.ts'
9+
import type { ToJSContext } from './toJS.ts'
10+
import { toJS } from './toJS.ts'
1011
import type { MapLike, YAMLMap } from './YAMLMap.ts'
1112
import type { YAMLSeq } from './YAMLSeq.ts'
1213

src/nodes/Pair.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { createNode, type CreateNodeContext } from '../doc/createNode.ts'
1+
import type { CreateNodeContext } from '../doc/createNode.ts'
2+
import { createNode } from '../doc/createNode.ts'
23
import type { CollectionItem } from '../parse/cst.ts'
34
import type { Schema } from '../schema/Schema.ts'
45
import type { StringifyContext } from '../stringify/stringify.ts'

src/nodes/Scalar.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { BlockScalar, FlowScalar } from '../parse/cst.ts'
22
import { SCALAR } from './identity.ts'
3-
import { NodeBase, type Range } from './Node.ts'
4-
import { toJS, type ToJSContext } from './toJS.ts'
3+
import type { Range } from './Node.ts'
4+
import { NodeBase } from './Node.ts'
5+
import type { ToJSContext } from './toJS.ts'
6+
import { toJS } from './toJS.ts'
57

68
export const isScalarValue = (value: unknown) =>
79
!value || (typeof value !== 'function' && typeof value !== 'object')

src/nodes/YAMLMap.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import type { BlockMap, FlowCollection } from '../parse/cst.ts'
22
import type { Schema } from '../schema/Schema.ts'
33
import type { StringifyContext } from '../stringify/stringify.ts'
44
import { stringifyCollection } from '../stringify/stringifyCollection.ts'
5-
import { type CreateNodeContext } from '../util.ts'
5+
import type { CreateNodeContext } from '../util.ts'
66
import { addPairToJSMap } from './addPairToJSMap.ts'
77
import { Collection } from './Collection.ts'
88
import { isPair, isScalar, MAP } from './identity.ts'
99
import type { ParsedNode, Range } from './Node.ts'
1010
import { createPair, Pair } from './Pair.ts'
11-
import { isScalarValue, type Scalar } from './Scalar.ts'
11+
import type { Scalar } from './Scalar.ts'
12+
import { isScalarValue } from './Scalar.ts'
1213
import type { ToJSContext } from './toJS.ts'
1314

1415
export type MapLike =

src/nodes/YAMLSeq.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { createNode, type CreateNodeContext } from '../doc/createNode.ts'
1+
import type { CreateNodeContext } from '../doc/createNode.ts'
2+
import { createNode } from '../doc/createNode.ts'
23
import type { BlockSequence, FlowCollection } from '../parse/cst.ts'
34
import type { Schema } from '../schema/Schema.ts'
45
import type { StringifyContext } from '../stringify/stringify.ts'
@@ -7,8 +8,10 @@ import { Collection } from './Collection.ts'
78
import { isScalar, SEQ } from './identity.ts'
89
import type { ParsedNode, Range } from './Node.ts'
910
import type { Pair } from './Pair.ts'
10-
import { isScalarValue, type Scalar } from './Scalar.ts'
11-
import { toJS, type ToJSContext } from './toJS.ts'
11+
import type { Scalar } from './Scalar.ts'
12+
import { isScalarValue } from './Scalar.ts'
13+
import type { ToJSContext } from './toJS.ts'
14+
import { toJS } from './toJS.ts'
1215

1316
export declare namespace YAMLSeq {
1417
interface Parsed<

src/nodes/addPairToJSMap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { addMergeToJSMap, isMergeKey } from '../schema/yaml-1.1/merge.ts'
33
import { createStringifyContext } from '../stringify/stringify.ts'
44
import { isNode } from './identity.ts'
55
import type { Pair } from './Pair.ts'
6-
import { toJS, type ToJSContext } from './toJS.ts'
6+
import type { ToJSContext } from './toJS.ts'
7+
import { toJS } from './toJS.ts'
78
import type { MapLike } from './YAMLMap.ts'
89

910
export function addPairToJSMap(

src/parse/cst-scalar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import type { ComposeContext } from '../compose/compose-node.ts'
22
import type { ComposeErrorHandler } from '../compose/composer.ts'
33
import { resolveBlockScalar } from '../compose/resolve-block-scalar.ts'
44
import { resolveFlowScalar } from '../compose/resolve-flow-scalar.ts'
5-
import { type ErrorCode, YAMLParseError } from '../errors.ts'
6-
import { type Range } from '../nodes/Node.ts'
5+
import type { ErrorCode } from '../errors.ts'
6+
import { YAMLParseError } from '../errors.ts'
7+
import type { Range } from '../nodes/Node.ts'
78
import type { Scalar } from '../nodes/Scalar.ts'
89
import type { StringifyContext } from '../stringify/stringify.ts'
910
import { stringifyString } from '../stringify/stringifyString.ts'

src/public-api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Composer } from './compose/composer.ts'
22
import type { Reviver } from './doc/applyReviver.ts'
3-
import { Document, type Replacer } from './doc/Document.ts'
3+
import type { Replacer } from './doc/Document.ts'
4+
import { Document } from './doc/Document.ts'
45
import { prettifyError, YAMLParseError } from './errors.ts'
56
import { warn } from './log.ts'
67
import { isDocument } from './nodes/identity.ts'

src/schema/yaml-1.1/omap.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { isPair, isScalar } from '../../nodes/identity.ts'
2-
import { toJS, type ToJSContext } from '../../nodes/toJS.ts'
2+
import type { ToJSContext } from '../../nodes/toJS.ts'
3+
import { toJS } from '../../nodes/toJS.ts'
34
import { YAMLMap } from '../../nodes/YAMLMap.ts'
45
import { YAMLSeq } from '../../nodes/YAMLSeq.ts'
5-
import { type CreateNodeContext } from '../../util.ts'
6+
import type { CreateNodeContext } from '../../util.ts'
67
import type { Schema } from '../Schema.ts'
7-
import { type CollectionTag } from '../types.ts'
8+
import type { CollectionTag } from '../types.ts'
89
import { createPairs, resolvePairs } from './pairs.ts'
910

1011
export class YAMLOMap extends YAMLSeq {

src/schema/yaml-1.1/set.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import type { ToJSContext } from '../../nodes/toJS.ts'
55
import { findPair, YAMLMap } from '../../nodes/YAMLMap.ts'
66
import type { Schema } from '../../schema/Schema.ts'
77
import type { StringifyContext } from '../../stringify/stringify.ts'
8-
import { type CreateNodeContext, createPair } from '../../util.ts'
8+
import type { CreateNodeContext } from '../../util.ts'
9+
import { createPair } from '../../util.ts'
910
import type { CollectionTag } from '../types.ts'
1011

1112
export class YAMLSet<T = unknown> extends YAMLMap<T, Scalar<null> | null> {

src/stringify/stringifyCollection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Collection } from '../nodes/Collection.ts'
22
import { isNode, isPair } from '../nodes/identity.ts'
3-
import { stringify, type StringifyContext } from './stringify.ts'
3+
import type { StringifyContext } from './stringify.ts'
4+
import { stringify } from './stringify.ts'
45
import { indentComment, lineComment } from './stringifyComment.ts'
56

67
interface StringifyCollectionOptions {

src/stringify/stringifyPair.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { isCollection, isNode, isScalar, isSeq } from '../nodes/identity.ts'
22
import type { Pair } from '../nodes/Pair.ts'
33
import { Scalar } from '../nodes/Scalar.ts'
4-
import { stringify, type StringifyContext } from './stringify.ts'
4+
import type { StringifyContext } from './stringify.ts'
5+
import { stringify } from './stringify.ts'
56
import { indentComment, lineComment } from './stringifyComment.ts'
67

78
export function stringifyPair(

src/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ export type { FoldOptions } from './stringify/foldFlowLines.ts'
1414
export type { StringifyContext } from './stringify/stringify.ts'
1515
export { stringifyNumber } from './stringify/stringifyNumber.ts'
1616
export { stringifyString } from './stringify/stringifyString.ts'
17-

tests/clone.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { isAlias, isScalar, parseDocument, type Scalar, visit, type YAMLMap } from 'yaml'
1+
import type { Scalar, YAMLMap } from 'yaml'
2+
import { isAlias, isScalar, parseDocument, visit } from 'yaml'
23
import { source } from './_utils.ts'
34

45
describe('doc.clone()', () => {

tests/directives.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { parseDocument, type Scalar } from 'yaml'
1+
import type { Scalar } from 'yaml'
2+
import { parseDocument } from 'yaml'
23
import { source } from './_utils.ts'
34

45
describe('%TAG', () => {

tests/doc/anchors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { type Alias, Document, parse, parseDocument, type YAMLMap, type YAMLSeq } from 'yaml'
1+
import type { Alias, YAMLMap, YAMLSeq } from 'yaml'
2+
import { Document, parse, parseDocument } from 'yaml'
23

34
test('basic', () => {
45
const src = `- &a 1\n- *a\n`

tests/doc/createNode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { type Alias, Document, type Node, Scalar, YAMLMap, YAMLSeq } from 'yaml'
1+
import type { Alias, Node } from 'yaml'
2+
import { Document, Scalar, YAMLMap, YAMLSeq } from 'yaml'
23
import { source } from '../_utils.ts'
34

45
describe('createNode(value)', () => {

tests/doc/foldFlowLines.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as YAML from 'yaml'
2-
import { foldFlowLines as fold, type FoldOptions } from 'yaml/util'
2+
import type { FoldOptions } from 'yaml/util'
3+
import { foldFlowLines as fold } from 'yaml/util'
34
import { source } from '../_utils.ts'
45

56
const FOLD_FLOW = 'flow'

tests/node-to-js.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { parseDocument, type YAMLMap, type YAMLSeq } from 'yaml'
1+
import type { YAMLMap, YAMLSeq } from 'yaml'
2+
import { parseDocument } from 'yaml'
23
import { source } from './_utils.ts'
34

45
describe('scalars', () => {

tests/stream.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Composer, type Document, Parser, parseDocument } from 'yaml'
1+
import type { Document } from 'yaml'
2+
import { Composer, Parser, parseDocument } from 'yaml'
23

34
const src = `
45
#c0\n \n

tests/visit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Document, isSeq, parseDocument, type Scalar, visit, visitAsync } from 'yaml'
1+
import type { Scalar } from 'yaml'
2+
import { Document, isSeq, parseDocument, visit, visitAsync } from 'yaml'
23

34
const coll = { items: {} }
45

tests/yaml-test-suite.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { readdirSync, readFileSync } from 'fs'
22
import { resolve } from 'path'
33

4-
import { CST, type Document, Lexer, parse, parseAllDocuments, Parser } from 'yaml'
4+
import type { Document } from 'yaml'
5+
import { CST, Lexer, parse, parseAllDocuments, Parser } from 'yaml'
56
import { testEvents } from '../src/test-events.ts' // no public export
67

78
type TestCase = {

0 commit comments

Comments
 (0)