Open
Description
Version
2.5.22
Reproduction link
https://jsfiddle.net/keegan_openbay/gehkx7pf/10/
https://jsfiddle.net/keegan_openbay/018rs3ae/11/
(More explanation in the fiddle, but keep in mind that JSFiddle doesn't show TS errors)
Steps to reproduce
- Declare a prop of type
Function
, and with a default function that returns some value; e.g.,
// ...
props: {
fooFn: {
type: Function,
default: () => true,
},
},
// ...
- Try to use that function elsewhere in your component options; e.g.,
// ...
methods: {
useFooFn(): void {
const bar = this.fooFn();
// ...
},
},
// ...
What is expected?
type FooFn = typeof this.fooFn; // Function
this.fooFn(); // no errors
What is actually happening?
type FooFn = typeof this.fooFn; // boolean | Function
this.fooFn();
// Cannot invoke an expression whose type lacks a call signature.
// Type 'boolean | Function' has no compatible call signatures.
Vue version: 2.5.22
TypeScript version: 3.0.3
tsconfig.json:
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es7", "dom"],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"baseUrl": "./app/javascript",
"noImplicitThis": true
},
"include": [
"app/javascript/**/*.ts",
"app/javascript/**/*.tsx",
"app/javascript/**/*.vue"
],
"exclude": [
"**/*.spec.ts",
"node_modules"
],
"compileOnSave": false
}