From ec4d98634d4309b8a24fc02ba6bd5bebdf83b901 Mon Sep 17 00:00:00 2001 From: Jongsun Suh <34228073+MajorLift@users.noreply.github.com> Date: Tue, 30 Nov 2021 03:06:26 -0800 Subject: [PATCH] style: use Record, Array type annotation - Record is default recommended by @typescript-eslint/ban-types. - Using Array when T is composite data type, and T[] when T is primitive is useful visual cue. --- sapling/src/controllers/SaplingParser.ts | 21 +++++++++++++++++++++ sapling/src/types/ImportObj.ts | 3 --- sapling/src/types/Tree.ts | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 sapling/src/controllers/SaplingParser.ts delete mode 100644 sapling/src/types/ImportObj.ts diff --git a/sapling/src/controllers/SaplingParser.ts b/sapling/src/controllers/SaplingParser.ts new file mode 100644 index 0000000..2e23e24 --- /dev/null +++ b/sapling/src/controllers/SaplingParser.ts @@ -0,0 +1,21 @@ + let children: Array = []; + let ast: ASTNode | Record>; + private getImports(body: Array): Record { + .reduce((accum: Record, declaration) => { + private parseImportDeclaration(declaration: ImportDeclaration): Record { + const output: Record = {}; + private parseVariableDeclaration(declaration: VariableDeclaration): Record { + const output: Record = {}; + imports: Record, + astToken: Token, + props: Record, + parent: Tree, + children: Record + ): Record { + astTokens: Array, + imports: Record, + let childNodes: Record = {}; + let props: Record = {}; + private getJSXProps(astTokens: Array, j: number): Record { + const props: Record = {}; + private checkForRedux(astTokens: Array, imports: Record): boolean { diff --git a/sapling/src/types/ImportObj.ts b/sapling/src/types/ImportObj.ts deleted file mode 100644 index a67a46f..0000000 --- a/sapling/src/types/ImportObj.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type ImportObj = { - [key: string]: { importPath: string; importName: string; }; -}; diff --git a/sapling/src/types/Tree.ts b/sapling/src/types/Tree.ts index 4293a84..177e9ed 100644 --- a/sapling/src/types/Tree.ts +++ b/sapling/src/types/Tree.ts @@ -12,8 +12,8 @@ export type Tree = { thirdParty: boolean; reactRouter: boolean; reduxConnect: boolean; - children: Tree[]; + children: Array; parentList: string[]; - props: { [key: string]: boolean; }; + props: Record; error: string; };