diff --git a/.gitignore b/.gitignore index e135849..63d83d3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist/ node_modules/ .DS_Store yarn-error.log +lib/ diff --git a/config/index.js b/config/index.js index ce6ed35..12d0837 100644 --- a/config/index.js +++ b/config/index.js @@ -11,7 +11,7 @@ const config = { '828': 1.81 / 2 }, sourceRoot: 'src', - outputRoot: 'dist', + outputRoot: 'lib', alias: { '@': path.resolve(__dirname, '..', 'src'), }, diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..5f670c5 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "outDir": "./lib", + "baseUrl": "." + }, + "include": ["src/**/*"] +} diff --git a/package.json b/package.json index defdc04..0841e23 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "license": "MIT", "author": "miaonster ", "files": [ - "dist" + "lib", + "types" ], "type": "module", - "main": "dist/index.js", + "main": "lib/index.js", "scripts": { "build": "export TARO_BUILD_TYPE=ui && taro build --ui", "dev:alipay": "taro build --type alipay --watch", diff --git a/src/components/Barcode/__snapshots__/index.test.js.snap b/src/components/Barcode/__snapshots__/index.test.js.snap index 3875350..62a03da 100644 --- a/src/components/Barcode/__snapshots__/index.test.js.snap +++ b/src/components/Barcode/__snapshots__/index.test.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Barcode test Barcode test suites 1`] = `"
"`; +exports[`Barcode test Barcode test suites 1`] = `"
"`; diff --git a/src/components/Barcode/index.js b/src/components/Barcode/index.js index e06093f..f2b22d4 100644 --- a/src/components/Barcode/index.js +++ b/src/components/Barcode/index.js @@ -19,7 +19,7 @@ BarCode.defaultProps = { } BarCode.propTypes = { - text: PropTypes.string, + text: PropTypes.string.isRequired, scale: PropTypes.number, width: PropTypes.number, height: PropTypes.number, diff --git a/src/components/Qrcode/index.js b/src/components/Qrcode/index.js index 8097d41..b91c151 100644 --- a/src/components/Qrcode/index.js +++ b/src/components/Qrcode/index.js @@ -21,9 +21,9 @@ QRCode.defaultProps = { } QRCode.propTypes = { + text: PropTypes.string.isRequired, size: PropTypes.number, scale: PropTypes.number, - text: PropTypes.string, errorCorrectLevel: PropTypes.string, typeNumber: PropTypes.number, } diff --git a/src/index.js b/src/index.js index b57e478..274fac9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,2 +1,2 @@ export { default as Barcode } from './components/Barcode' -export { default as QRCode } from './components/Qrcode' +export { default as QRCode } from './components/QRCode' diff --git a/src/pages/index/index.js b/src/pages/index/index.js index a08087c..2c01256 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -1,7 +1,7 @@ import Taro, { Component } from '@tarojs/taro' import { View } from '@tarojs/components' import Barcode from '../../components/Barcode' -import QRCode from '../../components/Qrcode' +import QRCode from '../../components/QRCode' import './index.css' export default class Index extends Component { diff --git a/types/barcode.d.ts b/types/barcode.d.ts new file mode 100644 index 0000000..340f6df --- /dev/null +++ b/types/barcode.d.ts @@ -0,0 +1,10 @@ +import React from 'react' + +export interface BarcodeProps { + text: string + scale?: number + width?: number + height?: number +} + +declare const Barcode: React.SFC diff --git a/types/qrcode.d.ts b/types/qrcode.d.ts new file mode 100644 index 0000000..eac8788 --- /dev/null +++ b/types/qrcode.d.ts @@ -0,0 +1,16 @@ +import React from 'react' + +export interface QRCodeProps { + text: string + scale?: number + size?: number + /** + * version + * @default 2 + * @see https://www.qrcode.com/zh/about/version.html + */ + typeNumber?: number + errorCorrectLevel?: 'L' | 'M' | 'Q' | 'H' +} + +declare const QRCode: React.SFC