Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): no props typings in js files #13109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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