Skip to content

Commit

Permalink
style: use Record, Array type annotation
Browse files Browse the repository at this point in the history
- Record<string, unknown> is default recommended by @typescript-eslint/ban-types.
- Using Array<T> when T is composite data type, and T[] when T is primitive is useful visual cue.
  • Loading branch information
MajorLift committed Nov 30, 2021
1 parent 4eda7be commit ec4d986
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
21 changes: 21 additions & 0 deletions sapling/src/controllers/SaplingParser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let children: Array<ChildInfo> = [];
let ast: ASTNode | Record<string, Array<Token>>;
private getImports(body: Array<ASTNode>): Record<string, ImportData> {
.reduce((accum: Record<string, ImportData>, declaration) => {
private parseImportDeclaration(declaration: ImportDeclaration): Record<string, ImportData> {
const output: Record<string, ImportData> = {};
private parseVariableDeclaration(declaration: VariableDeclaration): Record<string, ImportData> {
const output: Record<string, ImportData> = {};
imports: Record<string, ImportData>,
astToken: Token,
props: Record<string, boolean>,
parent: Tree,
children: Record<string, Tree>
): Record<string, Tree> {
astTokens: Array<Token>,
imports: Record<string, ImportData>,
let childNodes: Record<string, Tree> = {};
let props: Record<string, boolean> = {};
private getJSXProps(astTokens: Array<Token>, j: number): Record<string, boolean> {
const props: Record<string, boolean> = {};
private checkForRedux(astTokens: Array<Token>, imports: Record<string, ImportData>): boolean {
3 changes: 0 additions & 3 deletions sapling/src/types/ImportObj.ts

This file was deleted.

4 changes: 2 additions & 2 deletions sapling/src/types/Tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type Tree = {
thirdParty: boolean;
reactRouter: boolean;
reduxConnect: boolean;
children: Tree[];
children: Array<Tree>;
parentList: string[];
props: { [key: string]: boolean; };
props: Record<string, boolean>;
error: string;
};

0 comments on commit ec4d986

Please sign in to comment.