Skip to content

Commit 8008509

Browse files
committed
refactor: fix type errors
1 parent fd2917c commit 8008509

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

packages/compiler-vapor/src/ir/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface BaseIRNode {
4242
type: IRNodeTypes
4343
}
4444

45-
export type CoreHelper = keyof typeof import('packages/runtime-core/src')
45+
export type CoreHelper = keyof typeof import('packages/runtime-dom/src')
4646

4747
export type VaporHelper = keyof typeof import('packages/runtime-vapor/src')
4848

packages/runtime-dom/src/modules/style.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
} from '../directives/vShow'
88
import { CSS_VAR_TEXT } from '../helpers/useCssVars'
99

10-
type Style = StyleValue | Record<string, StyleValue | StyleValue[]>
11-
type StyleValue = string | null | undefined
10+
type Style = string | null | undefined | Record<string, unknown>
1211

1312
const displayRE = /(^|;)\s*display\s*:/
1413

@@ -68,15 +67,11 @@ export function patchStyle(el: Element, prev: Style, next: Style): void {
6867
const semicolonRE = /[^\\];\s*$/
6968
const importantRE = /\s*!important$/
7069

71-
function setStyle(
72-
style: CSSStyleDeclaration,
73-
name: string,
74-
val: StyleValue | StyleValue[],
75-
) {
76-
if (isArray(val)) {
77-
val.forEach(v => setStyle(style, name, v))
70+
function setStyle(style: CSSStyleDeclaration, name: string, rawVal: unknown) {
71+
if (isArray(rawVal)) {
72+
rawVal.forEach(v => setStyle(style, name, v))
7873
} else {
79-
if (val == null) val = ''
74+
const val = rawVal == null ? '' : String(rawVal)
8075
if (__DEV__) {
8176
if (semicolonRE.test(val)) {
8277
warn(

packages/runtime-vapor/__tests__/apiSetupContext.spec.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ describe('api: setup context', () => {
7474
inheritAttrs: false,
7575
setup(_props, { attrs }) {
7676
const el = document.createElement('div')
77-
let prev: any
78-
renderEffect(() => {
79-
prev = setDynamicProps(el, [attrs], prev, true)
80-
})
77+
renderEffect(() => setDynamicProps(el, [attrs]))
8178
return el
8279
},
8380
})
@@ -113,10 +110,7 @@ describe('api: setup context', () => {
113110
const n0 = createComponent(Wrapper, null, {
114111
default: () => {
115112
const n0 = template('<div>')() as HTMLDivElement
116-
let prev: any
117-
renderEffect(() => {
118-
prev = setDynamicProps(n0, [attrs], prev, true)
119-
})
113+
renderEffect(() => setDynamicProps(n0, [attrs]))
120114
return n0
121115
},
122116
})

packages/runtime-vapor/__tests__/errorHandling.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
watch,
77
watchEffect,
88
} from '@vue/runtime-dom'
9-
import { createComponent, setRef, template } from '../src'
9+
import { createComponent, createTemplateRefSetter, template } from '../src'
1010
import { makeRender } from './_utils'
1111
import type { VaporComponent } from '../src/component'
1212
import type { RefEl } from '../src/apiTemplateRef'
@@ -229,6 +229,7 @@ describe('error handling', () => {
229229
const Child = {
230230
render() {
231231
const el = template('<div>')()
232+
const setRef = createTemplateRefSetter()
232233
setRef(el as RefEl, ref)
233234
return el
234235
},

packages/shared/src/normalizeProp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { hyphenate, isArray, isObject, isString } from './general'
22

3-
export type NormalizedStyle = Record<string, string>
3+
export type NormalizedStyle = Record<string, unknown>
44

55
export function normalizeStyle(
66
value: unknown,

0 commit comments

Comments
 (0)