mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
strict typings
This commit is contained in:
parent
b56fa78ce6
commit
89db9f8f4f
@ -2,13 +2,13 @@ import { createApp } from './app'
|
|||||||
|
|
||||||
import type { PageContext, VikePageContext } from '#types/PageContext'
|
import type { PageContext, VikePageContext } from '#types/PageContext'
|
||||||
|
|
||||||
let app: ReturnType<typeof createApp>
|
let instance: ReturnType<typeof createApp>
|
||||||
async function render(pageContext: VikePageContext & PageContext) {
|
/* async */ function render(pageContext: VikePageContext & PageContext) {
|
||||||
if (!app) {
|
if (!instance) {
|
||||||
app = createApp(pageContext).app
|
instance = createApp(pageContext)
|
||||||
app.mount('#app')
|
instance.app.mount('#app')
|
||||||
} else {
|
} else {
|
||||||
app.changePage(pageContext)
|
instance.app.changePage(pageContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,9 @@ function createApp(pageContext: VikePageContext & PageContext, isClient = true)
|
|||||||
objectAssign(app, {
|
objectAssign(app, {
|
||||||
changePage: (pageContext: VikePageContext & PageContext) => {
|
changePage: (pageContext: VikePageContext & PageContext) => {
|
||||||
Object.assign(pageContextReactive, pageContext)
|
Object.assign(pageContextReactive, pageContext)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
rootComponent.Page = markRaw(pageContext.Page)
|
rootComponent.Page = markRaw(pageContext.Page)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
rootComponent.pageProps = markRaw(pageContext.pageProps || {})
|
rootComponent.pageProps = markRaw(pageContext.pageProps || {})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
import '@mdi/font/css/materialdesignicons.css'
|
import '@mdi/font/css/materialdesignicons.css'
|
||||||
// eslint-disable-next-line import/no-unassigned-import
|
// eslint-disable-next-line import/no-unassigned-import
|
||||||
import 'vuetify/lib/styles/main.sass'
|
import 'vuetify/lib/styles/main.sass'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { I18n, useI18n } from 'vue-i18n'
|
||||||
import { createVuetify } from 'vuetify'
|
import { createVuetify } from 'vuetify'
|
||||||
// eslint-disable-next-line import/no-namespace
|
// eslint-disable-next-line import/no-namespace
|
||||||
import * as components from 'vuetify/lib/components/index.mjs'
|
import * as components from 'vuetify/lib/components/index.mjs'
|
||||||
@ -11,7 +11,7 @@ import * as directives from 'vuetify/lib/directives/index.mjs'
|
|||||||
import { createVueI18nAdapter } from 'vuetify/locale/adapters/vue-i18n'
|
import { createVueI18nAdapter } from 'vuetify/locale/adapters/vue-i18n'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export default (i18n: any) =>
|
export default (i18n: I18n<any, NonNullable<unknown>, NonNullable<unknown>, string, false>) =>
|
||||||
createVuetify({
|
createVuetify({
|
||||||
locale: {
|
locale: {
|
||||||
adapter: createVueI18nAdapter({ i18n, useI18n }),
|
adapter: createVueI18nAdapter({ i18n, useI18n }),
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { root } from './root.js'
|
|||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production'
|
const isProduction = process.env.NODE_ENV === 'production'
|
||||||
|
|
||||||
startServer()
|
void startServer()
|
||||||
|
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
const app = express()
|
const app = express()
|
||||||
@ -52,6 +52,7 @@ async function startServer() {
|
|||||||
|
|
||||||
// Vike middleware. It should always be our last middleware (because it's a
|
// Vike middleware. It should always be our last middleware (because it's a
|
||||||
// catch-all middleware superseding any middleware placed after it).
|
// catch-all middleware superseding any middleware placed after it).
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
app.get('*', async (req, res, next) => {
|
app.get('*', async (req, res, next) => {
|
||||||
const pageContextInit = {
|
const pageContextInit = {
|
||||||
urlOriginal: req.originalUrl,
|
urlOriginal: req.originalUrl,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import ClientOnly from './ClientOnly.vue'
|
|||||||
describe('ClientOnly', () => {
|
describe('ClientOnly', () => {
|
||||||
const wrapper = mount(ClientOnly)
|
const wrapper = mount(ClientOnly)
|
||||||
|
|
||||||
it('renders content if mounted', async () => {
|
it('renders content if mounted', () => {
|
||||||
expect(wrapper.isVisible()).toBeTruthy()
|
expect(wrapper.isVisible()).toBeTruthy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
const META = {
|
const META = {
|
||||||
DEFAULT_TITLE: import.meta.env.PUBLIC_ENV__META__DEFAULT_TITLE ?? 'IT4C',
|
DEFAULT_TITLE: (import.meta.env.PUBLIC_ENV__META__DEFAULT_TITLE as string) ?? 'IT4C',
|
||||||
DEFAULT_DESCRIPTION:
|
DEFAULT_DESCRIPTION:
|
||||||
import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION ?? 'IT4C Frontend Boilerplate',
|
(import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION as string) ??
|
||||||
|
'IT4C Frontend Boilerplate',
|
||||||
}
|
}
|
||||||
|
|
||||||
export { META }
|
export { META }
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { VueWrapper, mount } from '@vue/test-utils'
|
||||||
import { describe, it, expect, beforeEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
|
import { ComponentPublicInstance } from 'vue'
|
||||||
|
|
||||||
import ErrorPage from './_error.page.vue'
|
import ErrorPage from './_error.page.vue'
|
||||||
|
|
||||||
describe('ErrorPage', () => {
|
describe('ErrorPage', () => {
|
||||||
let wrapper: typeof ErrorPage
|
let wrapper: VueWrapper<unknown, ComponentPublicInstance<unknown, Omit<unknown, never>>>
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return mount(ErrorPage)
|
return mount(ErrorPage)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type { PageContextBuiltInServer } from 'vike/types'
|
|||||||
|
|
||||||
export { onBeforeRender }
|
export { onBeforeRender }
|
||||||
|
|
||||||
async function onBeforeRender(pageContext: PageContextBuiltInServer) {
|
/* async */ function onBeforeRender(pageContext: PageContextBuiltInServer) {
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
pageProps: pageContext.routeParams,
|
pageProps: pageContext.routeParams,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { setActivePinia, createPinia } from 'pinia'
|
import { setActivePinia, createPinia } from 'pinia'
|
||||||
import { describe, it, expect } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
|
|
||||||
import { useCounterStore } from './counter'
|
import { useCounterStore } from './counter'
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const meta = {
|
|||||||
render: (args: any) => ({
|
render: (args: any) => ({
|
||||||
components: { ExampleHeader },
|
components: { ExampleHeader },
|
||||||
setup() {
|
setup() {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
return { args }
|
return { args }
|
||||||
},
|
},
|
||||||
template: '<example-header :user="args.user" />',
|
template: '<example-header :user="args.user" />',
|
||||||
|
|||||||
@ -26,8 +26,8 @@ type Story = StoryObj<typeof meta>
|
|||||||
export const LoggedIn: Story = {
|
export const LoggedIn: Story = {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
play: async ({ canvasElement }: any) => {
|
play: async ({ canvasElement }: any) => {
|
||||||
const canvas = within(canvasElement)
|
const canvas = within(canvasElement as HTMLElement)
|
||||||
const loginButton = await canvas.getByRole('button', {
|
const loginButton = canvas.getByRole('button', {
|
||||||
name: /Log in/i,
|
name: /Log in/i,
|
||||||
})
|
})
|
||||||
await userEvent.click(loginButton)
|
await userEvent.click(loginButton)
|
||||||
|
|||||||
6
types/vue.d.ts
vendored
6
types/vue.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
import Vue from 'vue'
|
||||||
const Component: any
|
|
||||||
export default Component
|
export default Vue
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user