Reputation: 3523
I always get this error:
Cannot reference type details_T [1] from a value position.
Here is my code:
type details_T = {
code: string, desc: string,
}
export default {
data: function () {
return {
details: details_T = { code : 'c', desc : 'd'}
};
},
msg : function() {
var s : string = 'tset'
s = 100
console.log('test')
}
};
How to fix this?
Upvotes: 0
Views: 38
Reputation: 37938
You are mixing object initialization with type annotations. If you want to annotate function's return type you can go with:
data: function (): { details: details_T } {
return {
details: { code : 'c', desc : 'd'}
};
},
Upvotes: 1