tcomb版本:3.2.25
import tcomb from "tcomb"
const typeCheck = tcomb.struct({
name: tcomb.String,
uuid: tcomb.String
})
const foo = ( userGroup: typeCheck ) => {
// do stuff
}
const x = {
name: "Joe",
uuid: "test-test"
}
foo( x )
引发此错误:
TypeError:[tcomb]无效值{ “ name”:“ Joe”, “ uuid”:“测试-测试” }提供给userGroup(预期为结构{名称:字符串,uuid:字符串})
如果我执行以下操作,它将起作用:
const foo = ( userGroup ) => {
typeCheck( userGroup )
// do stuff
}
我在做什么错了?