Skip to content
Permalink
Browse files

Merge pull request #6373 from IlCallo/fix-6360

fix(typescript): move Quasar CLI related typings to @quasar/app, fix: #6360
  • Loading branch information
rstoenescu committed Feb 14, 2020
2 parents 5f5a5d3 + 19520c5 commit 2a04fdab556e618fcb0f9dc799947a5ea97bb0b4
@@ -5,6 +5,7 @@
"bin": {
"quasar": "./bin/quasar"
},
"typings": "types/index.d.ts",
"files": [
"assets",
"bin",
@@ -0,0 +1,29 @@
import { Request, Response } from "express";
import { HasSsr, HasStore } from "quasar";
import Vue, { ComponentOptions, VueConstructor } from "vue";
import VueRouter from "vue-router";

declare module "quasar" {
interface QSsrContext {
req: Request;
res: Response;
url: Request["url"];
}

type HasSsrBootParams = HasSsr<{ ssrContext?: QSsrContext | null }>;
type HasStoreBootParams<S = any> = HasStore<{ store: S }>;

interface BootFileParams<TStore>
extends HasSsrBootParams,
HasStoreBootParams<TStore> {
app: ComponentOptions<Vue>;
Vue: VueConstructor<Vue>;
router: VueRouter;
urlPath: string;
redirect: (url: string) => void;
}

type BootCallback<TStore> = (
params: BootFileParams<TStore>
) => void | Promise<void>;
}
@@ -0,0 +1,7 @@
import { QuasarContext, QuasarConf } from "quasar";
import "./configuration/conf";
import "./configuration/context";

declare module "quasar" {
type ConfigureCallback = (context: QuasarContext) => QuasarConf;
}
@@ -0,0 +1,11 @@
import "quasar";

interface BootConfigurationItem {
path: string;
server?: false;
client?: false;
}

declare module "quasar" {
type QuasarBootConfiguration = (string | BootConfigurationItem)[];
}
@@ -1,8 +1,9 @@
import { QuasarHookParams, WebpackConfiguration } from "quasar";
import { TerserPluginOptions } from "terser-webpack-plugin";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
import * as WebpackChain from "webpack-chain";
import { WebpackConfiguration } from "../ts-helpers";
import { QuasarHookParams } from "./conf";
import "./conf";
import "../ts-helpers";

interface QuasarStaticBuildConfiguration {
/**
@@ -168,6 +169,8 @@ interface QuasarDynamicBuildConfiguration {
webpackManifest: boolean;
}

export type QuasarBuildConfiguration = Partial<
QuasarStaticBuildConfiguration & QuasarDynamicBuildConfiguration
>;
declare module "quasar" {
type QuasarBuildConfiguration = Partial<
QuasarStaticBuildConfiguration & QuasarDynamicBuildConfiguration
>;
}
@@ -0,0 +1,16 @@
import "quasar";

declare module "quasar" {
type QuasarCapacitorTargets = "android" | "ios";

interface QuasarCapacitorConfiguration {
/** If not present, will look for `package.json > capacitorId/cordovaId` */
id?: string;
/** If not present, will look for `package.json > name` */
appName?: string;
/** If not present, will look for `package.json > version` */
version?: string;
/** If not present, will look for `package.json > description` */
description?: string;
}
}
@@ -1,15 +1,17 @@
import { QuasarAnimations } from "../extras/animations";
import { QuasarFonts } from "../extras/fonts";
import { QuasarIconSets } from "../extras/icon-set";
import { WebpackConfiguration } from "../ts-helpers";
import { QuasarBuildConfiguration } from "./build";
import { QuasarCapacitorConfiguration } from "./capacitor-conf";
import { QuasarCordovaConfiguration } from "./cordova-conf";
import { QuasarElectronConfiguration } from "./electron-conf";
import { QuasarFrameworkConfiguration } from "./framework-conf";
import { QuasarPwaConfiguration } from "./pwa-conf";
import { QuasarSsrConfiguration } from "./ssr-conf";
import { QuasarBootConfiguration } from "./boot";
import {
QuasarAnimations,
QuasarBootConfiguration,
QuasarBuildConfiguration,
QuasarFonts,
QuasarFrameworkConfiguration,
QuasarIconSets,
WebpackConfiguration
} from "quasar";
import "../ts-helpers";
import "./build";
import "./framework-conf";
import "./pwa-conf";
import "./ssr-conf";

type QuasarAnimationsConfiguration = "all" | QuasarAnimations[];

@@ -27,10 +29,6 @@ interface QuasarDevServerConfiguration
open: boolean | string;
}

interface QuasarHookParams {
quasarConf: QuasarConf;
}

/**
* Use this property to change the default names of some files of your website/app if you have to.
* All paths must be relative to the root folder of your project.
@@ -117,19 +115,25 @@ interface BaseQuasarConfiguration {
sourceFiles?: QuasarSourceFilesConfiguration;
}

export type QuasarConf = BaseQuasarConfiguration & {
/** PWA specific [config](/quasar-cli/developing-pwa/configuring-pwa). */
pwa?: QuasarPwaConfiguration;
} & {
/** SSR specific [config](/quasar-cli/developing-ssr/configuring-ssr). */
ssr?: QuasarSsrConfiguration;
} & {
/** Capacitor specific [config](/quasar-cli/developing-capacitor-apps/configuring-capacitor). */
capacitor?: QuasarCapacitorConfiguration;
} & {
/** Cordova specific [config](/quasar-cli/developing-cordova-apps/configuring-cordova). */
cordova?: QuasarCordovaConfiguration;
} & {
/** Electron specific [config](/quasar-cli/developing-electron-apps/configuring-electron). */
electron?: QuasarElectronConfiguration;
};
declare module "quasar" {
interface QuasarHookParams {
quasarConf: QuasarConf;
}

type QuasarConf = BaseQuasarConfiguration & {
/** PWA specific [config](/quasar-cli/developing-pwa/configuring-pwa). */
pwa?: QuasarPwaConfiguration;
} & {
/** SSR specific [config](/quasar-cli/developing-ssr/configuring-ssr). */
ssr?: QuasarSsrConfiguration;
} & {
/** Capacitor specific [config](/quasar-cli/developing-capacitor-apps/configuring-capacitor). */
capacitor?: QuasarCapacitorConfiguration;
} & {
/** Cordova specific [config](/quasar-cli/developing-cordova-apps/configuring-cordova). */
cordova?: QuasarCordovaConfiguration;
} & {
/** Electron specific [config](/quasar-cli/developing-electron-apps/configuring-electron). */
electron?: QuasarElectronConfiguration;
};
}
@@ -1,13 +1,10 @@
import { Configuration as ElectronBuilderConfiguration } from "electron-builder";
import { QuasarCapacitorTargets } from "./capacitor-conf";
import { QuasarCordovaTargets } from "./cordova-conf";
import {
ElectronBuilderArchs,
ElectronPackagerArchs,
ElectronBuilderTargets,
QuasarElectronBundlers,
ElectronPackagerTargets
} from "./electron-conf";
import { ElectronBuilderArchs, ElectronBuilderTargets, ElectronPackagerArchs, ElectronPackagerTargets, QuasarCapacitorTargets, QuasarCordovaTargets, QuasarElectronBundlers } from "quasar";
import "../shims";
import "./boot";
import "./capacitor-conf";
import "./cordova-conf";
import "./electron-conf";

type QuasarModes = "spa" | "ssr" | "pwa" | "cordova" | "capacitor" | "electron";

@@ -136,10 +133,13 @@ interface SsrQuasarContext extends BaseQuasarContext {
modeName: "ssr";
}

export type QuasarContext =
| SpaQuasarContext
| PwaQuasarContext
| SsrQuasarContext
| CapacitorQuasarContext
| CordovaQuasarContext
| ElectronQuasarContext;
declare module "quasar" {
type QuasarContext =
| SpaQuasarContext
| PwaQuasarContext
| SsrQuasarContext
| CapacitorQuasarContext
| CordovaQuasarContext
| ElectronQuasarContext;
}

@@ -0,0 +1,32 @@
import "quasar";

declare module "quasar" {
type QuasarCordovaTargets =
| "android"
| "ios"
| "blackberry10"
| "browser"
| "osx"
| "ubuntu"
| "webos"
| "windows";

interface QuasarCordovaConfiguration {
/** If not present, will look for `package.json > cordovaId` */
id?: string;
/** If not present, will look for `package.json > version` */
version?: string;
/** If not present, will look for `package.json > description` */
description?: string;
androidVersionCode?: string;
/**
* Enable Xcode modern build even if after considering iOS-Cordova issues.
* You can enable it if you know what you are doing,
* for example if you want to specify the build type in your “build.json”.
*
* @default false
*/
noIosLegacyBuildFlag?: boolean;
}
}

@@ -1,24 +1,14 @@
import { Configuration as ElectronBuilderConfiguration } from "electron-builder";
import { Options as ElectronPackagerOptions } from "electron-packager";
import {
arch,
Options as ElectronPackagerOptions,
platform
} from "electron-packager";
import { WebpackConfiguration } from "quasar";
import * as WebpackChain from "webpack-chain";
import { WebpackConfiguration } from "../ts-helpers";

export type QuasarElectronBundlers = "builder" | "packager";

export type ElectronBuilderArchs = "ia32" | "x64" | "armv7l" | "arm64" | "all";
import "../ts-helpers";

export type ElectronBuilderTargets =
| "darwin"
| "mac"
| "win32"
| "win"
| "linux"
| "all";

export {
arch as ElectronPackagerArchs,
platform as ElectronPackagerTargets
} from "electron-packager";
type QuasarElectronBundlersInternal = "builder" | "packager";

interface QuasarBaseElectronConfiguration {
/** Webpack config object for the Main Process ONLY (`/src-electron/main-process/`) */
@@ -41,7 +31,7 @@ interface QuasarBaseElectronConfiguration {
* or we haven’t found the recipe yet.
*/
// This property definition is here merely to avoid duplicating the TSDoc
bundler: QuasarElectronBundlers;
bundler: QuasarElectronBundlersInternal;
}

interface QuasarElectronPackagerConfiguration
@@ -63,6 +53,23 @@ interface QuasarElectronBuilderConfiguration
builder?: ElectronBuilderConfiguration;
}

export type QuasarElectronConfiguration =
| QuasarElectronPackagerConfiguration
| QuasarElectronBuilderConfiguration;
declare module "quasar" {
type QuasarElectronBundlers = QuasarElectronBundlersInternal;

type ElectronBuilderArchs = "ia32" | "x64" | "armv7l" | "arm64" | "all";

type ElectronBuilderTargets =
| "darwin"
| "mac"
| "win32"
| "win"
| "linux"
| "all";

type ElectronPackagerArchs = arch;
type ElectronPackagerTargets = platform;

type QuasarElectronConfiguration =
| QuasarElectronPackagerConfiguration
| QuasarElectronBuilderConfiguration;
}
@@ -1,7 +1,9 @@
import { QuasarIconSets } from "../extras/icon-set";
import { QuasarLanguageCodes } from "../lang";
import { QuasarComponents, QuasarDirectives, QuasarPlugins } from "../plugin";
import { DeepPartial } from "../ts-helpers";
import {
QuasarIconSets,
QuasarLanguageCodes,
DeepPartial,
QuasarPluginOptions
} from "quasar";

interface QuasarFrameworkInnerConfiguration {
brand: {
@@ -42,7 +44,7 @@ interface QuasarFrameworkInnerConfiguration {
}

interface QuasarBaseFrameworkObjectConfiguration {
plugins?: (keyof QuasarPlugins)[];
plugins?: (keyof QuasarPluginOptions["plugins"])[];
config?: DeepPartial<QuasarFrameworkInnerConfiguration>;
iconSet?: QuasarIconSets;
lang?: QuasarLanguageCodes;
@@ -64,12 +66,14 @@ interface QuasarAllFrameworkObjectConfiguration
interface QuasarManualFrameworkObjectConfiguration
extends QuasarBaseFrameworkObjectConfiguration {
all: false;
components?: (keyof QuasarComponents)[];
directives?: (keyof QuasarDirectives)[];
components?: (keyof QuasarPluginOptions["components"])[];
directives?: (keyof QuasarPluginOptions["directives"])[];
}

export type QuasarFrameworkConfiguration =
| "all" // Equal to `{ all: true }`
| QuasarAutoFrameworkObjectConfiguration
| QuasarAllFrameworkObjectConfiguration
| QuasarManualFrameworkObjectConfiguration;
declare module "quasar" {
type QuasarFrameworkConfiguration =
| "all" // Equal to `{ all: true }`
| QuasarAutoFrameworkObjectConfiguration
| QuasarAllFrameworkObjectConfiguration
| QuasarManualFrameworkObjectConfiguration;
}

0 comments on commit 2a04fda

Please sign in to comment.
You can’t perform that action at this time.