Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions types/test/v3/define-component-test.js
Original file line number Diff line number Diff line change
@@ -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<typeof this.a> */ (this.a)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this.a is any this conversion wouldn't result in an error


// @ts-expect-error Unknown property
expectError(this.b)
}
}
})
})
2 changes: 2 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["dom", "esnext"],
"types": ["node"],
"module": "esnext",
"allowJs": true,
"moduleResolution": "node",
"jsx": "preserve",
"strict": true,
Expand All @@ -14,5 +15,6 @@
}
},
"include": ["."],
"files": ["./test/v3/define-component-test.js"],
"compileOnSave": false
}
2 changes: 1 addition & 1 deletion types/v3-define-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function defineComponent<
* see `ExtractPropTypes` in './componentProps.ts'
*/
export function defineComponent<
Props,
Props = unknown,
RawBindings = {},
D = {},
C extends ComputedOptions = {},
Expand Down