-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from pvasek/AST_manipulation_refactoring
Big refactoring with following goals
- Loading branch information
Showing
19 changed files
with
1,438 additions
and
2,955 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
examples/react-styleguidist-example/components/HocComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
|
||
/** | ||
* Row properties. | ||
*/ | ||
export interface IRowProps { | ||
/** prop1 description */ | ||
prop1?: string; | ||
/** prop2 description */ | ||
prop2: number; | ||
/** | ||
* prop3 description | ||
*/ | ||
prop3: () => void; | ||
/** prop4 description */ | ||
prop4: 'option1' | 'option2' | "option3"; | ||
} | ||
|
||
/** | ||
* Form row. | ||
*/ | ||
class Component extends React.Component<IRowProps, {}> { | ||
|
||
render() { | ||
return <div>Test</div>; | ||
} | ||
}; | ||
|
||
export function hoc<T>(Component: T): T { | ||
// do whatever you need but return the same type T | ||
return Component as T; | ||
} | ||
|
||
/** This example shows HocComponent */ | ||
export const HocComponent = hoc(Component); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import * as sourceMapSupport from "source-map-support"; | ||
sourceMapSupport.install(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as React from 'react'; | ||
/** | ||
* Column properties. | ||
*/ | ||
export interface IColumnProps extends React.HTMLAttributes<any> { | ||
/** prop1 description */ | ||
prop1?: string; | ||
/** prop2 description */ | ||
prop2: number; | ||
/** | ||
* prop3 description | ||
*/ | ||
prop3: () => void; | ||
/** prop4 description */ | ||
prop4: 'option1' | 'option2' | "option3"; | ||
} | ||
|
||
/** | ||
* Form column. | ||
*/ | ||
class Column extends React.Component<IColumnProps, {}> { | ||
public static defaultProps: Partial<IColumnProps> = { | ||
prop1: 'prop1' | ||
}; | ||
|
||
render() { | ||
const {prop1} = this.props; | ||
return <div>{prop1}</div>; | ||
} | ||
} | ||
|
||
/** | ||
* Row properties. | ||
*/ | ||
export interface IRowProps { | ||
/** prop1 description */ | ||
prop1?: string; | ||
/** prop2 description */ | ||
prop2: number; | ||
/** | ||
* prop3 description | ||
*/ | ||
prop3: () => void; | ||
/** prop4 description */ | ||
prop4: 'option1' | 'option2' | "option3"; | ||
} | ||
|
||
/** | ||
* Form row. | ||
*/ | ||
const Row = (props: IRowProps) => { | ||
const innerFunc = (props: IRowProps) => { | ||
return <span>Inner Func</span> | ||
}; | ||
const innerNonExportedFunc = (props: IRowProps) => { | ||
return <span>Inner Func</span> | ||
}; | ||
return <div>Test</div>; | ||
}; | ||
|
||
function hoc<T>(C: T): T { | ||
return ((props) => <div>{C}</div>) as any as T; | ||
} | ||
|
||
/** ColumnHighOrderComponent1 specific comment */ | ||
export const ColumnHighOrderComponent1 = hoc(Column); | ||
|
||
export const ColumnHighOrderComponent2 = hoc(Column); | ||
|
||
/** RowHighOrderComponent1 specific comment */ | ||
export const RowHighOrderComponent1 = hoc(Row); | ||
|
||
export const RowHighOrderComponent2 = hoc(Row); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const unexportedVar = 10; | ||
export const exportedVar = 10; | ||
|
||
/** unexportedVarFunction comment */ | ||
const unexportedVarFunction = (param1: string): number => 0 | ||
; | ||
/** exportedVarFunction comment */ | ||
export const exportedVarFunction = (param1: number, param2: string): string => ""; | ||
|
||
function unexportedFunction(param1: number): string { | ||
return ""; | ||
} | ||
|
||
function exportedFunction(param1: string, param2: number): number { | ||
return 0; | ||
} | ||
|
||
interface UnexportedInterface { | ||
/** prop1 comment */ | ||
prop1: string; | ||
} | ||
|
||
export interface ExportedInterface { | ||
/** prop1 comment */ | ||
prop1: string; | ||
/** prop2 comment */ | ||
prop2: string; | ||
} | ||
|
||
export class OurBaseClass<T1, T2> { | ||
} | ||
|
||
/** UnexportedClass comment */ | ||
class UnexportedClass extends OurBaseClass<ExportedInterface, {}> { | ||
method1(): string { | ||
return ""; | ||
} | ||
} | ||
|
||
/** ExportedClass comment */ | ||
export class ExportedClass { | ||
method1(): string { | ||
return ""; | ||
} | ||
method2(): number { | ||
return 0; | ||
} | ||
} | ||
|
||
export function hoc<T>(component: T): T { | ||
return component; | ||
} | ||
|
||
/** exportedHoc comment */ | ||
export const exportedHoc = hoc(ExportedClass); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.