Added type definitions for @chenfengyuan/vue-qrcode (#47016)

This commit is contained in:
gaoming13 2020-08-28 08:00:45 +08:00 committed by GitHub
parent 8809c61614
commit 869e188582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import Vue from 'vue';
import VueQrCode from '@chenfengyuan/vue-qrcode';
new Vue({
el: '#app',
components: {
VueQrCode,
},
template: `<vue-qr-code :value="'http://example.com/'"></vue-qr-code>`
});

View File

@ -0,0 +1,50 @@
// Type definitions for @chenfengyuan/vue-qrcode 1.0
// Project: https://github.com/fengyuanchen/vue-qrcode
// Definitions by: gaoming13 <https://github.com/gaoming13>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.9
import { VueConstructor } from 'vue';
declare const VueQrCode: QrCodeConstructor;
export = VueQrCode;
interface QrCodePorps {
// The value of the QR code.
value: string | null;
// The options for the QR code generator.
options: {
// QR Code version.
version?: number;
// Error correction level.
errorCorrectionLevel?: 'low' | 'medium' | 'quartile' | 'high' | 'L' | 'M' | 'Q' | 'H';
// Mask pattern used to mask the symbol.
maskPattern?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
// Define how much wide the quiet zone should be.
margin?: number;
// Scale factor.
scale?: number;
// Forces a specific width for the output image.
width?: number;
color?: {
dark?: string;
light?: string;
}
};
// The tag name of the component's root element.
tag: string;
}
interface QrCodeWatch {
$props: (val: any) => void;
}
interface QrCodeMethods {
// Generate QR code.
generate: () => void;
}
interface QrCodeConstructor extends VueConstructor {
props: QrCodePorps;
watch: QrCodeWatch;
methods: QrCodeMethods;
}

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"vue": ">=2.0.0"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@chenfengyuan/vue-qrcode": ["chenfengyuan__vue-qrcode"]
}
},
"files": [
"index.d.ts",
"chenfengyuan__vue-qrcode-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }