Skip to content

Commit

Permalink
fix: tsc error file
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Mar 3, 2021
1 parent 838a584 commit 01ac2d6
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 42 deletions.
19 changes: 13 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
"tag": "next"
},
"description": "一套京东风格的轻量级移动端 Vue 组件库",
"main": "dist/lib/nutui.js",
"module": "dist/es/nutui.js",
"style": "dist/lib/index.css",
"typings": "dist/types/index.d.ts",
"main": "dist/nutui.umd.js",
"module": "dist/nutui.es.js",
"exports": {
".": {
"import": "./dist/nutui.es.js",
"require": "./dist/nutui.umd.js"
}
},
"style": "dist/style.css",
"typings": "dist/types/nutui.d.ts",
"keywords": [
"nutui",
"nutui2",
Expand Down Expand Up @@ -36,11 +42,12 @@
"CHANGELOG.md"
],
"scripts": {
"dev": "vite --open",
"dev": "tsc && vite --open",
"build:site": "vite build",
"build": "vite build -c vite.config.build.ts",
"build:ts": "rm -rf dist/es && tsc",
"serve": "vite preview",
"upload": "vite build && node ./jd/upload.js",
"upload": "yarn build:site && node ./jd/upload.js",
"add": "node jd/createComponentMode.js"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { defineComponent, createVNode, render, toRef, watch } from 'vue';

const confirmConstructor = defineComponent(dialog);

let instance;
const Dialog = options => {
let instance: any;
const Dialog = (options: any) => {
options = options ? options : {};

options.id = options.id || 'nut-dialog-default-id';
Expand Down Expand Up @@ -38,7 +38,7 @@ Dialog.close = function() {
}
};

Dialog.install = function(app) {
Dialog.install = function(app: any) {
app.use(dialog);
app.config.globalProperties.$dialog = Dialog;
};
Expand Down
16 changes: 8 additions & 8 deletions src/packages/notify/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const clearNotify = (id?: string) => {
}
};

const updateNotify = opts => {
const updateNotify = (opts: any) => {
const container = document.getElementById(opts.id);
if (container) {
const currentOpt = optsMap.find(item => item.id === opts.id);
Expand All @@ -53,7 +53,7 @@ const updateNotify = opts => {
}
};

const mountNotify = opts => {
const mountNotify = (opts: any) => {
opts.unmount = clearNotify;
let _id;
if (opts.id) {
Expand Down Expand Up @@ -81,31 +81,31 @@ const mountNotify = opts => {
return instance.component.ctx;
};

const errorMsg = msg => {
const errorMsg = (msg: string) => {
if (!msg) {
console.warn('[NutUI Notify]: msg不能为空');
return;
}
};

export const Notify = {
text(msg, obj = {}) {
text(msg: string, obj = {}) {
errorMsg(msg);
return mountNotify({ ...obj, msg });
},
primary(msg, obj = {}) {
primary(msg: string, obj = {}) {
errorMsg(msg);
return mountNotify({ ...obj, msg, type: 'primary' });
},
success(msg, obj = {}) {
success(msg: string, obj = {}) {
errorMsg(msg);
return mountNotify({ ...obj, msg, type: 'success' });
},
danger(msg, obj = {}) {
danger(msg: string, obj = {}) {
errorMsg(msg);
return mountNotify({ ...obj, msg, type: 'danger' });
},
warn(msg, obj = {}) {
warn(msg: string, obj = {}) {
errorMsg(msg);
return mountNotify({ ...obj, msg, type: 'warning' });
},
Expand Down
16 changes: 8 additions & 8 deletions src/packages/toast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const clearToast = (id?: string) => {
}
};

const updateToast = opts => {
const updateToast = (opts: any) => {
const container = document.getElementById(opts.id);
if (container) {
const currentOpt = optsMap.find(item => item.id === opts.id);
Expand All @@ -58,7 +58,7 @@ const updateToast = opts => {
}
};

const mountToast = opts => {
const mountToast = (opts: any) => {
opts.unmount = clearToast;
let _id;
// 如果是更新已有的toast
Expand All @@ -83,31 +83,31 @@ const mountToast = opts => {
return instance.component.ctx;
};

const errorMsg = msg => {
const errorMsg = (msg: string) => {
if (!msg) {
console.warn('[NutUI Toast]: msg不能为空');
return;
}
};

export const Toast = {
text(msg, opts = {}) {
text(msg: string, opts = {}) {
errorMsg(msg);
return mountToast({ ...opts, type: 'text', msg });
},
success(msg, opts = {}) {
success(msg: string, opts = {}) {
errorMsg(msg);
return mountToast({ icon: 'success', ...opts, msg, type: 'success' });
},
fail(msg, opts = {}) {
fail(msg: string, opts = {}) {
errorMsg(msg);
return mountToast({ icon: 'failure', ...opts, msg, type: 'fail' });
},
warn(msg, opts = {}) {
warn(msg: string, opts = {}) {
errorMsg(msg);
return mountToast({ icon: 'tips', ...opts, msg, type: 'warn' });
},
loading(msg, opts = {}) {
loading(msg: string, opts = {}) {
return mountToast({
icon:
"data:image/svg+xml, %3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='rgb(230,230,230)' d='M874.667 533.333h-192c-12.8 0-21.334-8.533-21.334-21.333 0-12.8 8.534-21.333 21.334-21.333h192c12.8 0 21.333 8.533 21.333 21.333 0 12.8-8.533 21.333-21.333 21.333zM648.533 407.467C640 416 627.2 416 618.667 407.467c-8.534-8.534-8.534-21.334 0-29.867L755.2 241.067c8.533-8.534 21.333-8.534 29.867 0 8.533 8.533 8.533 21.333 0 29.866L648.533 407.467zM512 896c-12.8 0-21.333-8.533-21.333-21.333v-192c0-12.8 8.533-21.334 21.333-21.334s21.333 8.534 21.333 21.334v192c0 12.8-8.533 21.333-21.333 21.333zm0-533.333c-12.8 0-21.333-8.534-21.333-21.334v-192c0-12.8 8.533-21.333 21.333-21.333s21.333 8.533 21.333 21.333v192c0 12.8-8.533 21.334-21.333 21.334zM270.933 782.933c-8.533 8.534-21.333 8.534-29.866 0s-8.534-21.333 0-29.866L377.6 616.533c8.533-8.533 21.333-8.533 29.867 0 8.533 8.534 8.533 21.334 0 29.867L270.933 782.933zm104.534-375.466L238.933 270.933c-8.533-8.533-8.533-21.333 0-29.866s21.334-8.534 29.867 0L405.333 377.6c8.534 8.533 8.534 21.333 0 29.867-6.4 6.4-21.333 6.4-29.866 0zM362.667 512c0 12.8-8.534 21.333-21.334 21.333h-192C136.533 533.333 128 524.8 128 512c0-12.8 8.533-21.333 21.333-21.333h192c12.8 0 21.334 8.533 21.334 21.333zm285.866 104.533l136.534 136.534c8.533 8.533 8.533 21.333 0 29.866-8.534 8.534-21.334 8.534-29.867 0L618.667 646.4c-8.534-8.533-8.534-21.333 0-29.867 6.4-6.4 21.333-6.4 29.866 0z'/%3E%3C/svg%3E",
Expand Down
2 changes: 1 addition & 1 deletion src/sites/service/ArticleApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ArticleApiService {
* 保存用户访问数据
* @returns
*/
saveUserInfo(parmas) {
saveUserInfo(parmas: any) {
return this.httpClient.request('/visit/saveVisitInfo', 'post', parmas);
}
}
2 changes: 1 addition & 1 deletion src/sites/service/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class HttpClient {
* @param {any} value 接口响应数据
* @param {string} message 服务器响应信息msg
*/
interface ResponseData {
export interface ResponseData {
state: number;
value?: any;
message: string;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Utils = {
if (/^0/.test(month)) {
month = month.split('')[1];
}
return [
return ([
0,
31,
this.isLeapYear(Number(year)) ? 29 : 28,
Expand All @@ -61,7 +61,7 @@ const Utils = {
31,
30,
31
][month];
] as number[])[month as any];
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/raf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function requestAniFrame() {
}
);
} else {
return function(callback) {
return function(callback: Function) {
setTimeout(callback, 1000 / 60);
};
}
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"sourceMap": false,
"declaration": true,
"removeComments":true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"outDir": "./dist/es",
"types": ["vite/client"],
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["./node_modules"]
"exclude": ["./node_modules","src/sites"]
}
18 changes: 8 additions & 10 deletions vite.config.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ export default defineConfig({
],
build: {
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
// external: ['vue'],
// output: {
// // Provide global variables to use in the UMD build
// // for externalized deps
// globals: {
// vue: 'Vue'
// }
// }
// 请确保外部化那些你的库中不需要的依赖
external: ['vue'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue'
}
}
},
lib: {
entry: 'src/nutui.ts',
Expand Down

0 comments on commit 01ac2d6

Please sign in to comment.