kea-typegen 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/package.json +4 -4
- package/dist/src/print/print.js +1 -1
- package/dist/src/print/print.js.map +1 -1
- package/dist/src/print/printInternalExtraInput.js +1 -1
- package/dist/src/print/printInternalExtraInput.js.map +1 -1
- package/dist/src/print/printInternalSelectorTypes.js +1 -1
- package/dist/src/print/printInternalSelectorTypes.js.map +1 -1
- package/dist/src/print/printListeners.js +2 -2
- package/dist/src/print/printListeners.js.map +1 -1
- package/dist/src/print/printReducer.js +3 -3
- package/dist/src/print/printReducer.js.map +1 -1
- package/dist/src/print/printReducers.js +3 -3
- package/dist/src/print/printReducers.js.map +1 -1
- package/dist/src/print/printSelector.js +1 -1
- package/dist/src/print/printSelector.js.map +1 -1
- package/dist/src/print/printSelectors.js +2 -2
- package/dist/src/print/printSelectors.js.map +1 -1
- package/dist/src/print/printSharedListeners.js +4 -4
- package/dist/src/print/printSharedListeners.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.js +119 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/src/visit/visit.js +2 -3
- package/dist/src/visit/visit.js.map +1 -1
- package/dist/src/visit/visitActions.js +3 -4
- package/dist/src/visit/visitActions.js.map +1 -1
- package/dist/src/visit/visitConnect.js +1 -2
- package/dist/src/visit/visitConnect.js.map +1 -1
- package/dist/src/visit/visitKey.js +1 -2
- package/dist/src/visit/visitKey.js.map +1 -1
- package/dist/src/visit/visitLoaders.js +5 -5
- package/dist/src/visit/visitLoaders.js.map +1 -1
- package/dist/src/visit/visitSelectors.js +3 -3
- package/dist/src/visit/visitSelectors.js.map +1 -1
- package/dist/src/visit/visitSharedListeners.js +1 -2
- package/dist/src/visit/visitSharedListeners.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/samples/typed-builder/typedForm.typegen.ts +0 -1
- package/src/print/print.ts +0 -1
- package/src/print/printInternalExtraInput.ts +0 -1
- package/src/print/printInternalSelectorTypes.ts +0 -1
- package/src/print/printListeners.ts +0 -2
- package/src/print/printReducer.ts +0 -3
- package/src/print/printReducers.ts +0 -3
- package/src/print/printSelector.ts +0 -1
- package/src/print/printSelectors.ts +0 -2
- package/src/print/printSharedListeners.ts +0 -4
- package/src/types.ts +1 -1
- package/src/utils.ts +111 -5
- package/src/visit/visit.ts +4 -3
- package/src/visit/visitActions.ts +3 -5
- package/src/visit/visitConnect.ts +2 -3
- package/src/visit/visitKey.ts +2 -3
- package/src/visit/visitLoaders.ts +3 -6
- package/src/visit/visitSelectors.ts +4 -4
- package/src/visit/visitSharedListeners.ts +2 -3
|
@@ -12,7 +12,6 @@ export function printSharedListeners(parsedLogic: ParsedLogic) {
|
|
|
12
12
|
undefined,
|
|
13
13
|
[
|
|
14
14
|
factory.createParameterDeclaration(
|
|
15
|
-
undefined,
|
|
16
15
|
undefined,
|
|
17
16
|
undefined,
|
|
18
17
|
factory.createIdentifier('payload'),
|
|
@@ -21,7 +20,6 @@ export function printSharedListeners(parsedLogic: ParsedLogic) {
|
|
|
21
20
|
undefined,
|
|
22
21
|
),
|
|
23
22
|
factory.createParameterDeclaration(
|
|
24
|
-
undefined,
|
|
25
23
|
undefined,
|
|
26
24
|
undefined,
|
|
27
25
|
factory.createIdentifier('breakpoint'),
|
|
@@ -30,7 +28,6 @@ export function printSharedListeners(parsedLogic: ParsedLogic) {
|
|
|
30
28
|
undefined,
|
|
31
29
|
),
|
|
32
30
|
factory.createParameterDeclaration(
|
|
33
|
-
undefined,
|
|
34
31
|
undefined,
|
|
35
32
|
undefined,
|
|
36
33
|
factory.createIdentifier('action'),
|
|
@@ -39,7 +36,6 @@ export function printSharedListeners(parsedLogic: ParsedLogic) {
|
|
|
39
36
|
undefined,
|
|
40
37
|
),
|
|
41
38
|
factory.createParameterDeclaration(
|
|
42
|
-
undefined,
|
|
43
39
|
undefined,
|
|
44
40
|
undefined,
|
|
45
41
|
factory.createIdentifier('previousState'),
|
package/src/types.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import * as path from 'path'
|
|
3
|
-
import { cloneNode } from '
|
|
3
|
+
import { cloneNode } from 'ts-clone-node'
|
|
4
4
|
import { visitProgram } from './visit/visit'
|
|
5
5
|
import { parsedLogicToTypeString } from './print/print'
|
|
6
6
|
import { AppOptions, NameType, ParsedLogic } from './types'
|
|
@@ -85,17 +85,16 @@ export function getAndGatherTypeNodeForDefaultValue(
|
|
|
85
85
|
): ts.TypeNode {
|
|
86
86
|
const typeNode = getTypeNodeForNode(defaultValue, checker)
|
|
87
87
|
gatherImports(typeNode, checker, parsedLogic)
|
|
88
|
-
return
|
|
88
|
+
return cloneNodeSorted(typeNode)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function getParameterDeclaration(param: ts.ParameterDeclaration) {
|
|
92
92
|
return factory.createParameterDeclaration(
|
|
93
|
-
undefined,
|
|
94
93
|
undefined,
|
|
95
94
|
undefined,
|
|
96
95
|
factory.createIdentifier(param.name.getText()),
|
|
97
96
|
param.initializer || param.questionToken ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
|
|
98
|
-
|
|
97
|
+
cloneNodeSorted(param.type || factory.createKeywordTypeNode(SyntaxKind.AnyKeyword)),
|
|
99
98
|
undefined,
|
|
100
99
|
)
|
|
101
100
|
}
|
|
@@ -197,7 +196,7 @@ export function extractImportedActions(
|
|
|
197
196
|
}
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
extraActions[actionType] =
|
|
199
|
+
extraActions[actionType] = cloneNodeSorted(actionCreator.type) //payload
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
}
|
|
@@ -327,3 +326,110 @@ export function isAnyUnknown(node?: ts.Node): boolean {
|
|
|
327
326
|
(ts.isTypeLiteralNode(unPromised) && unPromised.members.length === 0)
|
|
328
327
|
)
|
|
329
328
|
}
|
|
329
|
+
|
|
330
|
+
const syntaxKindOrderOverride = (kind: ts.SyntaxKind): number => {
|
|
331
|
+
if (kind === ts.SyntaxKind.UndefinedKeyword) {
|
|
332
|
+
// sort undefineds at the end always
|
|
333
|
+
return 999
|
|
334
|
+
}
|
|
335
|
+
return kind
|
|
336
|
+
}
|
|
337
|
+
function compareNodes(a?: ts.Node, b?: ts.Node): number {
|
|
338
|
+
if (!a) {
|
|
339
|
+
if (!b) {
|
|
340
|
+
return 0
|
|
341
|
+
}
|
|
342
|
+
return -1
|
|
343
|
+
} else if (!b) {
|
|
344
|
+
return 1
|
|
345
|
+
}
|
|
346
|
+
if (ts.isLiteralTypeNode(a) && ts.isLiteralTypeNode(b)) {
|
|
347
|
+
if (ts.isStringLiteralLike(a.literal) && ts.isStringLiteralLike(b.literal)) {
|
|
348
|
+
return a.literal.text.localeCompare(b.literal.text)
|
|
349
|
+
} else if (ts.isNumericLiteral(a.literal) && ts.isNumericLiteral(b.literal)) {
|
|
350
|
+
return Number(a.literal.text) - Number(b.literal.text)
|
|
351
|
+
}
|
|
352
|
+
return a.literal.kind - b.literal.kind
|
|
353
|
+
} else if (ts.isTypeReferenceNode(a) && ts.isTypeReferenceNode(b)) {
|
|
354
|
+
try {
|
|
355
|
+
const textA = (a.typeName as any).escapedText || ''
|
|
356
|
+
const textB = (b.typeName as any).escapedText || ''
|
|
357
|
+
return textA.localeCompare(textB)
|
|
358
|
+
} catch (e) {
|
|
359
|
+
return 0
|
|
360
|
+
}
|
|
361
|
+
} else if (ts.isIdentifier(a) && ts.isIdentifier(b)) {
|
|
362
|
+
try {
|
|
363
|
+
const textA = (a as any).escapedText || ''
|
|
364
|
+
const textB = (b as any).escapedText || ''
|
|
365
|
+
return textA.localeCompare(textB)
|
|
366
|
+
} catch (e) {
|
|
367
|
+
return 0
|
|
368
|
+
}
|
|
369
|
+
} else if (ts.isImportTypeNode(a) && ts.isImportTypeNode(b)) {
|
|
370
|
+
const compare = compareNodes(a.argument, b.argument)
|
|
371
|
+
if (compare !== 0) {
|
|
372
|
+
return compare
|
|
373
|
+
}
|
|
374
|
+
return compareNodes(a.qualifier, b.qualifier)
|
|
375
|
+
} else if (ts.isUnionTypeNode(a) && ts.isUnionTypeNode(b)) {
|
|
376
|
+
if (a.types.length === b.types.length) {
|
|
377
|
+
for (let index = 0; index < a.types.length; index++) {
|
|
378
|
+
const compare = compareNodes(a.types[index], b.types[index])
|
|
379
|
+
if (compare !== 0) {
|
|
380
|
+
return compare
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return 0
|
|
384
|
+
}
|
|
385
|
+
return a.types.length - b.types.length
|
|
386
|
+
} else if (ts.isTypeLiteralNode(a) && ts.isTypeLiteralNode(b)) {
|
|
387
|
+
if (a.members.length === b.members.length) {
|
|
388
|
+
for (let index = 0; index < a.members.length; index++) {
|
|
389
|
+
const compare = compareNodes(a.members[index], b.members[index])
|
|
390
|
+
if (compare !== 0) {
|
|
391
|
+
return compare
|
|
392
|
+
}
|
|
393
|
+
if (ts.isPropertySignature(a.members[index]) && ts.isPropertySignature(b.members[index])) {
|
|
394
|
+
const typeCompare = compareNodes(
|
|
395
|
+
(a.members[index] as ts.PropertySignature).type,
|
|
396
|
+
(b.members[index] as ts.PropertySignature).type,
|
|
397
|
+
)
|
|
398
|
+
if (typeCompare !== 0) {
|
|
399
|
+
return typeCompare
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return 0
|
|
404
|
+
}
|
|
405
|
+
return a.members.length - b.members.length
|
|
406
|
+
} else if (ts.isArrayTypeNode(a) && ts.isArrayTypeNode(b)) {
|
|
407
|
+
return compareNodes(a.elementType, b.elementType)
|
|
408
|
+
} else if (ts.isPropertySignature(a) && ts.isPropertySignature(b)) {
|
|
409
|
+
try {
|
|
410
|
+
return a.name.getText().localeCompare(b.name.getText())
|
|
411
|
+
} catch (e) {
|
|
412
|
+
return ((a.name as any).escapedText || '').localeCompare((b.name as any).escapedText || '')
|
|
413
|
+
}
|
|
414
|
+
} else if (b.kind === a.kind) {
|
|
415
|
+
// if (a.kind !== 148 && a.kind !== 152 && a.kind !== 155 && a.kind !== 131) {
|
|
416
|
+
// debugger
|
|
417
|
+
// }
|
|
418
|
+
}
|
|
419
|
+
return syntaxKindOrderOverride(a.kind) - syntaxKindOrderOverride(b.kind)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function cloneNodeSorted<T extends ts.Node>(node: T): T {
|
|
423
|
+
const visit = (node) => {
|
|
424
|
+
if (ts.isUnionTypeNode(node)) {
|
|
425
|
+
;(node.types as any as ts.Node[]).sort(compareNodes)
|
|
426
|
+
}
|
|
427
|
+
if (ts.isTypeLiteralNode(node) && node.members.length > 1) {
|
|
428
|
+
;(node.members as any as ts.Node[]).sort(compareNodes)
|
|
429
|
+
}
|
|
430
|
+
ts.forEachChild(node, visit)
|
|
431
|
+
}
|
|
432
|
+
const cloned = cloneNode(node)
|
|
433
|
+
visit(cloned)
|
|
434
|
+
return cloned
|
|
435
|
+
}
|
package/src/visit/visit.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as path from 'path'
|
|
|
3
3
|
import * as fs from 'fs'
|
|
4
4
|
import { AppOptions, ParsedLogic, PluginModule, TypeBuilderModule, VisitKeaPropertyArguments } from '../types'
|
|
5
5
|
import {
|
|
6
|
+
cloneNodeSorted,
|
|
6
7
|
gatherImports,
|
|
7
8
|
getFilenameForImportDeclaration,
|
|
8
9
|
getFilenameForNode,
|
|
@@ -23,7 +24,7 @@ import { visitListeners } from './visitListeners'
|
|
|
23
24
|
import { visitEvents } from './visitEvents'
|
|
24
25
|
import { visitDefaults } from './visitDefaults'
|
|
25
26
|
import { visitSharedListeners } from './visitSharedListeners'
|
|
26
|
-
import { cloneNode } from '
|
|
27
|
+
import { cloneNode } from 'ts-clone-node'
|
|
27
28
|
|
|
28
29
|
const visitFunctions = {
|
|
29
30
|
actions: visitActions,
|
|
@@ -376,11 +377,11 @@ export function visitKeaCalls(
|
|
|
376
377
|
node: expression,
|
|
377
378
|
checker,
|
|
378
379
|
gatherImports: (input) => gatherImports(input, checker, parsedLogic),
|
|
379
|
-
cloneNode,
|
|
380
|
+
cloneNode: cloneNodeSorted,
|
|
380
381
|
getTypeNodeForNode: (node) => getTypeNodeForNode(node, checker),
|
|
381
382
|
prepareForPrint: (node) => {
|
|
382
383
|
gatherImports(node, checker, parsedLogic)
|
|
383
|
-
return
|
|
384
|
+
return cloneNodeSorted(node)
|
|
384
385
|
},
|
|
385
386
|
}
|
|
386
387
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ParsedLogic } from '../types'
|
|
2
2
|
import { factory, isFunctionLike, isPropertyAssignment, Expression, SyntaxKind, Type, TrueLiteral } from 'typescript'
|
|
3
3
|
import { NodeBuilderFlags } from 'typescript'
|
|
4
|
-
import {
|
|
5
|
-
import { gatherImports } from '../utils'
|
|
4
|
+
import { cloneNodeSorted, gatherImports } from '../utils'
|
|
6
5
|
|
|
7
6
|
export function visitActions(parsedLogic: ParsedLogic, type: Type, expression: Expression) {
|
|
8
7
|
const { checker } = parsedLogic
|
|
@@ -27,14 +26,13 @@ export function visitActions(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
27
26
|
gatherImports(param.type, checker, parsedLogic)
|
|
28
27
|
}
|
|
29
28
|
return factory.createParameterDeclaration(
|
|
30
|
-
undefined,
|
|
31
29
|
undefined,
|
|
32
30
|
undefined,
|
|
33
31
|
factory.createIdentifier(param.name.getText()),
|
|
34
32
|
param.initializer || param.questionToken
|
|
35
33
|
? factory.createToken(SyntaxKind.QuestionToken)
|
|
36
34
|
: undefined,
|
|
37
|
-
param.type ?
|
|
35
|
+
param.type ? cloneNodeSorted(param.type) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword),
|
|
38
36
|
undefined,
|
|
39
37
|
)
|
|
40
38
|
})
|
|
@@ -55,7 +53,7 @@ export function visitActions(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
gatherImports(returnTypeNode, checker, parsedLogic)
|
|
58
|
-
returnTypeNode =
|
|
56
|
+
returnTypeNode = cloneNodeSorted(returnTypeNode)
|
|
59
57
|
} else {
|
|
60
58
|
// action is a value (action: true)
|
|
61
59
|
returnTypeNode = factory.createTypeLiteralNode([
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ParsedLogic } from '../types'
|
|
2
2
|
import * as ts from 'typescript'
|
|
3
|
-
import { gatherImports, getParameterDeclaration } from '../utils'
|
|
4
|
-
import { cloneNode } from '@wessberg/ts-clone-node'
|
|
3
|
+
import { cloneNodeSorted, gatherImports, getParameterDeclaration } from '../utils'
|
|
5
4
|
import { Expression, Type } from 'typescript'
|
|
6
5
|
|
|
7
6
|
export function visitConnect(parsedLogic: ParsedLogic, type: Type, expression: Expression) {
|
|
@@ -74,7 +73,7 @@ export function visitConnect(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
74
73
|
if (ts.isTypeLiteralNode(returnType)) {
|
|
75
74
|
const payload = returnType.members.find((m) => m.name.getText() === 'payload')
|
|
76
75
|
if (ts.isPropertySignature(payload)) {
|
|
77
|
-
const returnTypeNode =
|
|
76
|
+
const returnTypeNode = cloneNodeSorted(payload.type)
|
|
78
77
|
gatherImports(actionType, checker, parsedLogic)
|
|
79
78
|
|
|
80
79
|
parsedLogic.actions.push({
|
package/src/visit/visitKey.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ParsedLogic } from '../types'
|
|
2
|
-
import {
|
|
3
|
-
import { gatherImports } from '../utils'
|
|
2
|
+
import { cloneNodeSorted, gatherImports } from '../utils'
|
|
4
3
|
import { Expression, Type } from 'typescript'
|
|
5
4
|
|
|
6
5
|
export function visitKey(parsedLogic: ParsedLogic, type: Type, expression: Expression) {
|
|
@@ -8,5 +7,5 @@ export function visitKey(parsedLogic: ParsedLogic, type: Type, expression: Expre
|
|
|
8
7
|
const typeNode = checker.typeToTypeNode(type, undefined, undefined)
|
|
9
8
|
gatherImports(typeNode, checker, parsedLogic)
|
|
10
9
|
|
|
11
|
-
parsedLogic.keyType =
|
|
10
|
+
parsedLogic.keyType = cloneNodeSorted(typeNode)
|
|
12
11
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
getAndGatherTypeNodeForDefaultValue,
|
|
18
18
|
isAnyUnknown,
|
|
19
19
|
unPromisify,
|
|
20
|
+
cloneNodeSorted,
|
|
20
21
|
} from '../utils'
|
|
21
22
|
import { NodeBuilderFlags } from 'typescript'
|
|
22
23
|
|
|
@@ -109,16 +110,14 @@ export function visitLoaders(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
109
110
|
|
|
110
111
|
const successParameters = [
|
|
111
112
|
factory.createParameterDeclaration(
|
|
112
|
-
undefined,
|
|
113
113
|
undefined,
|
|
114
114
|
undefined,
|
|
115
115
|
factory.createIdentifier(loaderName),
|
|
116
116
|
undefined,
|
|
117
|
-
returnTypeNode,
|
|
117
|
+
cloneNodeSorted(returnTypeNode),
|
|
118
118
|
undefined,
|
|
119
119
|
),
|
|
120
120
|
factory.createParameterDeclaration(
|
|
121
|
-
undefined,
|
|
122
121
|
undefined,
|
|
123
122
|
undefined,
|
|
124
123
|
factory.createIdentifier('payload'),
|
|
@@ -132,7 +131,7 @@ export function visitLoaders(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
132
131
|
undefined,
|
|
133
132
|
factory.createIdentifier(loaderName),
|
|
134
133
|
undefined,
|
|
135
|
-
returnTypeNode,
|
|
134
|
+
cloneNodeSorted(returnTypeNode),
|
|
136
135
|
),
|
|
137
136
|
factory.createPropertySignature(
|
|
138
137
|
undefined,
|
|
@@ -151,7 +150,6 @@ export function visitLoaders(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
151
150
|
if (!parsedLogic.actions.find(({ name }) => name === `${loaderActionName}Failure`)) {
|
|
152
151
|
const failureParameters = [
|
|
153
152
|
factory.createParameterDeclaration(
|
|
154
|
-
undefined,
|
|
155
153
|
undefined,
|
|
156
154
|
undefined,
|
|
157
155
|
factory.createIdentifier('error'),
|
|
@@ -160,7 +158,6 @@ export function visitLoaders(parsedLogic: ParsedLogic, type: Type, expression: E
|
|
|
160
158
|
undefined,
|
|
161
159
|
),
|
|
162
160
|
factory.createParameterDeclaration(
|
|
163
|
-
undefined,
|
|
164
161
|
undefined,
|
|
165
162
|
undefined,
|
|
166
163
|
factory.createIdentifier('errorObject'),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ParsedLogic } from '../types'
|
|
2
2
|
import * as ts from 'typescript'
|
|
3
3
|
import { Expression, NodeBuilderFlags, Type } from 'typescript'
|
|
4
|
-
import {
|
|
5
|
-
import { gatherImports } from '../utils'
|
|
4
|
+
import { cloneNodeSorted, gatherImports } from '../utils'
|
|
6
5
|
|
|
7
6
|
export function visitSelectors(parsedLogic: ParsedLogic, type: Type, expression: Expression) {
|
|
8
7
|
const { checker } = parsedLogic
|
|
@@ -48,7 +47,7 @@ export function visitSelectors(parsedLogic: ParsedLogic, type: Type, expression:
|
|
|
48
47
|
return {
|
|
49
48
|
name,
|
|
50
49
|
type: ts.isFunctionTypeNode(selectorTypeNode)
|
|
51
|
-
?
|
|
50
|
+
? cloneNodeSorted(selectorTypeNode.type)
|
|
52
51
|
: ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
|
53
52
|
}
|
|
54
53
|
})
|
|
@@ -62,10 +61,11 @@ export function visitSelectors(parsedLogic: ParsedLogic, type: Type, expression:
|
|
|
62
61
|
let typeNode: ts.TypeNode
|
|
63
62
|
if (computedFunction.type) {
|
|
64
63
|
gatherImports(computedFunction.type, checker, parsedLogic)
|
|
65
|
-
typeNode =
|
|
64
|
+
typeNode = cloneNodeSorted(computedFunction.type)
|
|
66
65
|
} else if (type) {
|
|
67
66
|
typeNode = checker.typeToTypeNode(type, undefined, NodeBuilderFlags.NoTruncation)
|
|
68
67
|
gatherImports(typeNode, checker, parsedLogic)
|
|
68
|
+
typeNode = cloneNodeSorted(typeNode)
|
|
69
69
|
} else {
|
|
70
70
|
typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
|
|
71
71
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ParsedLogic } from '../types'
|
|
2
2
|
import * as ts from 'typescript'
|
|
3
|
-
import {
|
|
4
|
-
import { gatherImports } from '../utils'
|
|
3
|
+
import { cloneNodeSorted, gatherImports } from '../utils'
|
|
5
4
|
import { Expression, Type } from 'typescript'
|
|
6
5
|
|
|
7
6
|
export function visitSharedListeners(parsedLogic: ParsedLogic, type: Type, expression: Expression) {
|
|
@@ -15,7 +14,7 @@ export function visitSharedListeners(parsedLogic: ParsedLogic, type: Type, expre
|
|
|
15
14
|
let typeNode
|
|
16
15
|
const firstParameter = value.parameters[0]
|
|
17
16
|
if (firstParameter) {
|
|
18
|
-
typeNode =
|
|
17
|
+
typeNode = cloneNodeSorted(
|
|
19
18
|
checker.typeToTypeNode(checker.getTypeAtLocation(firstParameter), undefined, undefined),
|
|
20
19
|
)
|
|
21
20
|
gatherImports(typeNode, checker, parsedLogic)
|