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

Add types definitions #55

Merged
merged 19 commits into from
Nov 15, 2019
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
types/*
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Set a function to be called after **a new file is selected**.

<br>

#### `customTabs: {[string]: CustomTabConstructor}`
#### `customTabs: {[key: string]: CustomTabConstructor}`

Add **custom tabs** for a widget.

Expand Down Expand Up @@ -129,15 +129,16 @@ receives a `fileInfo` object for each uploaded file and throws an exception if
that file does not meet validation requirements.

```jsx
const fileTypeLimit = (tps) => {
cosnt types = tps.split(' ')
return function(fileInfo) {
const fileTypeLimit = (allowedFileTypes: string) => {
const types = allowedFileTypes.split(' ')

return function(fileInfo: FileInfo) {
if (fileInfo.name === null) {
return
}
const extension = fileInfo.name.split('.').pop()

if (!types.include(extension)) {
if (extension && !types.includes(extension)) {
throw new Error('fileType')
}
}
Expand All @@ -154,7 +155,7 @@ const validators = [fileTypeLimit('mp3 avi mp4')];

<br>

#### `preloader: Component`
#### `preloader: ComponentType`

Set a custom **preloader**. Preloader is a Component to be shown while a widget
is loading.
Expand Down
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
"description": "React component for Uploadcare Widget",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "types",
"scripts": {
"lint:types": "dtslint types --onlyTestTsNext",
"clean": "rimraf dist en",
"build": "rollup -c",
"dummy": "parcel dummy/index.html",
"prepublishOnly": "npm run clean && npm run build",
"test:dev": "karma start karma.config.js",
"test": "karma start karma.config.js --single-run --nocache",
"test:dev": "npm run lint:types && karma start karma.config.js",
"test": "npm run lint:types && karma start karma.config.js --single-run --nocache",
"release": "release-it"
},
"files": [
"dist/*",
"en/*",
"locales.js"
"locales.js",
"*.d.ts"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -62,8 +65,11 @@
"@babel/preset-react": "^7.6.3",
"@release-it/conventional-changelog": "^1.1.0",
"@testing-library/react": "^9.3.0",
"@types/jquery": "^3.3.31",
"@types/react": "^16.9.11",
"assert": "^2.0.0",
"babel-eslint": "^10.0.3",
"dtslint": "^2.0.0",
"eslint": "^6.4.0",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-jsx": "^8.1.0",
Expand All @@ -89,7 +95,8 @@
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0"
"rollup-plugin-replace": "^2.2.0",
"typescript": "^3.7.2"
},
"husky": {
"hooks": {
Expand Down
Loading