Skip to content

Commit 92ff0b5

Browse files
committed
fix(core): export validateType
1 parent e8b384a commit 92ff0b5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/core/__tests__/shim.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,3 +813,14 @@ describe('`fromType()`', () => {
813813
expect(copy.required).toBe(false)
814814
})
815815
})
816+
817+
test('API parity', () => {
818+
it('includes all methods from the full build', async () => {
819+
const fullBuild = await import('../src/index')
820+
const shimBuild = await import('../src/shim')
821+
822+
expect(Object.keys(shimBuild).sort()).toStrictEqual(
823+
Object.keys(fullBuild).sort(),
824+
)
825+
})
826+
})

packages/core/src/shim.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ export function createTypes(defs: Partial<VueTypesDefaults> = typeDefaults()) {
204204
}
205205
}
206206

207+
export function validateType<T, U>(
208+
type: T,
209+
value: U,
210+
silent = false,
211+
): string | boolean {
212+
return true
213+
}
214+
207215
/* eslint-disable no-console */
208216
if (process.env.NODE_ENV !== 'production') {
209217
config.silent === false &&

packages/docs/guide/installation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ For reference, here is the list of available entry points:
6464

6565
Vue.js does not validate components' props when used in a production build. If you're using a bundler such as Webpack or rollup, you can shrink VueTypes file size by around **70%** (minified and gzipped) by removing the validation logic while preserving the library's API methods. To achieve that result, VueTypes ships with a `vue-types/shim` module that can be used as alias in production builds.
6666

67+
::: danger NOTE
68+
Note that all validation functions in the shim version (including `validateType` and `VueTypes.validate`) always return `true`.
69+
:::
70+
6771
By just aliasing `vue-types` to `vue-types/shim`, bundlers should be able to pick the module type that fits your configuration (ES, CommonJS, ...).
6872

6973
See below for common configuration scenarios.

0 commit comments

Comments
 (0)