fix: 解决 ts 提示问题 (#155)

This commit is contained in:
qlin 2022-11-10 17:48:34 +08:00 committed by GitHub
parent 8d4f8c1321
commit 92e154e48b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 103 additions and 148 deletions

View File

@ -29,12 +29,9 @@
}
},
"include": [
"*.js",
".fes*.js",
"src/**/*",
"typings/**/*",
"config/**/*",
"src/.fes/configType.d.ts"
"*.js",
".fes*.js"
],
"exclude": [
"build",

View File

@ -33,8 +33,7 @@
".fes*.js",
"src/**/*",
"typings/**/*",
"config/**/*",
"src/.fes/configType.d.ts"
"config/**/*"
],
"exclude": [
"build",

View File

@ -3,7 +3,7 @@
"version": "3.0.0-beta.6",
"description": "@fesjs/builder-webpack",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"types": "types.d.ts",
"files": [
"lib",
"types.d.ts"
@ -66,4 +66,4 @@
"@fesjs/fes": "^3.0.0-beta.0",
"core-js": "^3.19.2"
}
}
}

View File

@ -1,6 +1,16 @@
import { Router, NavigationGuard } from 'vue-router';
import { Ref } from 'vue';
export function access(): {
hasAccess(accessId: string | number): Promise<boolean>;
isDataReady(): boolean;
setRole(roleId: string | Promise<string>): void;
setAccess(accessIds: Array<string | number> | Promise<Array<string | number>>): void;
getAccess(): string[];
};
export function useAccess(accessId: Array<string | number>): Ref<boolean>;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
access?:
@ -16,14 +26,4 @@ declare module '@fesjs/fes' {
unAccessHandler: (param: { router: Router } & NavigationGuard) => void;
};
}
export function access(): {
hasAccess(accessId: string | number): Promise<boolean>;
isDataReady(): boolean;
setRole(roleId: string | Promise<string>): void;
setAccess(accessIds: Array<string | number> | Promise<Array<string | number>>): void;
getAccess(): string[];
};
export function useAccess(accessId: Array<string | number>): Ref<boolean>;
}

View File

@ -14,12 +14,11 @@ interface EnumApi {
convert(name: string, _enum?: [] | object, option?: { keyName: string; valueName: string }): any;
}
export const enums: EnumApi;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
enums?: {
[key: string]: [string | number, string | number][];
} | false;
}
export const enums: EnumApi;
}

View File

@ -10,6 +10,7 @@ interface Menu {
children?: Menu[];
}
export const Page: Component;
declare module '@fesjs/fes' {
interface RouteMeta {
'keep-alive'?: boolean;
@ -61,5 +62,4 @@ declare module '@fesjs/fes' {
};
}
export const Page: Component;
}

View File

@ -1,5 +1,11 @@
import '@fesjs/fes';
export const locale: {
setLocale({ locale }: { locale: string }): void;
addLocale({ locale, messages }: { locale: string; messages: object }): void;
getAllLocales(): string[];
messages: Record<string, object>;
};
declare module '@fesjs/fes' {
interface PluginBuildConfig {
locale?:
@ -11,13 +17,4 @@ declare module '@fesjs/fes' {
}
| false;
}
// export * from 'vue-i18n';
export const locale: {
setLocale({ locale }: { locale: string }): void;
addLocale({ locale, messages }: { locale: string; messages: object }): void;
getAllLocales(): string[];
messages: Record<string, object>;
};
}

View File

@ -1,10 +1,9 @@
import '@fesjs/fes';
export function useModel(moduleId: string): any;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
model?: {} | false;
}
export function useModel(moduleId: string): any;
}

View File

@ -2,6 +2,7 @@ import type { Component } from 'vue';
import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages';
import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
export const MonacoEditor: Component;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
monacoEditor?: {
@ -12,6 +13,4 @@ declare module '@fesjs/fes' {
globalAPI: boolean;
} | false;
}
export const MonacoEditor: Component;
}

View File

@ -2,6 +2,7 @@ import { readFileSync } from 'fs';
import { join } from 'path';
import { winPath } from '@fesjs/utils';
import { parseStore } from './helper';
import { name } from '../package.json';
const namespace = 'plugin-pinia';
@ -52,4 +53,8 @@ export default (api) => {
]);
api.addRuntimePlugin(() => `@@/${absRuntimeFilePath}`);
api.addConfigType(() => ({
source: name,
}));
};

View File

@ -1,9 +1,8 @@
import type { Pinia } from 'pinia';
export const pinia: Pinia;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
pinia?: {} | false;
}
export const pinia: Pinia;
}

View File

@ -7,20 +7,18 @@ interface AppOption {
props: Record<string, any>;
}
declare module '@fesjs/fes' {
interface PluginBuildConfig {
qiankun?:
| {
main?: {
apps: AppOption[];
lifeCycles?: FrameworkLifeCycles<MicroApp>;
[key: string]: any;
};
micro?: {};
}
| false;
}
export const MicroApp: Component;
export const MicroAppWithMemoHistory: Component;
export interface PluginBuildConfig {
qiankun?:
| {
main?: {
apps: AppOption[];
lifeCycles?: FrameworkLifeCycles<MicroApp>;
[key: string]: any;
};
micro?: {};
}
| false;
}
export const MicroApp: Component;
export const MicroAppWithMemoHistory: Component;

View File

@ -13,6 +13,8 @@ interface RequestPluginOption {
}
}
export function request(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): Promise<any>
export function useRequest(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref<boolean>; errorRef: Ref<Error>; dataRef: Ref<any>}
declare module "@fesjs/fes" {
interface PluginRuntimeConfig {
request?: {
@ -22,6 +24,4 @@ declare module "@fesjs/fes" {
responseInterceptors?: ResponseInterceptor[];
} & AxiosRequestConfig;
}
export function request(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): Promise<any>
export function useRequest(url: string, data: null | Record<string, any>, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref<boolean>; errorRef: Ref<Error>; dataRef: Ref<any>}
}

View File

@ -1,4 +1,4 @@
import '@fesjs/fes';
declare module '@fesjs/fes' {
interface PluginBuildConfig {

View File

@ -1,4 +1,11 @@
import '@fesjs/fes';
export const MUTATION_TYPES: object;
export const ACTION_TYPES: object;
export const GETTER_TYPES: object;
export const store: object;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
vuex?:
@ -9,11 +16,4 @@ declare module '@fesjs/fes' {
| false;
}
export const MUTATION_TYPES: object;
export const ACTION_TYPES: object;
export const GETTER_TYPES: object;
export const store: object;
}

View File

@ -14,6 +14,8 @@ interface WatermarkParam {
zIndex: number;
timestamp: string;
}
export function createWatermark(param: WatermarkParam): void;
export function destroyWatermark(): void;
declare module '@fesjs/fes' {
interface PluginBuildConfig {
@ -21,7 +23,4 @@ declare module '@fesjs/fes' {
disable: boolean;
} | false;
}
export function createWatermark(param: WatermarkParam): void;
export function destroyWatermark(): void;
}

View File

@ -1,7 +1,7 @@
function importsToStr(imports) {
return imports.map((imp) => {
const { source } = imp;
return `import '${source}';`;
return `export * from '${source}';`;
});
}

View File

@ -19,7 +19,22 @@ interface ClientRenderOption {
type RenderFunc = () => Promise<App>
declare module "@fesjs/fes" {
export function getRouter(): Router;
export function getHistory(): RouterHistory;
export function destroyRouter(): void;
declare module '@fesjs/fes' {
interface PluginRuntimeConfig {
beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig;
patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void;
modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption;
rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => Component;
onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void;
render?: (defaultRender: RenderFunc) => RenderFunc;
onRouterCreated?: ({ router }: { router: Router }) => void;
}
interface PluginBuildConfig {
alias?: Record<string, string>,
autoprefixer?: {
@ -81,17 +96,5 @@ declare module "@fesjs/fes" {
terserOptions?: object;
title?: string;
}
interface PluginRuntimeConfig {
beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig;
patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void;
modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption;
rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => Component;
onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void;
render?: (defaultRender: RenderFunc) => RenderFunc;
onRouterCreated?: ({ router }: { router: Router }) => void;
}
export function getRouter(): Router;
export function getHistory(): RouterHistory;
export function destroyRouter(): void;
}

View File

@ -3,10 +3,7 @@
"outDir": "build/dist",
"module": "esnext",
"target": "esnext",
"lib": [
"esnext",
"dom"
],
"lib": ["esnext", "dom"],
"sourceMap": true,
"baseUrl": ".",
"jsx": "preserve",
@ -17,31 +14,18 @@
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowJs": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"strict": true,
"paths": {
"@/*": [
"./src/*"
],
"@@/*": [
"./src/.fes/*"
]
"@/*": ["./src/*"],
"@@/*": ["./src/.fes/*"]
}
},
"include": [
"*.js",
".fes.js",
"src/**/*",
"typings/**/*",
"config/**/*",
"src/.fes/configType.d.ts"
".fes.js",
".fes.*.js"
],
"exclude": [
"build",
"dist",
"scripts",
"webpack",
"jest",
"node_modules"
]
}
"exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"]
}

View File

@ -1,6 +1,6 @@
// .fes.js 只负责管理编译时配置只能使用plain Object
import { defineBuildConfig } from "@fesjs/fes";
export default {
export default defineBuildConfig({
// exportStatic: {},
define: {
__DEV__: false
@ -84,5 +84,5 @@ export default {
dynamicImport: true,
monacoEditor: {
languages: ['javascript', 'typescript', 'html', 'json']
}
};
},
});

View File

@ -1,3 +1,5 @@
import { defineBuildConfig } from "@fesjs/fes";
export default {
// define: {
// __DEV__: true

View File

@ -1,5 +1,4 @@
// .fes.js 只负责管理编译时配置只能使用plain Object
import { defineBuildConfig } from "@fesjs/fes";
export default {
publicPath: 'https://gw.alipayobjects.com/'

View File

@ -24,15 +24,8 @@
},
"include": [
"src/**/*",
"tests/**/*",
"test/**/*",
"__test__/**/*",
"typings/**/*",
"config/**/*",
".eslintrc.js",
".stylelintrc.js",
".prettierrc.js",
"src/.fes/configType.d.ts"
".fes.js",
".fes.*.js"
],
"exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"]
}

View File

@ -3,10 +3,7 @@
"outDir": "build/dist",
"module": "esnext",
"target": "esnext",
"lib": [
"esnext",
"dom"
],
"lib": ["esnext", "dom"],
"sourceMap": true,
"baseUrl": ".",
"jsx": "preserve",
@ -17,31 +14,18 @@
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowJs": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"strict": true,
"paths": {
"@/*": [
"./src/*"
],
"@@/*": [
"./src/.fes/*"
]
"@/*": ["./src/*"],
"@@/*": ["./src/.fes/*"]
}
},
"include": [
"*.js",
".fes.js",
"src/**/*",
"typings/**/*",
"config/**/*",
"src/.fes/configType.d.ts"
".fes.js",
".fes.*.js"
],
"exclude": [
"build",
"dist",
"scripts",
"webpack",
"jest",
"node_modules"
]
}
"exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"]
}

View File

@ -50,4 +50,4 @@
"node": "^10.12.0 || ^12.0.0 || >= 14.0.0"
},
"types": "types.d.ts"
}
}

View File

@ -1,5 +1,4 @@
// @ts-ignore
import '@@/configType';
export * from '@@/configType'
export * from '@fesjs/runtime';