From b74957acdfc8d67d154bcb4698acd7575db7cc47 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 11 May 2018 17:38:51 +0200 Subject: Add missing type definitions --- packages/website/ts/pages/about/about.tsx | 6 ++-- packages/website/ts/pages/about/profile.tsx | 8 ++--- .../website/ts/pages/documentation/doc_page.tsx | 10 +++--- packages/website/ts/pages/faq/faq.tsx | 8 ++--- packages/website/ts/pages/faq/question.tsx | 4 +-- packages/website/ts/pages/landing/landing.tsx | 39 ++++++++++++---------- packages/website/ts/pages/not_found.tsx | 2 +- packages/website/ts/pages/wiki/wiki.tsx | 18 +++++----- 8 files changed, 50 insertions(+), 45 deletions(-) (limited to 'packages/website/ts/pages') diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index d78cca703..673022329 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -210,10 +210,10 @@ const styles: Styles = { }; export class About extends React.Component { - public componentDidMount() { + public componentDidMount(): void { window.scrollTo(0, 0); } - public render() { + public render(): React.ReactNode { return (
@@ -284,7 +284,7 @@ export class About extends React.Component {
); } - private _renderProfiles(profiles: ProfileInfo[]) { + private _renderProfiles(profiles: ProfileInfo[]): React.ReactNode { const numIndiv = profiles.length; const colSize = utils.getColSize(numIndiv); return _.map(profiles, profile => { diff --git a/packages/website/ts/pages/about/profile.tsx b/packages/website/ts/pages/about/profile.tsx index 4361da103..dd046a8cb 100644 --- a/packages/website/ts/pages/about/profile.tsx +++ b/packages/website/ts/pages/about/profile.tsx @@ -22,7 +22,7 @@ interface ProfileProps { profileInfo: ProfileInfo; } -export function Profile(props: ProfileProps) { +export const Profile = (props: ProfileProps) => { return (
@@ -53,9 +53,9 @@ export function Profile(props: ProfileProps) {
); -} +}; -function renderSocialMediaIcons(profileInfo: ProfileInfo) { +function renderSocialMediaIcons(profileInfo: ProfileInfo): React.ReactNode { const icons = [ renderSocialMediaIcon('zmdi-github-box', profileInfo.github), renderSocialMediaIcon('zmdi-linkedin-box', profileInfo.linkedIn), @@ -64,7 +64,7 @@ function renderSocialMediaIcons(profileInfo: ProfileInfo) { return icons; } -function renderSocialMediaIcon(iconName: string, url: string) { +function renderSocialMediaIcon(iconName: string, url: string): React.ReactNode { if (_.isEmpty(url)) { return null; } diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index be8ae02f4..17efc56ed 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -59,7 +59,7 @@ export class DocPage extends React.Component { docAgnosticFormat: undefined, }; } - public componentWillMount() { + public componentWillMount(): void { const pathName = this.props.location.pathname; const lastSegment = pathName.substr(pathName.lastIndexOf('/') + 1); const versions = findVersions(lastSegment); @@ -67,10 +67,10 @@ export class DocPage extends React.Component { // tslint:disable-next-line:no-floating-promises this._fetchJSONDocsFireAndForgetAsync(preferredVersionIfExists); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; } - public render() { + public render(): React.ReactNode { const menuSubsectionsBySection = _.isUndefined(this.state.docAgnosticFormat) ? {} : this.props.docsInfo.getMenuSubsectionsBySection(this.state.docAgnosticFormat); @@ -135,7 +135,7 @@ export class DocPage extends React.Component { }); } } - private _getSourceUrl() { + private _getSourceUrl(): string { const url = this.props.docsInfo.packageUrl; let pkg = docIdToSubpackageName[this.props.docsInfo.id]; let tagPrefix = pkg; @@ -155,7 +155,7 @@ export class DocPage extends React.Component { const sourceUrl = `${url}/blob/${tagPrefix}%40${this.props.docsVersion}/packages${pkg}`; return sourceUrl; } - private _onVersionSelected(semver: string) { + private _onVersionSelected(semver: string): void { let path = window.location.pathname; const lastChar = path[path.length - 1]; if (_.isFinite(_.parseInt(lastChar))) { diff --git a/packages/website/ts/pages/faq/faq.tsx b/packages/website/ts/pages/faq/faq.tsx index 701031d44..c9295d806 100644 --- a/packages/website/ts/pages/faq/faq.tsx +++ b/packages/website/ts/pages/faq/faq.tsx @@ -404,10 +404,10 @@ const sections: FAQSection[] = [ ]; export class FAQ extends React.Component { - public componentDidMount() { + public componentDidMount(): void { window.scrollTo(0, 0); } - public render() { + public render(): React.ReactNode { return (
@@ -422,7 +422,7 @@ export class FAQ extends React.Component {
); } - private _renderSections() { + private _renderSections(): React.ReactNode { const renderedSections = _.map(sections, (section: FAQSection, i: number) => { const isFirstSection = i === 0; return ( @@ -434,7 +434,7 @@ export class FAQ extends React.Component { }); return renderedSections; } - private _renderQuestions(questions: FAQQuestion[], isFirstSection: boolean) { + private _renderQuestions(questions: FAQQuestion[], isFirstSection: boolean): React.ReactNode { const renderedQuestions = _.map(questions, (question: FAQQuestion, i: number) => { const isFirstQuestion = i === 0; return ( diff --git a/packages/website/ts/pages/faq/question.tsx b/packages/website/ts/pages/faq/question.tsx index 240dae910..28ea6881a 100644 --- a/packages/website/ts/pages/faq/question.tsx +++ b/packages/website/ts/pages/faq/question.tsx @@ -20,7 +20,7 @@ export class Question extends React.Component { isExpanded: props.shouldDisplayExpanded, }; } - public render() { + public render(): React.ReactNode { return (
{
); } - private _onExchangeChange() { + private _onExchangeChange(): void { this.setState({ isExpanded: !this.state.isExpanded, }); diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx index a63c24fb7..02ecfa117 100644 --- a/packages/website/ts/pages/landing/landing.tsx +++ b/packages/website/ts/pages/landing/landing.tsx @@ -177,14 +177,14 @@ export class Landing extends React.Component { }; this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('resize', this._throttledScreenWidthUpdate); window.scrollTo(0, 0); } - public componentWillUnmount() { + public componentWillUnmount(): void { window.removeEventListener('resize', this._throttledScreenWidthUpdate); } - public render() { + public render(): React.ReactNode { return (
@@ -218,7 +218,7 @@ export class Landing extends React.Component {
); } - private _renderHero() { + private _renderHero(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const buttonLabelStyle: React.CSSProperties = { textTransform: 'none', @@ -305,7 +305,7 @@ export class Landing extends React.Component { ); } - private _renderWhatsNew() { + private _renderWhatsNew(): React.ReactNode { return ( ); } - private _renderProjects(projects: Project[], title: string, backgroundColor: string, isTitleCenter: boolean) { + private _renderProjects( + projects: Project[], + title: string, + backgroundColor: string, + isTitleCenter: boolean, + ): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const projectList = _.map(projects, (project: Project, i: number) => { const isRelayersOnly = projects.length === 12; @@ -393,7 +398,7 @@ export class Landing extends React.Component { ); } - private _renderTokenizationSection() { + private _renderTokenizationSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -424,7 +429,7 @@ export class Landing extends React.Component {
); } - private _renderProtocolSection() { + private _renderProtocolSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -469,7 +474,7 @@ export class Landing extends React.Component {
); } - private _renderBuildingBlocksSection() { + private _renderBuildingBlocksSection(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const descriptionStyle: React.CSSProperties = { fontFamily: 'Roboto Mono', @@ -526,7 +531,7 @@ export class Landing extends React.Component { ); } - private _renderBlockChipImage() { + private _renderBlockChipImage(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -534,7 +539,7 @@ export class Landing extends React.Component {
); } - private _renderTokenCloud() { + private _renderTokenCloud(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; return (
@@ -542,7 +547,7 @@ export class Landing extends React.Component {
); } - private _renderAssetTypes() { + private _renderAssetTypes(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const assetTypes: AssetType[] = [ { @@ -585,7 +590,7 @@ export class Landing extends React.Component { }); return assets; } - private _renderInfoBoxes() { + private _renderInfoBoxes(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const boxStyle: React.CSSProperties = { maxWidth: 253, @@ -648,7 +653,7 @@ export class Landing extends React.Component { ); } - private _renderUseCases() { + private _renderUseCases(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const useCases: UseCase[] = [ @@ -746,7 +751,7 @@ export class Landing extends React.Component { ); } - private _renderCallToAction() { + private _renderCallToAction(): React.ReactNode { const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm; const buttonLabelStyle: React.CSSProperties = { textTransform: 'none', @@ -793,7 +798,7 @@ export class Landing extends React.Component { ); } - private _updateScreenWidth() { + private _updateScreenWidth(): void { const newScreenWidth = utils.getScreenWidth(); if (newScreenWidth !== this.state.screenWidth) { this.setState({ @@ -801,7 +806,7 @@ export class Landing extends React.Component { }); } } - private _onLanguageSelected(language: Language) { + private _onLanguageSelected(language: Language): void { this.props.dispatcher.updateSelectedLanguage(language); } } // tslint:disable:max-file-line-count diff --git a/packages/website/ts/pages/not_found.tsx b/packages/website/ts/pages/not_found.tsx index ff25a35e9..96c73d4ec 100644 --- a/packages/website/ts/pages/not_found.tsx +++ b/packages/website/ts/pages/not_found.tsx @@ -21,7 +21,7 @@ const styles: Styles = { }; export class NotFound extends React.Component { - public render() { + public render(): React.ReactNode { return (
diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index edca5834d..720c1cc37 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -69,19 +69,19 @@ export class Wiki extends React.Component { isHoveringSidebar: false, }; } - public componentDidMount() { + public componentDidMount(): void { window.addEventListener('hashchange', this._onHashChanged.bind(this), false); } - public componentWillMount() { + public componentWillMount(): void { // tslint:disable-next-line:no-floating-promises this._fetchArticlesBySectionAsync(); } - public componentWillUnmount() { + public componentWillUnmount(): void { this._isUnmounted = true; clearTimeout(this._wikiBackoffTimeoutId); window.removeEventListener('hashchange', this._onHashChanged.bind(this), false); } - public render() { + public render(): React.ReactNode { const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection) ? {} : this._getMenuSubsectionsBySection(this.state.articlesBySection); @@ -171,7 +171,7 @@ export class Wiki extends React.Component { const sections = _.map(sectionNames, sectionName => this._renderSection(sectionName)); return sections; } - private _renderSection(sectionName: string) { + private _renderSection(sectionName: string): React.ReactNode { const articles = this.state.articlesBySection[sectionName]; const renderedArticles = _.map(articles, (article: Article) => { const githubLink = `${constants.URL_GITHUB_WIKI}/edit/master/${sectionName}/${article.fileName}`; @@ -227,7 +227,7 @@ export class Wiki extends React.Component { } } } - private _getMenuSubsectionsBySection(articlesBySection: ArticlesBySection) { + private _getMenuSubsectionsBySection(articlesBySection: ArticlesBySection): { [section: string]: string[] } { const sectionNames = _.keys(articlesBySection); const menuSubsectionsBySection: { [section: string]: string[] } = {}; for (const sectionName of sectionNames) { @@ -237,17 +237,17 @@ export class Wiki extends React.Component { } return menuSubsectionsBySection; } - private _onSidebarHover(event: React.FormEvent) { + private _onSidebarHover(event: React.FormEvent): 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); } -- cgit v1.2.3