diff options
Diffstat (limited to 'packages/react-docs/src')
-rw-r--r-- | packages/react-docs/src/components/badge.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/custom_enum.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/documentation.tsx | 18 | ||||
-rw-r--r-- | packages/react-docs/src/components/enum.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/event_definition.tsx | 6 | ||||
-rw-r--r-- | packages/react-docs/src/components/interface.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/signature.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/signature_block.tsx | 8 | ||||
-rw-r--r-- | packages/react-docs/src/components/source_link.tsx | 4 | ||||
-rw-r--r-- | packages/react-docs/src/components/type_definition.tsx | 8 | ||||
-rw-r--r-- | packages/react-docs/src/docs_info.ts | 5 | ||||
-rw-r--r-- | packages/react-docs/src/utils/doxity_utils.ts | 4 | ||||
-rw-r--r-- | packages/react-docs/src/utils/typedoc_utils.ts | 2 | ||||
-rw-r--r-- | packages/react-docs/src/utils/utils.ts | 2 |
14 files changed, 39 insertions, 38 deletions
diff --git a/packages/react-docs/src/components/badge.tsx b/packages/react-docs/src/components/badge.tsx index b342f2dca..0137b153b 100644 --- a/packages/react-docs/src/components/badge.tsx +++ b/packages/react-docs/src/components/badge.tsx @@ -31,7 +31,7 @@ export class Badge extends React.Component<BadgeProps, BadgeState> { isHovering: false, }; } - public render() { + public render(): React.ReactNode { const badgeStyle = { ...styles.badge, backgroundColor: this.props.backgroundColor, @@ -48,7 +48,7 @@ export class Badge extends React.Component<BadgeProps, BadgeState> { </div> ); } - private _setHoverState(isHovering: boolean) { + private _setHoverState(isHovering: boolean): void { this.setState({ isHovering, }); diff --git a/packages/react-docs/src/components/custom_enum.tsx b/packages/react-docs/src/components/custom_enum.tsx index 1fe55eedc..797372f35 100644 --- a/packages/react-docs/src/components/custom_enum.tsx +++ b/packages/react-docs/src/components/custom_enum.tsx @@ -14,7 +14,7 @@ export interface CustomEnumProps { // This component renders custom string enums that was a work-around for versions of // TypeScript <2.4.0 that did not support them natively. We keep it around to support // older versions of 0x.js <0.9.0 -export function CustomEnum(props: CustomEnumProps) { +export const CustomEnum = (props: CustomEnumProps) => { const type = props.type; if (!_.startsWith(type.defaultValue, STRING_ENUM_CODE_PREFIX)) { logUtils.log('We do not yet support `Variable` types that are not strEnums'); @@ -31,4 +31,4 @@ export function CustomEnum(props: CustomEnumProps) { {`}`} </span> ); -} +}; diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 0a525f702..25687db67 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -71,19 +71,19 @@ export class Documentation extends React.Component<DocumentationProps, Documenta isHoveringSidebar: false, }; } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('hashchange', this._onHashChanged.bind(this), false); } - public componentWillUnmount() { + public componentWillUnmount(): void { window.removeEventListener('hashchange', this._onHashChanged.bind(this), false); } - public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) { + public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState): void { if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) { const hash = window.location.hash.slice(1); sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID); } } - public render() { + public render(): React.ReactNode { const styles: Styles = { mainContainers: { position: 'absolute', @@ -157,7 +157,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta </div> ); } - private _renderLoading(mainContainersStyles: React.CSSProperties) { + private _renderLoading(mainContainersStyles: React.CSSProperties): React.ReactNode { return ( <div className="col col-12" style={mainContainersStyles}> <div @@ -289,7 +289,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta </div> ); } - private _renderNetworkBadgesIfExists(sectionName: string) { + private _renderNetworkBadgesIfExists(sectionName: string): React.ReactNode { if (this.props.docsInfo.type !== SupportedDocJson.Doxity) { return null; } @@ -368,17 +368,17 @@ export class Documentation extends React.Component<DocumentationProps, Documenta /> ); } - private _onSidebarHover(event: React.FormEvent<HTMLInputElement>) { + private _onSidebarHover(event: React.FormEvent<HTMLInputElement>): void { this.setState({ isHoveringSidebar: true, }); } - private _onSidebarHoverOff() { + private _onSidebarHoverOff(): void { this.setState({ isHoveringSidebar: false, }); } - private _onHashChanged(event: any) { + private _onHashChanged(event: any): void { const hash = window.location.hash.slice(1); sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID); } diff --git a/packages/react-docs/src/components/enum.tsx b/packages/react-docs/src/components/enum.tsx index 37f82f26e..536385d90 100644 --- a/packages/react-docs/src/components/enum.tsx +++ b/packages/react-docs/src/components/enum.tsx @@ -7,7 +7,7 @@ export interface EnumProps { values: EnumValue[]; } -export function Enum(props: EnumProps) { +export const Enum = (props: EnumProps) => { const values = _.map(props.values, (value, i) => { const defaultValueIfAny = !_.isUndefined(value.defaultValue) ? ` = ${value.defaultValue}` : ''; return `\n\t${value.name}${defaultValueIfAny},`; @@ -20,4 +20,4 @@ export function Enum(props: EnumProps) { {`}`} </span> ); -} +}; diff --git a/packages/react-docs/src/components/event_definition.tsx b/packages/react-docs/src/components/event_definition.tsx index 67729ac87..b4dc729a9 100644 --- a/packages/react-docs/src/components/event_definition.tsx +++ b/packages/react-docs/src/components/event_definition.tsx @@ -24,7 +24,7 @@ export class EventDefinition extends React.Component<EventDefinitionProps, Event shouldShowAnchor: false, }; } - public render() { + public render(): React.ReactNode { const event = this.props.event; const id = `${this.props.sectionName}-${event.name}`; return ( @@ -49,7 +49,7 @@ export class EventDefinition extends React.Component<EventDefinitionProps, Event </div> ); } - private _renderEventCode() { + private _renderEventCode(): React.ReactNode { const indexed = <span style={{ color: colors.green }}> indexed</span>; const eventArgs = _.map(this.props.event.eventArgs, (eventArg: EventArg) => { const type = ( @@ -76,7 +76,7 @@ export class EventDefinition extends React.Component<EventDefinitionProps, Event </span> ); } - private _setAnchorVisibility(shouldShowAnchor: boolean) { + private _setAnchorVisibility(shouldShowAnchor: boolean): void { this.setState({ shouldShowAnchor, }); diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx index bdfdf47c4..a881c7fec 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -13,7 +13,7 @@ export interface InterfaceProps { docsInfo: DocsInfo; } -export function Interface(props: InterfaceProps) { +export const Interface = (props: InterfaceProps) => { const type = props.type; const properties = _.map(type.children, property => { return ( @@ -63,4 +63,4 @@ export function Interface(props: InterfaceProps) { {`}`} </span> ); -} +}; diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index 1d3c90261..c4a6394fa 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -88,7 +88,7 @@ function renderParameters( docsInfo: DocsInfo, sectionName: string, typeDefinitionByName?: TypeDefinitionByName, -) { +): React.ReactNode[] { const params = _.map(parameters, (p: Parameter) => { const isOptional = p.isOptional; const hasDefaultValue = !_.isUndefined(p.defaultValue); @@ -116,7 +116,7 @@ function renderTypeParameter( docsInfo: DocsInfo, sectionName: string, typeDefinitionByName?: TypeDefinitionByName, -) { +): React.ReactNode { const typeParam = ( <span> {`<${typeParameter.name} extends `} diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 6475d3995..9e5198e16 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -42,7 +42,7 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu shouldShowAnchor: false, }; } - public render() { + public render(): React.ReactNode { const method = this.props.method; if (typeDocUtils.isPrivateOrProtectedProperty(method.name)) { return null; @@ -111,14 +111,14 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu </div> ); } - private _renderChip(text: string) { + private _renderChip(text: string): React.ReactNode { return ( <div className="p1 mr1" style={styles.chip}> {text} </div> ); } - private _renderParameterDescriptions(parameters: Parameter[]) { + private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { const descriptions = _.map(parameters, parameter => { const isOptional = parameter.isOptional; return ( @@ -146,7 +146,7 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu }); return descriptions; } - private _setAnchorVisibility(shouldShowAnchor: boolean) { + private _setAnchorVisibility(shouldShowAnchor: boolean): void { this.setState({ shouldShowAnchor, }); diff --git a/packages/react-docs/src/components/source_link.tsx b/packages/react-docs/src/components/source_link.tsx index 89956a507..58a9ba6a7 100644 --- a/packages/react-docs/src/components/source_link.tsx +++ b/packages/react-docs/src/components/source_link.tsx @@ -10,7 +10,7 @@ export interface SourceLinkProps { version: string; } -export function SourceLink(props: SourceLinkProps) { +export const SourceLink = (props: SourceLinkProps) => { const src = props.source; const sourceCodeUrl = `${props.sourceUrl}/${src.fileName}#L${src.line}`; return ( @@ -20,4 +20,4 @@ export function SourceLink(props: SourceLinkProps) { </a> </div> ); -} +}; diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index 605b58fbd..a8e601ac2 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -3,7 +3,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from '../types'; +import { CustomType, CustomTypeChild, EnumValue, KindString, TypeDocTypes } from '../types'; import { constants } from '../utils/constants'; import { utils } from '../utils/utils'; @@ -35,7 +35,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef shouldShowAnchor: false, }; } - public render() { + public render(): React.ReactNode { const customType = this.props.customType; if (!this.props.docsInfo.isPublicType(customType.name)) { return null; // no-op @@ -129,7 +129,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef </div> ); } - private _setAnchorVisibility(shouldShowAnchor: boolean) { + private _setAnchorVisibility(shouldShowAnchor: boolean): void { this.setState({ shouldShowAnchor, }); @@ -150,7 +150,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef * * Each property description should be on a new line. */ - private _formatComment(text: string) { + private _formatComment(text: string): string { const NEW_LINE_REGEX = /(\r\n|\n|\r)/gm; const sanitizedText = text.replace(NEW_LINE_REGEX, ' '); const PROPERTY_DESCRIPTION_DIVIDER = ':'; diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index 0030568a1..e9c84b7c9 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -11,6 +11,7 @@ import { DoxityDocObj, SectionsMap, SupportedDocJson, + TypeDefinitionByName, TypeDocNode, } from './types'; import { doxityUtils } from './utils/doxity_utils'; @@ -104,13 +105,13 @@ export class DocsInfo { }); return menuSubsectionsBySection; } - public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat) { + public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } { if (_.isUndefined(this.sections.types)) { return {}; } const typeDocSection = docAgnosticFormat[this.sections.types]; - const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name'); + const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any; return typeDefinitionByName; } public isVisibleConstructor(sectionName: string): boolean { diff --git a/packages/react-docs/src/utils/doxity_utils.ts b/packages/react-docs/src/utils/doxity_utils.ts index 1b91690e0..374ee07dd 100644 --- a/packages/react-docs/src/utils/doxity_utils.ts +++ b/packages/react-docs/src/utils/doxity_utils.ts @@ -142,7 +142,7 @@ export const doxityUtils = { }; return type; }, - _isMethod(abiDoc: DoxityAbiDoc) { + _isMethod(abiDoc: DoxityAbiDoc): boolean { if (abiDoc.type !== AbiTypes.Function) { return false; } @@ -152,7 +152,7 @@ export const doxityUtils = { const isMethod = hasNamedOutputIfExists && !isNameAllCaps; return isMethod; }, - _isProperty(abiDoc: DoxityAbiDoc) { + _isProperty(abiDoc: DoxityAbiDoc): boolean { if (abiDoc.type !== AbiTypes.Function) { return false; } diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index 0c7803a04..5a672f10f 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -113,7 +113,7 @@ export const typeDocUtils = { }); return docAgnosticFormat; }, - _convertEntitiesToDocSection(entities: TypeDocNode[], docsInfo: DocsInfo, sectionName: string) { + _convertEntitiesToDocSection(entities: TypeDocNode[], docsInfo: DocsInfo, sectionName: string): DocSection { const docSection: DocSection = { comment: '', constructors: [], diff --git a/packages/react-docs/src/utils/utils.ts b/packages/react-docs/src/utils/utils.ts index f8c1fefff..e3dd1fc62 100644 --- a/packages/react-docs/src/utils/utils.ts +++ b/packages/react-docs/src/utils/utils.ts @@ -1,5 +1,5 @@ export const utils = { - spawnSwitchErr(name: string, value: any) { + spawnSwitchErr(name: string, value: any): Error { return new Error(`Unexpected switch value: ${value} encountered for ${name}`); }, }; |