Skip to content

Commit 29fa212

Browse files
fix: type cleanup
1 parent b03bd1f commit 29fa212

File tree

25 files changed

+70
-66
lines changed

25 files changed

+70
-66
lines changed

lib/buildtime/plugins/exporter/exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const exporter = ({ instance }) => {
1414
const createRelativePath = path => relativeUnix(instance.options.routifyDir, path)
1515

1616
const relativePaths = {
17-
routesDir: createRelativePath(instance.options.routesDir.default),
17+
routesDir: createRelativePath(instance.options.routesDir['default']),
1818
mainEntryPoint: createRelativePath(instance.options.mainEntryPoint),
1919
rootComponent: createRelativePath(instance.options.rootComponent),
2020
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @param {string | (Object.<string, string>)} input
3-
* @returns {Object.<string, string>}
2+
* @param {string | ({default: string} & Object.<string, string>)} input
3+
* @returns {{default: string} & Object.<string, string>}
44
*/
55
export const normalizeRoutesDir = input =>
66
typeof input === 'string' ? { default: input } : input

lib/buildtime/plugins/themes/themes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const createThemedRootNode = (
4545
const rootNode = instance.rootNodes[rootNodeName].deepClone()
4646
rootNode.name = name
4747
rootNode.id = '_' + name
48-
rootNode.rootName = rootNodeName + '-theme-' + name
48+
rootNode['rootName'] = rootNodeName + '-theme-' + name
4949
instance.rootNodes[rootNodeName + '-theme-' + name] = rootNode
5050
;[...themePreferenceGroups].reverse().forEach(themePreferenceGroup => {
5151
themePreferenceGroup = coerceArray(themePreferenceGroup)

lib/buildtime/plugins/themes/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ export const normalizeConfig = (config, rootNodes) => {
8383

8484
const defaultPreset = {
8585
preferences: [],
86-
namespaces: _config.defaults.namespaces,
86+
namespaces: _config.defaults['namespaces'],
8787
rootNodes,
8888
}
8989

9090
Object.keys(_config.presets).forEach(
9191
key =>
9292
(_config.presets[key] = normalizePreset(_config.presets[key], defaultPreset)),
9393
)
94-
return _config
94+
return /** @type {ThemeConfig} */ (_config)
9595
}
9696

9797
export const coerceArray = value => (Array.isArray(value) ? value : [value])

lib/common/RNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class RNode {
163163
const isNamed = !path.startsWith('/') && !path.startsWith('.')
164164
return isNamed
165165
? this.root.instance.nodeIndex.find(node => node.meta.name === path)
166-
: this.getChainTo(path, options)?.pop().node
166+
: /** @type {this} */ (this.getChainTo(path, options)?.pop().node)
167167
}
168168

169169
/**

lib/common/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const mockRoutes = (instance, routes) => {
160160
* Adds props to a Svelte component
161161
* @example
162162
* const MyCompWithProps = addPropsToComp(MyComp, {msg: 'hello world'})
163-
* @template {typeof import('svelte/internal').SvelteComponentDev} Component
163+
* @template {typeof import('svelte').SvelteComponent} Component
164164
* @param {Component} Comp
165165
* @param {Object<string, any>} props
166166
* @returns {Component}

lib/extra/tools/ssr4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ const polyfillFetch = async () => {
3030
*/
3131
export const renderModule = async (module, urlOrOptions) => {
3232
await polyfillFetch()
33-
const render = module.default?.render || module['render']
33+
const render = module['default']?.render || module['render']
3434

35-
const url = urlOrOptions.url || urlOrOptions
35+
const url = urlOrOptions['url'] || urlOrOptions
3636
const load = module.load ? await module.load(url) : {}
3737

3838
const preloadUrlLoad = await preloadUrl(urlOrOptions)

lib/extra/tools/ssr5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @ts-ignore */
12
import { render } from 'svelte/server'
23
import { preloadUrl } from '../../runtime/index.js'
34

@@ -33,14 +34,14 @@ export const renderModule = async (module, urlOrOptions) => {
3334
await polyfillFetch()
3435
// const render = module.default?.render || module['render']
3536

36-
const url = urlOrOptions.url || urlOrOptions
37+
const url = urlOrOptions['url'] || urlOrOptions
3738
const load = module.load ? await module.load(url) : {}
3839

3940
const preloadUrlLoad = await preloadUrl(urlOrOptions)
4041

4142
return {
4243
status: 200,
43-
...(await render(module.default)),
44+
...(await render(module['default'])),
4445
...load,
4546
...preloadUrlLoad?.flat()[0],
4647
}

lib/runtime/Router/Router.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ export class Router {
239239
this._setUrl(this.url.getActive(), 'pushState', true)
240240
}
241241

242+
const C = Array.isArray(urlReflector) ? urlReflector[0] : urlReflector
242243
const shouldInstallUrlReflector =
243-
!this.urlReflector ||
244-
(urlReflector && !(this.urlReflector instanceof urlReflector))
244+
!this.urlReflector || (urlReflector && !(this.urlReflector instanceof C))
245245

246246
if (shouldInstallUrlReflector) {
247247
urlReflector =
@@ -313,7 +313,7 @@ export class Router {
313313

314314
const stackedRoute = this.history.get(state.id)
315315

316-
if (stackedRoute?.meta.history) {
316+
if (stackedRoute?.meta['history']) {
317317
stackedRoute.mode = 'popState'
318318
stackedRoute.state.cached = true
319319
this.setActiveRoute(stackedRoute, null)
@@ -400,7 +400,7 @@ export class Router {
400400
const warnTimeout = setTimeout(() => {
401401
if (!route.isActive) return // don't warn if the route is no longer active
402402
const index = renderPromises.findIndex(p => !p.isResolved)
403-
const warning = `Failed to render ${route.fragments[index].node.name} (${route.fragments[index].node.file?.path}) within 5s. Ensure the parent component renders a <slot />`
403+
const warning = `Failed to render ${route.fragments[index].node.name} (${route.fragments[index].node['file']?.path}) within 5s. Ensure the parent component renders a <slot />`
404404
console.warn(warning)
405405
}, 5000)
406406

lib/runtime/helpers/preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const preloadUrlFromUrlPairs = async (urlPairs, routesMap) => {
8181
const routers = await Promise.all(routerPromises)
8282

8383
await Promise.all(routers.map(router => router && router.ready()))
84-
return routers.map(router => router.activeRoute?.get().load)
84+
return routers.map(router => router['activeRoute']?.get().load)
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)