mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
fix: add more types (#16)
This commit is contained in:
parent
799e872b80
commit
fc0934dd0c
@ -5,7 +5,8 @@ import Hookable, { configHooksT } from 'hookable'
|
||||
import { tryImport, resolvePath, detectTarget, extendTarget } from './utils'
|
||||
import * as TARGETS from './targets'
|
||||
|
||||
export type UnresolvedPath = string | ((SLSOptions) => string)
|
||||
// eslint-disable-next-line
|
||||
export type UnresolvedPath = string | ((config: SLSOptions) => string)
|
||||
|
||||
export interface Nuxt extends Hookable{
|
||||
options: NuxtOptions
|
||||
@ -45,17 +46,24 @@ export interface SLSConfig extends Omit<Partial<SLSOptions>, 'targetDir'> {
|
||||
targetDir?: UnresolvedPath
|
||||
}
|
||||
|
||||
export type SLSTargetFn = (SLSConfig) => SLSConfig
|
||||
export type SLSTargetFn = (config: SLSConfig) => SLSConfig
|
||||
export type SLSTarget = SLSConfig | SLSTargetFn
|
||||
|
||||
export function getoptions (nuxt: Nuxt): SLSOptions {
|
||||
interface SLSNuxt extends Nuxt {
|
||||
options: Nuxt['options'] & {
|
||||
generate: Nuxt['options']['generate'] & {
|
||||
staticAssets: string[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getoptions (nuxt: SLSNuxt): SLSOptions {
|
||||
const defaults: SLSConfig = {
|
||||
rootDir: nuxt.options.rootDir,
|
||||
buildDir: nuxt.options.buildDir,
|
||||
publicDir: nuxt.options.generate.dir,
|
||||
routerBase: nuxt.options.router.base,
|
||||
fullStatic: nuxt.options.target === 'static' && !nuxt.options._legacyGenerate,
|
||||
// @ts-ignore
|
||||
staticAssets: nuxt.options.generate.staticAssets,
|
||||
|
||||
outName: '_nuxt.js',
|
||||
|
@ -30,7 +30,7 @@ export default <Module> function slsModule () {
|
||||
nuxt.addHooks(options.nuxtHooks)
|
||||
}
|
||||
|
||||
nuxt.hook('generate:cache:ignore', (ignore) => {
|
||||
nuxt.hook('generate:cache:ignore', (ignore: string[]) => {
|
||||
ignore.push(options.slsDir)
|
||||
ignore.push(options.targetDir)
|
||||
ignore.push(...options.generateIgnore)
|
||||
|
@ -23,7 +23,7 @@ export function serializeTemplate (contents: string) {
|
||||
return `export default (params) => \`${contents.replace(/{{ (\w+) }}/g, '${params.$1}')}\``
|
||||
}
|
||||
|
||||
export async function writeFileP (path, contents) {
|
||||
export async function writeFileP (path: string, contents: string) {
|
||||
await mkdirp(dirname(path))
|
||||
await writeFile(path, contents)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user