Skip to content

Commit

Permalink
Add type declarations for TypeScript support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Jun 11, 2019
1 parent 257d2d1 commit 52ded7d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"react-dom": ">= 16.2.0"
},
"main": "lib/react-authorization.js",
"types": "types/react-authorization.d.ts",
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@types/react": "^16.8.19",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
Expand All @@ -44,7 +46,8 @@
"webpack-node-externals": "^1.7.2"
},
"files": [
"lib"
"lib",
"types"
],
"scripts": {
"test": "jest --env=jsdom",
Expand Down
38 changes: 38 additions & 0 deletions types/react-authorization.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from "react";
import IfAllGrantedProps = ReactAuthorization.IfAllGrantedProps;
import IfAnyGrantedProps = ReactAuthorization.IfAnyGrantedProps;
import IfGrantedProps = ReactAuthorization.IfGrantedProps;
import IfNoneGrantedProps = ReactAuthorization.IfNoneGrantedProps;

export namespace ReactAuthorization {
interface CommonProps {
actual?: string | string[];
unauthorized?: React.ReactNode | null;
}

interface IfAllGrantedProps extends CommonProps {
expected: string[];
}

interface IfAnyGrantedProps extends CommonProps {
expected: string[];
}

interface IfGrantedProps extends CommonProps {
expected: string;
}

interface IfNoneGrantedProps extends CommonProps {
expected?: string | string[];
}
}

declare const IfAllGranted: React.FC<IfAllGrantedProps>;

declare const IfAnyGranted: React.FC<IfAnyGrantedProps>;

declare const IfGranted: React.FC<IfGrantedProps>;

declare const IfNoneGranted: React.FC<IfNoneGrantedProps>;

export {IfAllGranted, IfAnyGranted, IfGranted, IfNoneGranted};

0 comments on commit 52ded7d

Please sign in to comment.