From 06261e9c3998e4080dadb903882e6415bf44e295 Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Mon, 28 Jan 2019 19:23:11 +0100 Subject: [PATCH 1/2] Added typings for Next-seo --- types/next-seo/index.d.ts | 85 ++++++++++++++++++++++++++++++++ types/next-seo/next-seo-tests.ts | 48 ++++++++++++++++++ types/next-seo/tsconfig.json | 25 ++++++++++ types/next-seo/tslint.json | 1 + 4 files changed, 159 insertions(+) create mode 100644 types/next-seo/index.d.ts create mode 100644 types/next-seo/next-seo-tests.ts create mode 100644 types/next-seo/tsconfig.json create mode 100644 types/next-seo/tslint.json diff --git a/types/next-seo/index.d.ts b/types/next-seo/index.d.ts new file mode 100644 index 0000000000..a3542c9fe9 --- /dev/null +++ b/types/next-seo/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for next-seo 1.10 +// Project: https://github.com/garmeeh/next-seo#readme +// Definitions by: Thomas Kosiewski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Component } from "react"; + +declare module "next-seo" { + interface INextSeoProps { + config: IConfig; + } + + interface IConfig { + title?: string; + titleTemplate?: string; + description?: string; + canonical?: string; + + dangerouslySetAllPagesToNoIndex?: boolean; + noindex?: boolean; + + twitter?: ITwitter; + facebook?: IFacebook; + openGraph?: IOpenGraph; + } + + interface ITwitter { + cardType?: string; + site?: string; + handle?: string; + } + + interface IFacebook { + appId?: number; + } + + interface IOpenGraph { + url?: string; + type?: string; + title?: string; + description?: string; + images?: ReadonlyArray; + defaultImageHeight?: number; + defaultImageWidth?: number; + locale?: string; + site_name?: string; + + profile?: IOpenGraphProfile; + book?: IOpenGraphBook; + article?: IOpenGraphArticle; + } + + interface IOpenGraphImages { + url?: string, + width?: number, + height?: number, + alt?: string, + } + + interface IOpenGraphProfile { + firstName?: string; + lastName?: string; + username?: string; + gender?: string; + } + + interface IOpenGraphBook { + authors?: ReadonlyArray; + isbn?: string; + releaseDate?: string; + tags?: ReadonlyArray; + } + + interface IOpenGraphArticle { + publishedTime?: string; + modifiedTime?: string; + expirationTime?: string; + + authors?: ReadonlyArray; + section?: string; + tags?: ReadonlyArray; + } + + export default class NextSeo extends Component { } +} diff --git a/types/next-seo/next-seo-tests.ts b/types/next-seo/next-seo-tests.ts new file mode 100644 index 0000000000..3c2da4b032 --- /dev/null +++ b/types/next-seo/next-seo-tests.ts @@ -0,0 +1,48 @@ +import NextSeo from 'next-seo'; + +new NextSeo({ + config: { + canonical: "", + dangerouslySetAllPagesToNoIndex: false, + description: "", + facebook: { + appId: 0, + }, + noindex: false, + openGraph: { + book: { + authors: [""], + isbn: "", + releaseDate: "", + tags: [""], + }, + defaultImageHeight: 0, + defaultImageWidth: 0, + description: "", + images: [{ + alt: "", + height: 0, + url: "", + width: 0, + }], + locale: "", + profile: { + firstName: "", + gender: "", + lastName: "", + username: "", + }, + site_name: "", + title: "", + type: "", + url: "", + }, + title: "", + titleTemplate: "", + twitter: { + cardType: "", + handle: "", + site: "", + }, + }, +}); diff --git a/types/next-seo/tsconfig.json b/types/next-seo/tsconfig.json new file mode 100644 index 0000000000..faea26b9bc --- /dev/null +++ b/types/next-seo/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "target": "es6", + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "next-seo-tests.ts" + ] +} diff --git a/types/next-seo/tslint.json b/types/next-seo/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/next-seo/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ac4b9e6cdd80c9bcda463b8024ae501cf5732cdd Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Mon, 28 Jan 2019 19:44:37 +0100 Subject: [PATCH 2/2] Next-seo: Test fixes --- types/next-seo/index.d.ts | 153 +++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 77 deletions(-) diff --git a/types/next-seo/index.d.ts b/types/next-seo/index.d.ts index a3542c9fe9..8d7c487393 100644 --- a/types/next-seo/index.d.ts +++ b/types/next-seo/index.d.ts @@ -2,84 +2,83 @@ // Project: https://github.com/garmeeh/next-seo#readme // Definitions by: Thomas Kosiewski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 import { Component } from "react"; -declare module "next-seo" { - interface INextSeoProps { - config: IConfig; - } - - interface IConfig { - title?: string; - titleTemplate?: string; - description?: string; - canonical?: string; - - dangerouslySetAllPagesToNoIndex?: boolean; - noindex?: boolean; - - twitter?: ITwitter; - facebook?: IFacebook; - openGraph?: IOpenGraph; - } - - interface ITwitter { - cardType?: string; - site?: string; - handle?: string; - } - - interface IFacebook { - appId?: number; - } - - interface IOpenGraph { - url?: string; - type?: string; - title?: string; - description?: string; - images?: ReadonlyArray; - defaultImageHeight?: number; - defaultImageWidth?: number; - locale?: string; - site_name?: string; - - profile?: IOpenGraphProfile; - book?: IOpenGraphBook; - article?: IOpenGraphArticle; - } - - interface IOpenGraphImages { - url?: string, - width?: number, - height?: number, - alt?: string, - } - - interface IOpenGraphProfile { - firstName?: string; - lastName?: string; - username?: string; - gender?: string; - } - - interface IOpenGraphBook { - authors?: ReadonlyArray; - isbn?: string; - releaseDate?: string; - tags?: ReadonlyArray; - } - - interface IOpenGraphArticle { - publishedTime?: string; - modifiedTime?: string; - expirationTime?: string; - - authors?: ReadonlyArray; - section?: string; - tags?: ReadonlyArray; - } - - export default class NextSeo extends Component { } +export interface NextSeoProps { + config: Config; } + +export interface Config { + title?: string; + titleTemplate?: string; + description?: string; + canonical?: string; + + dangerouslySetAllPagesToNoIndex?: boolean; + noindex?: boolean; + + twitter?: Twitter; + facebook?: Facebook; + openGraph?: OpenGraph; +} + +export interface Twitter { + cardType?: string; + site?: string; + handle?: string; +} + +export interface Facebook { + appId?: number; +} + +export interface OpenGraph { + url?: string; + type?: string; + title?: string; + description?: string; + images?: ReadonlyArray; + defaultImageHeight?: number; + defaultImageWidth?: number; + locale?: string; + site_name?: string; + + profile?: OpenGraphProfile; + book?: OpenGraphBook; + article?: OpenGraphArticle; +} + +export interface OpenGraphImages { + url?: string; + width?: number; + height?: number; + alt?: string; +} + +export interface OpenGraphProfile { + firstName?: string; + lastName?: string; + username?: string; + gender?: string; +} + +export interface OpenGraphBook { + authors?: ReadonlyArray; + isbn?: string; + releaseDate?: string; + tags?: ReadonlyArray; +} + +export interface OpenGraphArticle { + publishedTime?: string; + modifiedTime?: string; + expirationTime?: string; + + authors?: ReadonlyArray; + section?: string; + tags?: ReadonlyArray; +} + +export default class NextSeo extends Component { }