kea-typegen 1.2.1 → 1.4.1

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +75 -32
  2. package/dist/package.json +18 -17
  3. package/dist/src/__tests__/e2e/actions.js +4 -4
  4. package/dist/src/__tests__/e2e/actions.js.map +1 -1
  5. package/dist/src/__tests__/e2e/connect.js +6 -6
  6. package/dist/src/__tests__/e2e/connect.js.map +1 -1
  7. package/dist/src/__tests__/e2e/loaders.js +3 -3
  8. package/dist/src/__tests__/e2e/loaders.js.map +1 -1
  9. package/dist/src/__tests__/e2e/reducers.js +4 -4
  10. package/dist/src/__tests__/e2e/reducers.js.map +1 -1
  11. package/dist/src/__tests__/e2e/selectors.js +3 -3
  12. package/dist/src/__tests__/e2e/selectors.js.map +1 -1
  13. package/dist/src/__tests__/utils.js +7 -7
  14. package/dist/src/__tests__/utils.js.map +1 -1
  15. package/dist/src/cli/typegen.js +35 -9
  16. package/dist/src/cli/typegen.js.map +1 -1
  17. package/dist/src/print/print.d.ts +5 -5
  18. package/dist/src/print/print.js +70 -44
  19. package/dist/src/print/print.js.map +1 -1
  20. package/dist/src/print/printActionCreators.d.ts +1 -2
  21. package/dist/src/print/printActionCreators.js +7 -7
  22. package/dist/src/print/printActionCreators.js.map +1 -1
  23. package/dist/src/print/printActionKeys.d.ts +1 -2
  24. package/dist/src/print/printActionKeys.js +4 -4
  25. package/dist/src/print/printActionKeys.js.map +1 -1
  26. package/dist/src/print/printActionTypes.d.ts +1 -2
  27. package/dist/src/print/printActionTypes.js +4 -4
  28. package/dist/src/print/printActionTypes.js.map +1 -1
  29. package/dist/src/print/printActions.d.ts +1 -2
  30. package/dist/src/print/printActions.js +4 -4
  31. package/dist/src/print/printActions.js.map +1 -1
  32. package/dist/src/print/printConstants.d.ts +1 -2
  33. package/dist/src/print/printConstants.js +2 -2
  34. package/dist/src/print/printConstants.js.map +1 -1
  35. package/dist/src/print/printDefaults.d.ts +1 -2
  36. package/dist/src/print/printDefaults.js +3 -3
  37. package/dist/src/print/printDefaults.js.map +1 -1
  38. package/dist/src/print/printEvents.d.ts +1 -2
  39. package/dist/src/print/printEvents.js +3 -3
  40. package/dist/src/print/printEvents.js.map +1 -1
  41. package/dist/src/print/printInternalExtraInput.d.ts +1 -2
  42. package/dist/src/print/printInternalExtraInput.js +8 -8
  43. package/dist/src/print/printInternalExtraInput.js.map +1 -1
  44. package/dist/src/print/printInternalReducerActions.d.ts +1 -2
  45. package/dist/src/print/printInternalReducerActions.js +3 -4
  46. package/dist/src/print/printInternalReducerActions.js.map +1 -1
  47. package/dist/src/print/printInternalSelectorTypes.d.ts +1 -2
  48. package/dist/src/print/printInternalSelectorTypes.js +3 -3
  49. package/dist/src/print/printInternalSelectorTypes.js.map +1 -1
  50. package/dist/src/print/printKey.d.ts +1 -2
  51. package/dist/src/print/printKey.js +2 -2
  52. package/dist/src/print/printKey.js.map +1 -1
  53. package/dist/src/print/printListeners.d.ts +1 -2
  54. package/dist/src/print/printListeners.js +9 -9
  55. package/dist/src/print/printListeners.js.map +1 -1
  56. package/dist/src/print/printProps.d.ts +1 -2
  57. package/dist/src/print/printProps.js +6 -5
  58. package/dist/src/print/printProps.js.map +1 -1
  59. package/dist/src/print/printReducer.d.ts +1 -2
  60. package/dist/src/print/printReducer.js +6 -6
  61. package/dist/src/print/printReducer.js.map +1 -1
  62. package/dist/src/print/printReducerOptions.d.ts +1 -2
  63. package/dist/src/print/printReducerOptions.js +3 -3
  64. package/dist/src/print/printReducerOptions.js.map +1 -1
  65. package/dist/src/print/printReducers.d.ts +1 -2
  66. package/dist/src/print/printReducers.js +7 -7
  67. package/dist/src/print/printReducers.js.map +1 -1
  68. package/dist/src/print/printSelector.d.ts +1 -2
  69. package/dist/src/print/printSelector.js +4 -4
  70. package/dist/src/print/printSelector.js.map +1 -1
  71. package/dist/src/print/printSelectors.d.ts +1 -2
  72. package/dist/src/print/printSelectors.js +6 -6
  73. package/dist/src/print/printSelectors.js.map +1 -1
  74. package/dist/src/print/printSharedListeners.d.ts +1 -2
  75. package/dist/src/print/printSharedListeners.js +11 -11
  76. package/dist/src/print/printSharedListeners.js.map +1 -1
  77. package/dist/src/print/printValues.d.ts +1 -2
  78. package/dist/src/print/printValues.js +3 -3
  79. package/dist/src/print/printValues.js.map +1 -1
  80. package/dist/src/typegen.js +5 -5
  81. package/dist/src/typegen.js.map +1 -1
  82. package/dist/src/types.d.ts +6 -0
  83. package/dist/src/utils.js +21 -18
  84. package/dist/src/utils.js.map +1 -1
  85. package/dist/src/visit/__tests__/visit.js +2 -2
  86. package/dist/src/visit/__tests__/visit.js.map +1 -1
  87. package/dist/src/visit/visit.js +22 -14
  88. package/dist/src/visit/visit.js.map +1 -1
  89. package/dist/src/visit/visitActions.d.ts +2 -2
  90. package/dist/src/visit/visitActions.js +13 -11
  91. package/dist/src/visit/visitActions.js.map +1 -1
  92. package/dist/src/visit/visitConnect.js +4 -4
  93. package/dist/src/visit/visitConnect.js.map +1 -1
  94. package/dist/src/visit/visitDefaults.js +1 -1
  95. package/dist/src/visit/visitDefaults.js.map +1 -1
  96. package/dist/src/visit/visitKey.js +2 -2
  97. package/dist/src/visit/visitKey.js.map +1 -1
  98. package/dist/src/visit/visitListeners.js +5 -5
  99. package/dist/src/visit/visitListeners.js.map +1 -1
  100. package/dist/src/visit/visitLoaders.d.ts +2 -2
  101. package/dist/src/visit/visitLoaders.js +27 -29
  102. package/dist/src/visit/visitLoaders.js.map +1 -1
  103. package/dist/src/visit/visitProps.js +1 -1
  104. package/dist/src/visit/visitProps.js.map +1 -1
  105. package/dist/src/visit/visitReducers.js +4 -4
  106. package/dist/src/visit/visitReducers.js.map +1 -1
  107. package/dist/src/visit/visitSelectors.js +8 -8
  108. package/dist/src/visit/visitSelectors.js.map +1 -1
  109. package/dist/src/visit/visitSharedListeners.js +5 -5
  110. package/dist/src/visit/visitSharedListeners.js.map +1 -1
  111. package/dist/src/visit/visitWindowValues.js +1 -1
  112. package/dist/src/visit/visitWindowValues.js.map +1 -1
  113. package/dist/src/write/write.d.ts +4 -0
  114. package/dist/src/{import/writeLogicTypeImports.js → write/write.js} +56 -11
  115. package/dist/src/write/write.js.map +1 -0
  116. package/dist/tsconfig.tsbuildinfo +1 -1
  117. package/form-plugin/lib/form-plugin/src/typegen.js +16 -15
  118. package/form-plugin/lib/src/types.d.ts +4 -1
  119. package/form-plugin/package.json +1 -1
  120. package/form-plugin/src/typegen.ts +25 -25
  121. package/form-plugin/tsconfig.json +0 -1
  122. package/form-plugin/yarn.lock +10 -10
  123. package/package.json +18 -17
  124. package/samples/.kearc +3 -0
  125. package/samples/autoImportLogic.ts +12 -3
  126. package/samples/autoImportLogicType.ts +7 -2
  127. package/samples/complexLogic.ts +4 -3
  128. package/samples/donotimport.ts +1 -0
  129. package/samples/githubConnectLogic.ts +1 -0
  130. package/samples/githubImportLogic.ts +1 -0
  131. package/samples/githubLogic.ts +1 -0
  132. package/samples/loadersLogic.ts +1 -0
  133. package/samples/loadersLogicType.ts +9 -9
  134. package/samples/logicType.ts +4 -4
  135. package/samples/pluginLogic.ts +2 -0
  136. package/samples/propsLogic.ts +1 -0
  137. package/samples/propsLogicType.ts +9 -9
  138. package/samples/windowValuesLogic.ts +1 -0
  139. package/src/__tests__/e2e/__snapshots__/loaders.ts.snap +10 -10
  140. package/src/__tests__/utils.ts +5 -5
  141. package/src/cli/typegen.ts +33 -7
  142. package/src/print/print.ts +97 -37
  143. package/src/print/printActionCreators.ts +12 -15
  144. package/src/print/printActionKeys.ts +5 -6
  145. package/src/print/printActionTypes.ts +6 -7
  146. package/src/print/printActions.ts +6 -13
  147. package/src/print/printConstants.ts +5 -6
  148. package/src/print/printDefaults.ts +5 -6
  149. package/src/print/printEvents.ts +8 -6
  150. package/src/print/printInternalExtraInput.ts +12 -13
  151. package/src/print/printInternalReducerActions.ts +5 -12
  152. package/src/print/printInternalSelectorTypes.ts +7 -8
  153. package/src/print/printKey.ts +2 -2
  154. package/src/print/printListeners.ts +16 -17
  155. package/src/print/printProps.ts +7 -7
  156. package/src/print/printReducer.ts +14 -15
  157. package/src/print/printReducerOptions.ts +4 -5
  158. package/src/print/printReducers.ts +13 -14
  159. package/src/print/printSelector.ts +8 -9
  160. package/src/print/printSelectors.ts +12 -13
  161. package/src/print/printSharedListeners.ts +20 -21
  162. package/src/print/printValues.ts +5 -6
  163. package/src/typegen.ts +4 -4
  164. package/src/types.ts +11 -1
  165. package/src/utils.ts +17 -17
  166. package/src/visit/visit.ts +11 -3
  167. package/src/visit/visitActions.ts +12 -10
  168. package/src/visit/visitListeners.ts +8 -8
  169. package/src/visit/visitLoaders.ts +49 -45
  170. package/src/visit/visitReducers.ts +1 -1
  171. package/src/visit/visitSelectors.ts +3 -3
  172. package/src/visit/visitSharedListeners.ts +8 -10
  173. package/src/{import/writeLogicTypeImports.ts → write/write.ts} +115 -16
  174. package/dist/src/import/writeLogicTypeImports.d.ts +0 -3
  175. package/dist/src/import/writeLogicTypeImports.js.map +0 -1
@@ -10,7 +10,6 @@
10
10
  "outDir": "./lib",
11
11
  "baseUrl": "./src",
12
12
  "incremental": true,
13
- "types": ["jest", "node"],
14
13
  "esModuleInterop": true,
15
14
  "resolveJsonModule": true,
16
15
  "jsx": "react"
@@ -127,11 +127,11 @@ is-fullwidth-code-point@^3.0.0:
127
127
  integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
128
128
 
129
129
  "kea-typegen@file:..":
130
- version "1.0.4"
130
+ version "1.3.0"
131
131
  dependencies:
132
132
  "@wessberg/ts-clone-node" "0.3.19"
133
133
  diff "^5.0.0"
134
- prettier "^2.3.1"
134
+ prettier "^2.5.1"
135
135
  yargs "^16.2.0"
136
136
 
137
137
  kea@^2.4.5:
@@ -151,10 +151,10 @@ object-assign@^4.1.1:
151
151
  resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
152
152
  integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
153
153
 
154
- prettier@^2.3.1:
155
- version "2.3.2"
156
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
157
- integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
154
+ prettier@^2.5.1:
155
+ version "2.5.1"
156
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
157
+ integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
158
158
 
159
159
  prop-types@^15.7.2:
160
160
  version "15.7.2"
@@ -228,10 +228,10 @@ strip-ansi@^6.0.0:
228
228
  dependencies:
229
229
  ansi-regex "^5.0.0"
230
230
 
231
- typescript@^4.3.5:
232
- version "4.3.5"
233
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
234
- integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
231
+ typescript@^4.5.3:
232
+ version "4.5.3"
233
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c"
234
+ integrity sha512-eVYaEHALSt+s9LbvgEv4Ef+Tdq7hBiIZgii12xXJnukryt3pMgJf6aKhoCZ3FWQsu6sydEnkg11fYXLzhLBjeQ==
235
235
 
236
236
  wrap-ansi@^7.0.0:
237
237
  version "7.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kea-typegen",
3
- "version": "1.2.1",
3
+ "version": "1.4.1",
4
4
  "description": "Generate type definitions for kea logic",
5
5
  "scripts": {
6
6
  "start": "ts-node ./src/cli/typegen.ts",
@@ -9,11 +9,12 @@
9
9
  "prepublishOnly": "npm run test && npm run clean && npm run build",
10
10
  "run-built-cli": "node dist/src/cli/typegen.js",
11
11
  "test": "jest",
12
- "samples:check": "ts-node ./src/cli/typegen.ts check -c ./samples/tsconfig.json",
13
- "samples:write": "ts-node ./src/cli/typegen.ts write -c ./samples/tsconfig.json",
14
- "samples:watch": "ts-node ./src/cli/typegen.ts watch -c ./samples/tsconfig.json",
12
+ "samples:check": "ts-node ./src/cli/typegen.ts check -r ./samples",
13
+ "samples:write": "ts-node ./src/cli/typegen.ts write -r ./samples --write-paths",
14
+ "samples:write:paths": "ts-node ./src/cli/typegen.ts write -r ./samples --write-paths",
15
+ "samples:watch": "ts-node ./src/cli/typegen.ts watch -r ./samples",
15
16
  "samples:write:posthog": "ts-node ./src/cli/typegen.ts write -c ../../PostHog/posthog/tsconfig.json",
16
- "form-plugin:build": "cd form-plugin && yarn build && cd ..",
17
+ "form-plugin:build": "cd form-plugin && yarn && yarn build && cd ..",
17
18
  "form-plugin:rebuild": "yarn form-plugin:build && rm -rf node_modules && yarn"
18
19
  },
19
20
  "main": "dist/src/index.js",
@@ -25,13 +26,13 @@
25
26
  "dependencies": {
26
27
  "@wessberg/ts-clone-node": "0.3.19",
27
28
  "diff": "^5.0.0",
28
- "prettier": "^2.3.1",
29
+ "prettier": "^2.5.1",
29
30
  "yargs": "^16.2.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@babel/core": "^7.13.1",
33
- "@babel/preset-env": "^7.13.5",
34
- "@babel/preset-typescript": "^7.13.0",
33
+ "@babel/core": "^7.16.0",
34
+ "@babel/preset-env": "^7.16.4",
35
+ "@babel/preset-typescript": "^7.16.0",
35
36
  "@types/jest": "^26.0.20",
36
37
  "@types/node": "^14.14.31",
37
38
  "@types/yargs": "^16.0.0",
@@ -40,19 +41,19 @@
40
41
  "form-plugin": "file:./form-plugin",
41
42
  "husky": ">=4",
42
43
  "jest": "^27.0.5",
43
- "kea": "^2.4.6",
44
- "lint-staged": ">=10.5.4",
44
+ "kea": "^2.5.6",
45
+ "lint-staged": ">=12.1.2",
45
46
  "react": "^16.13.1",
46
- "react-redux": "^7.2.4",
47
- "redux": "^4.1.0",
48
- "reselect": "^4.0.0",
47
+ "react-redux": "^7.2.6",
48
+ "redux": "^4.1.2",
49
+ "reselect": "^4.1.5",
49
50
  "rimraf": "^3.0.2",
50
51
  "ts-jest": "^27.0.3",
51
- "ts-node": "^10.0.0",
52
- "typescript": "^4.3.4"
52
+ "ts-node": "^10.4.0",
53
+ "typescript": "^4.5.3"
53
54
  },
54
55
  "peerDependencies": {
55
- "typescript": "*"
56
+ "typescript": ">=4.5.3"
56
57
  },
57
58
  "jest": {
58
59
  "testPathIgnorePatterns": [
package/samples/.kearc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "ignoreImportPaths": ["./donotimport.ts"]
3
+ }
@@ -1,9 +1,10 @@
1
1
  import { kea, KeaPlugin } from 'kea'
2
2
 
3
- import { autoImportLogicType } from './autoImportLogicType'
4
3
  import { A1, A2, A3, A4, A5, A7, D1, D3, D6, EventIndex, ExportedApi, R1, R6, S6 } from './autoImportTypes'
5
4
  import { githubLogic } from './githubLogic'
6
5
  import { loadersLogic } from './loadersLogic'
6
+ import { Bla } from './donotimport'
7
+ import type { autoImportLogicType } from './autoImportLogicType'
7
8
 
8
9
  type L1 = 'haha'
9
10
  type L2 = {
@@ -12,6 +13,7 @@ type L2 = {
12
13
  interface RandomAPI extends ExportedApi.RandomThing {}
13
14
 
14
15
  export const autoImportLogic = kea<autoImportLogicType<L1, L2, RandomAPI>>({
16
+ path: ['autoImportLogic'],
15
17
  props: {} as {
16
18
  asd: D3
17
19
  },
@@ -40,10 +42,16 @@ export const autoImportLogic = kea<autoImportLogicType<L1, L2, RandomAPI>>({
40
42
  complexAction: (element: HTMLElement, timeout: NodeJS.Timeout) => ({ element, timeout }),
41
43
  combinedA6Action: (filter: A5) => ({ a6: filter.a6, bla: filter.bla }),
42
44
  valueAction: [] as A7,
43
- miscActionWithType: (randomThing: ExportedApi.RandomThing): { randomThing: ExportedApi.RandomThing } => ({
45
+ miscActionWithType: (
46
+ randomThing: ExportedApi.RandomThing,
47
+ ): {
48
+ randomThing: ExportedApi.RandomThing
49
+ } => ({
44
50
  randomThing,
45
51
  }),
46
- miscActionWithTypeConstants: (): { color: 'green' | 'blue' } => ({
52
+ miscActionWithTypeConstants: (): {
53
+ color: 'green' | 'blue'
54
+ } => ({
47
55
  color: 'blue',
48
56
  }),
49
57
  miscActionWithoutType: (randomThing: ExportedApi.RandomThing) => ({ randomThing }),
@@ -56,6 +64,7 @@ export const autoImportLogic = kea<autoImportLogicType<L1, L2, RandomAPI>>({
56
64
  defaults: {
57
65
  bla: { bla: 'asd' } as D1,
58
66
  asd: {} as D6,
67
+ notimported: {} as Bla,
59
68
  },
60
69
  reducers: {
61
70
  rbla: [{ bla: 'asd' } as R1, {}],
@@ -1,11 +1,10 @@
1
- // Generated by kea-typegen on Sun, 11 Jul 2021 22:15:52 GMT. DO NOT EDIT THIS FILE MANUALLY.
1
+ // Generated by kea-typegen on Sun, 12 Dec 2021 13:31:25 GMT. DO NOT EDIT THIS FILE MANUALLY.
2
2
 
3
3
  import { Logic } from 'kea'
4
4
 
5
5
  import { A1, A2, A3, A4, A5, A7, D1, D3, D6, EventIndex, ExportedApi, R1, R6, RandomThing, S6, S7 } from './autoImportTypes'
6
6
  import { KeaPlugin } from '../node_modules/kea/lib/index.d'
7
7
  import { HTMLElement } from '../node_modules/@types/react/global.d'
8
- import { NodeJS, Timeout } from '../node_modules/@types/node/globals.d'
9
8
  import { Dashboard, Repository } from './types'
10
9
 
11
10
  export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
@@ -135,6 +134,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
135
134
  defaults: {
136
135
  bla: D1
137
136
  asd: D6
137
+ notimported: Bla
138
138
  rbla: R1
139
139
  rasd: R6
140
140
  then: null | ExportedApi.RandomThing
@@ -154,6 +154,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
154
154
  ) => {
155
155
  bla: D1
156
156
  asd: D6
157
+ notimported: Bla
157
158
  rbla: R1
158
159
  rasd: R6
159
160
  then: null | ExportedApi.RandomThing
@@ -162,6 +163,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
162
163
  reducers: {
163
164
  bla: (state: D1, action: any, fullState: any) => D1
164
165
  asd: (state: D6, action: any, fullState: any) => D6
166
+ notimported: (state: Bla, action: any, fullState: any) => Bla
165
167
  rbla: (state: R1, action: any, fullState: any) => R1
166
168
  rasd: (state: R6, action: any, fullState: any) => R6
167
169
  then: (state: null | ExportedApi.RandomThing, action: any, fullState: any) => null | ExportedApi.RandomThing
@@ -169,6 +171,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
169
171
  selector: (state: any) => {
170
172
  bla: D1
171
173
  asd: D6
174
+ notimported: Bla
172
175
  rbla: R1
173
176
  rasd: R6
174
177
  then: null | ExportedApi.RandomThing
@@ -176,6 +179,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
176
179
  selectors: {
177
180
  bla: (state: any, props?: any) => D1
178
181
  asd: (state: any, props?: any) => D6
182
+ notimported: (state: any, props?: any) => Bla
179
183
  rbla: (state: any, props?: any) => R1
180
184
  rasd: (state: any, props?: any) => R6
181
185
  then: (state: any, props?: any) => null | ExportedApi.RandomThing
@@ -191,6 +195,7 @@ export interface autoImportLogicType<L1, L2, RandomAPI> extends Logic {
191
195
  values: {
192
196
  bla: D1
193
197
  asd: D6
198
+ notimported: Bla
194
199
  rbla: R1
195
200
  rasd: R6
196
201
  then: null | ExportedApi.RandomThing
@@ -45,8 +45,9 @@ function newAction(element: HTMLElement | null): Partial<ActionType> {
45
45
  export const complexLogic = kea<
46
46
  complexLogicType<ActionForm, ActionType, AntdFieldData, DashboardItemType, FormInstance>
47
47
  >({
48
+ path: ['complexLogic'],
48
49
  props: {} as AntdFieldData,
49
-
50
+
50
51
  actions: {
51
52
  setForm: (form: FormInstance) => ({ form }),
52
53
  selectAction: (id: string | null) => ({ id: id || null }),
@@ -155,8 +156,8 @@ export const complexLogic = kea<
155
156
  const a = {} as DashboardItemType
156
157
  const result = { ...a, bla: true }
157
158
  return result
158
- }
159
- ]
159
+ },
160
+ ],
160
161
  },
161
162
 
162
163
  listeners: ({ actions, values }) => ({
@@ -0,0 +1 @@
1
+ export type Bla = 123
@@ -4,6 +4,7 @@ import { githubLogic } from './githubLogic'
4
4
  import { githubConnectLogicType } from './githubConnectLogicType'
5
5
 
6
6
  export const githubConnectLogic = kea<githubConnectLogicType>({
7
+ path: ['githubConnectLogic'],
7
8
  connect: {
8
9
  values: [githubLogic, ['repositories', 'this-one-does-not-exist'], githubLogic(), ['isLoading']],
9
10
  actions: [githubLogic, ['setRepositories', 'will-not-be-imported']],
@@ -5,6 +5,7 @@ import { githubImportLogicType } from './githubImportLogicType'
5
5
  import { Repository } from './types'
6
6
 
7
7
  export const githubImportLogic = kea<githubImportLogicType>({
8
+ path: ['githubImportLogic'],
8
9
  reducers: () => ({
9
10
  repositoryReducerCopy: [
10
11
  [] as Repository[],
@@ -5,6 +5,7 @@ import { Repository } from './types'
5
5
  const API_URL = 'https://api.github.com'
6
6
 
7
7
  export const githubLogic = kea<githubLogicType>({
8
+ path: ['githubLogic'],
8
9
  actions: {
9
10
  setUsername: (username: string) => ({ username }),
10
11
  setRepositories: (repositories: Repository[]) => ({ repositories }),
@@ -4,6 +4,7 @@ import { loadersLogicType } from './loadersLogicType'
4
4
  import { Dashboard } from './types'
5
5
 
6
6
  export const loadersLogic = kea<loadersLogicType>({
7
+ path: ['loadersLogic'],
7
8
  actions: {
8
9
  addDashboard: (name: string) => ({ name }),
9
10
  },
@@ -1,4 +1,4 @@
1
- // Generated by kea-typegen on Thu, 14 Oct 2021 12:25:24 GMT. DO NOT EDIT THIS FILE MANUALLY.
1
+ // Generated by kea-typegen on Thu, 14 Oct 2021 12:36:17 GMT. DO NOT EDIT THIS FILE MANUALLY.
2
2
 
3
3
  import { Logic } from 'kea'
4
4
 
@@ -14,14 +14,14 @@ export interface loadersLogicType extends Logic {
14
14
  }
15
15
  addDashboardSuccess: (
16
16
  dashboard: Dashboard,
17
- payload: {
17
+ payload?: {
18
18
  name: string
19
19
  },
20
20
  ) => {
21
21
  type: 'add dashboard success (loadersLogic)'
22
22
  payload: {
23
23
  dashboard: Dashboard
24
- payload: {
24
+ payload?: {
25
25
  name: string
26
26
  }
27
27
  }
@@ -44,14 +44,14 @@ export interface loadersLogicType extends Logic {
44
44
  }
45
45
  addDashboardNoTypeSuccess: (
46
46
  dashboard: Dashboard,
47
- payload: {
47
+ payload?: {
48
48
  name: string
49
49
  },
50
50
  ) => {
51
51
  type: 'add dashboard no type success (loadersLogic)'
52
52
  payload: {
53
53
  dashboard: Dashboard
54
- payload: {
54
+ payload?: {
55
55
  name: string
56
56
  }
57
57
  }
@@ -72,7 +72,7 @@ export interface loadersLogicType extends Logic {
72
72
  }
73
73
  loadItSuccess: (
74
74
  misc: { id: number; name: void; pinned: boolean },
75
- payload: any,
75
+ payload?: any,
76
76
  ) => {
77
77
  type: 'load it success (loadersLogic)'
78
78
  payload: {
@@ -117,7 +117,7 @@ export interface loadersLogicType extends Logic {
117
117
  addDashboard: (name: string) => void
118
118
  addDashboardSuccess: (
119
119
  dashboard: Dashboard,
120
- payload: {
120
+ payload?: {
121
121
  name: string
122
122
  },
123
123
  ) => void
@@ -125,13 +125,13 @@ export interface loadersLogicType extends Logic {
125
125
  addDashboardNoType: ({ name }: { name: string }) => void
126
126
  addDashboardNoTypeSuccess: (
127
127
  dashboard: Dashboard,
128
- payload: {
128
+ payload?: {
129
129
  name: string
130
130
  },
131
131
  ) => void
132
132
  addDashboardNoTypeFailure: (error: string, errorObject?: any) => void
133
133
  loadIt: () => void
134
- loadItSuccess: (misc: { id: number; name: void; pinned: boolean }, payload: any) => void
134
+ loadItSuccess: (misc: { id: number; name: void; pinned: boolean }, payload?: any) => void
135
135
  loadItFailure: (error: string, errorObject?: any) => void
136
136
  }
137
137
  constants: {}
@@ -1,4 +1,4 @@
1
- // Generated by kea-typegen on Thu, 14 Oct 2021 12:09:15 GMT. DO NOT EDIT THIS FILE MANUALLY.
1
+ // Generated by kea-typegen on Thu, 14 Oct 2021 12:36:17 GMT. DO NOT EDIT THIS FILE MANUALLY.
2
2
 
3
3
  import { Logic, BreakPointFunction } from 'kea'
4
4
 
@@ -28,12 +28,12 @@ export interface logicType<Session> extends Logic {
28
28
  }
29
29
  loadSessionsSuccess: (
30
30
  sessions: Session[],
31
- payload: string,
31
+ payload?: string,
32
32
  ) => {
33
33
  type: 'load sessions success (scenes.homepage.index.*)'
34
34
  payload: {
35
35
  sessions: Session[]
36
- payload: string
36
+ payload?: string
37
37
  }
38
38
  }
39
39
  loadSessionsFailure: (
@@ -68,7 +68,7 @@ export interface logicType<Session> extends Logic {
68
68
  updateConst: (name: 'John' | 'Bill') => void
69
69
  updateNumber: (number: number) => void
70
70
  loadSessions: (selectedDate: string) => void
71
- loadSessionsSuccess: (sessions: Session[], payload: string) => void
71
+ loadSessionsSuccess: (sessions: Session[], payload?: string) => void
72
72
  loadSessionsFailure: (error: string, errorObject?: any) => void
73
73
  }
74
74
  constants: {
@@ -4,6 +4,7 @@ import { inlinePlugin } from './inline-plugin'
4
4
  import { pluginLogicType, anotherPluginLogicType } from './pluginLogicType'
5
5
 
6
6
  export const pluginLogic = kea<pluginLogicType>({
7
+ path: ['pluginLogic'],
7
8
  inline: { bla: true },
8
9
 
9
10
  form: {
@@ -19,6 +20,7 @@ export const pluginLogic = kea<pluginLogicType>({
19
20
  })
20
21
 
21
22
  export const anotherPluginLogic = kea<anotherPluginLogicType>({
23
+ path: ['pluginLogic'],
22
24
  form: ({ values }) => ({
23
25
  default: {
24
26
  name: 'john',
@@ -2,6 +2,7 @@ import { kea } from 'kea'
2
2
  import { propsLogicType } from './propsLogicType'
3
3
 
4
4
  const propsLogic = kea<propsLogicType>({
5
+ path: (key) => ['propsLogic', key],
5
6
  props: {
6
7
  /* TODO for 3.0: set default props here */
7
8
  } as {
@@ -1,29 +1,29 @@
1
- // Generated by kea-typegen on Wed, 23 Jun 2021 09:53:33 GMT. DO NOT EDIT THIS FILE MANUALLY.
1
+ // Generated by kea-typegen on Sun, 12 Dec 2021 13:38:14 GMT. DO NOT EDIT THIS FILE MANUALLY.
2
2
 
3
3
  import { Logic } from 'kea'
4
4
 
5
5
  export interface propsLogicType extends Logic {
6
6
  actionCreators: {
7
7
  setPage: (page: string) => {
8
- type: 'set page (propsLogic)'
8
+ type: 'set page (propsLogic.*)'
9
9
  payload: {
10
10
  page: string
11
11
  }
12
12
  }
13
13
  setId: (id: number) => {
14
- type: 'set id (propsLogic)'
14
+ type: 'set id (propsLogic.*)'
15
15
  payload: {
16
16
  id: number
17
17
  }
18
18
  }
19
19
  }
20
20
  actionKeys: {
21
- 'set page (propsLogic)': 'setPage'
22
- 'set id (propsLogic)': 'setId'
21
+ 'set page (propsLogic.*)': 'setPage'
22
+ 'set id (propsLogic.*)': 'setId'
23
23
  }
24
24
  actionTypes: {
25
- setPage: 'set page (propsLogic)'
26
- setId: 'set id (propsLogic)'
25
+ setPage: 'set page (propsLogic.*)'
26
+ setId: 'set id (propsLogic.*)'
27
27
  }
28
28
  actions: {
29
29
  setPage: (page: string) => void
@@ -36,8 +36,8 @@ export interface propsLogicType extends Logic {
36
36
  events: {}
37
37
  key: number
38
38
  listeners: {}
39
- path: ['propsLogic']
40
- pathString: 'propsLogic'
39
+ path: ['propsLogic', '*']
40
+ pathString: 'propsLogic.*'
41
41
  props: {
42
42
  page: string
43
43
  id: number
@@ -1,6 +1,7 @@
1
1
  import { kea } from 'kea'
2
2
  import { windowValuesLogicType } from './windowValuesLogicType'
3
3
  export const windowValuesLogic = kea<windowValuesLogicType>({
4
+ path: ['windowValuesLogic'],
4
5
  windowValues: () => ({
5
6
  windowHeight: (window) => window.innerHeight,
6
7
  windowWidth: (window) => Math.min(window.innerWidth, window.document.body.clientWidth),
@@ -13,11 +13,11 @@ exports[`loaders - with a function 1`] = `
13
13
  type: \\"load sessions (logic)\\";
14
14
  payload: string;
15
15
  });
16
- loadSessionsSuccess: (sessions: Session[], payload: string) => ({
16
+ loadSessionsSuccess: (sessions: Session[], payload?: string) => ({
17
17
  type: \\"load sessions success (logic)\\";
18
18
  payload: {
19
19
  sessions: Session[];
20
- payload: string;
20
+ payload?: string;
21
21
  };
22
22
  });
23
23
  loadSessionsFailure: (error: string, errorObject?: any) => ({
@@ -43,7 +43,7 @@ exports[`loaders - with a function 1`] = `
43
43
  actions: {
44
44
  updateName: (name: string) => void;
45
45
  loadSessions: (query: string) => void;
46
- loadSessionsSuccess: (sessions: Session[], payload: string) => void;
46
+ loadSessionsSuccess: (sessions: Session[], payload?: string) => void;
47
47
  loadSessionsFailure: (error: string, errorObject?: any) => void;
48
48
  };
49
49
  constants: {};
@@ -99,11 +99,11 @@ exports[`loaders - with an array and default 1`] = `
99
99
  type: \\"load sessions (logic)\\";
100
100
  payload: string;
101
101
  });
102
- loadSessionsSuccess: (sessions: Session[], payload: string) => ({
102
+ loadSessionsSuccess: (sessions: Session[], payload?: string) => ({
103
103
  type: \\"load sessions success (logic)\\";
104
104
  payload: {
105
105
  sessions: Session[];
106
- payload: string;
106
+ payload?: string;
107
107
  };
108
108
  });
109
109
  loadSessionsFailure: (error: string, errorObject?: any) => ({
@@ -129,7 +129,7 @@ exports[`loaders - with an array and default 1`] = `
129
129
  actions: {
130
130
  updateName: (name: string) => void;
131
131
  loadSessions: (query: string) => void;
132
- loadSessionsSuccess: (sessions: Session[], payload: string) => void;
132
+ loadSessionsSuccess: (sessions: Session[], payload?: string) => void;
133
133
  loadSessionsFailure: (error: string, errorObject?: any) => void;
134
134
  };
135
135
  constants: {};
@@ -179,7 +179,7 @@ exports[`loaders - with no param 1`] = `
179
179
  type: \\"load sessions (logic)\\";
180
180
  payload: any;
181
181
  });
182
- loadSessionsSuccess: (sessions: string[], payload: any) => ({
182
+ loadSessionsSuccess: (sessions: string[], payload?: any) => ({
183
183
  type: \\"load sessions success (logic)\\";
184
184
  payload: {
185
185
  sessions: string[];
@@ -197,7 +197,7 @@ exports[`loaders - with no param 1`] = `
197
197
  type: \\"load results (logic)\\";
198
198
  payload: any;
199
199
  });
200
- loadResultsSuccess: (sessions: string[], payload: any) => ({
200
+ loadResultsSuccess: (sessions: string[], payload?: any) => ({
201
201
  type: \\"load results success (logic)\\";
202
202
  payload: {
203
203
  sessions: string[];
@@ -230,10 +230,10 @@ exports[`loaders - with no param 1`] = `
230
230
  };
231
231
  actions: {
232
232
  loadSessions: () => void;
233
- loadSessionsSuccess: (sessions: string[], payload: any) => void;
233
+ loadSessionsSuccess: (sessions: string[], payload?: any) => void;
234
234
  loadSessionsFailure: (error: string, errorObject?: any) => void;
235
235
  loadResults: () => void;
236
- loadResultsSuccess: (sessions: string[], payload: any) => void;
236
+ loadResultsSuccess: (sessions: string[], payload?: any) => void;
237
237
  loadResultsFailure: (error: string, errorObject?: any) => void;
238
238
  };
239
239
  constants: {};
@@ -1,16 +1,16 @@
1
1
  import { sourceToSourceFile, programFromSource, logicSourceToLogicType } from '../utils'
2
- import * as ts from 'typescript'
2
+ import { SyntaxKind } from 'typescript'
3
3
 
4
4
  test('sourceToSourceFile', () => {
5
5
  const source = 'var foo = 5;'
6
- const sourceFile1 = sourceToSourceFile(source, )
6
+ const sourceFile1 = sourceToSourceFile(source)
7
7
  const sourceFile2 = sourceToSourceFile(source, 'otherLogic.ts')
8
8
  expect(sourceFile1.text).toEqual(source)
9
9
  expect(sourceFile2.text).toEqual(source)
10
10
  expect(sourceFile1.fileName).toEqual('logic.ts')
11
11
  expect(sourceFile2.fileName).toEqual('otherLogic.ts')
12
- expect(ts.SyntaxKind[sourceFile1.kind]).toEqual('SourceFile')
13
- expect(ts.SyntaxKind[sourceFile2.kind]).toEqual('SourceFile')
12
+ expect(SyntaxKind[sourceFile1.kind]).toEqual('SourceFile')
13
+ expect(SyntaxKind[sourceFile2.kind]).toEqual('SourceFile')
14
14
  })
15
15
 
16
16
  test('programFromSource', () => {
@@ -34,4 +34,4 @@ test('logicSourceToLogicType', () => {
34
34
  const string = logicSourceToLogicType(logicSource)
35
35
 
36
36
  expect(string).toContain('export interface myRandomLogicType extends Logic {')
37
- })
37
+ })