Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript] fix broken typescript definitions #207

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions demo/type-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* This file contains a very small demo project
* that is tested for type correctness in the
* `npm run test:type-check` check.
*
* This file is intended to include any API interface
* to ensure that our type definitions are correct.
*/

import React, { Component } from 'react';
import Avatar, {
createAvatarComponent,
ConfigProvider,
Cache,

GravatarSource,
FacebookSource,
GithubSource,
SkypeSource,
ValueSource,
SrcSource,
IconSource,

VKontakteSource,
InstagramSource,
TwitterSource,
GoogleSource,
} from '..';

const CustomAvatar = createAvatarComponent({
sources: [
GravatarSource,
FacebookSource,
GithubSource,
SkypeSource,
ValueSource,
SrcSource,
IconSource,
VKontakteSource,
InstagramSource,
TwitterSource,
GoogleSource,
]
});

export default
class TypeTest extends Component {

render() {
return (
<div>
<Avatar />
<CustomAvatar />

<ConfigProvider>
<Avatar />
</ConfigProvider>
</div>
)
}
}
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ interface Source {

type SourceConstructor = new (props: object) => Source;

const AvatarRedirectSource: SourceConstructor;
export const RedirectSource: (network: string, property: string) => AvatarRedirectSource
export const RedirectSource: (network: string, property: string) => SourceConstructor

/**
* Universal avatar makes it possible to fetch/generate an avatar based on the information you have about that user.
* We use a fallback system that if for example an invalid Facebook ID is used it will try Google, and so on.
*/
declare const ReactAvatar: React.ComponentType<ReactAvatarProps>;
type ReactAvatar = React.ComponentType<ReactAvatarProps>;
declare const Avatar : ReactAvatar;

export const createAvatarComponent: (options: CreateAvatarOptions) => ReactAvatar;

Expand All @@ -184,4 +184,4 @@ export const InstagramSource: SourceConstructor;
export const TwitterSource: SourceConstructor;
export const GoogleSource: SourceConstructor;

export default ReactAvatar;
export default Avatar;
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"demo": "npm -s run build:demo",
"dev": "webpack-dev-server",
"serve": "npm -s run dev",
"test": "npm -s run test:lint && npm -s run test:tslint",
"test": "npm -s run test:lint && npm -s run test:type-check",
"test:lint": "eslint src",
"test:tslint": "tslint ./index.d.ts",
"test:type-check": "tsc -p tsconfig.json",
"postpublish": "npm -s run publish:docs",
"publish:docs": "npm -s run build:demo && gh-pages -d build"
},
Expand Down Expand Up @@ -59,8 +59,7 @@
"gh-pages": "^2.1.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"tslint": "^6.1.2",
"typescript": "^3.8.3",
"typescript": "^3.9.3",
"webpack": "^4.41.4",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.10",
Expand Down
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"jsx": "react",
"noEmit": true,
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
}
}
9 changes: 0 additions & 9 deletions tslint.json

This file was deleted.