diff --git a/types/test/v3/define-component-test.js b/types/test/v3/define-component-test.js new file mode 100644 index 00000000000..868e862c24d --- /dev/null +++ b/types/test/v3/define-component-test.js @@ -0,0 +1,20 @@ +// @ts-check +import { defineComponent } from '../../index' +import { expectError, describe } from '../utils' +const props = { + a: Number +} +describe('defineComponent prop types work in js', () => { + defineComponent({ + props, + computed: { + test() { + // @ts-expect-error Invalid typecast if `this.a` is not any + ;/** @type import('../utils').IsAny */ (this.a) + + // @ts-expect-error Unknown property + expectError(this.b) + } + } + }) +}) diff --git a/types/tsconfig.json b/types/tsconfig.json index 36c5afee057..8842b3e6a22 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -5,6 +5,7 @@ "lib": ["dom", "esnext"], "types": ["node"], "module": "esnext", + "allowJs": true, "moduleResolution": "node", "jsx": "preserve", "strict": true, @@ -14,5 +15,6 @@ } }, "include": ["."], + "files": ["./test/v3/define-component-test.js"], "compileOnSave": false } diff --git a/types/v3-define-component.d.ts b/types/v3-define-component.d.ts index 03ef52d1856..257ede3a07a 100644 --- a/types/v3-define-component.d.ts +++ b/types/v3-define-component.d.ts @@ -139,7 +139,7 @@ export function defineComponent< * see `ExtractPropTypes` in './componentProps.ts' */ export function defineComponent< - Props, + Props = unknown, RawBindings = {}, D = {}, C extends ComputedOptions = {},