Comments (2)
It's been some time since I used vue. To be honest, TypeScript appears to be an afterthought...
Use the syntax described here: https://vuejs.org/v2/guide/typescript.html#Annotating-Props
Instead of "ComplexMessage", use your "ReportOption". ReportOption is a simple interface just like ComplexMessage.
import { ReportOption } from '@company/api-client';
// ...
props: {
value: {
required: true,
type: Object as PropType<ReportOption>,
}
}
I am not sure why they recommend to cast as PropType. I don't see any benefit.
Iยดd take a look at Class-Style components. Seem to be a better match for TypeScript:
https://vuejs.org/v2/guide/typescript.html#Class-Style-Vue-Components
from protobuf-ts.
Thanks for the tip - still doesn't seem to be working though. I opened an issue on the @vue/composition-api project for this. I thought my understanding of the types generated from this package may have been lacking, I haven't run into this issue with other types I've built components around, but even trying the ComplexMessage
example you linked to seems to be failing.
I've built multiple apps using the Class Style in Vue, but I'm trying to build my next app with the new Composition API. There are limits/quirks of the Class Style that I hope to be resolved with Vue 3 being written in TypeScript - no longer making it an afterthought.
The compiler error:
No overload matches this call.
Overload 1 of 3, '(options: ComponentOptionsWithoutProps<unknown, unknown, Data, {}, {}>): VueProxy<unknown, unknown, Data, {}, {}>', gave the following error.
Type '{ value: { required: true; type: PropType<ReportOption>; }; }' is not assignable to type 'undefined'.
Overload 2 of 3, '(options: ComponentOptionsWithArrayProps<string, Data, Data, {}, {}, Readonly<{ [x: string]: any; }>>): VueProxy<Readonly<{ [x: string]: any; }>, Data, Data, {}, {}>', gave the following error.
Type '{ value: { required: true; type: PropType<ReportOption>; }; }' is not assignable to type 'string[]'.
Object literal may only specify known properties, but 'value' does not exist in type 'string[]'. Did you mean to write 'values'?
Overload 3 of 3, '(options: ComponentOptionsWithProps<ComponentPropsOptions<Data>, Data, Data, {}, {}, ({ [x: number]: string; } & { length?: number | undefined; toString?: string | undefined; ... 29 more ...; flat?: unknown[] | undefined; }) | ({} & { ...; })>): VueProxy<...>', gave the following error.
Type '{ value: { required: true; type: PropType<ReportOption>; }; }' is not assignable to type 'string[] | ComponentObjectPropsOptions<Data> | undefined'.
Types of property 'value' are incompatible.
Type '{ required: true; type: PropType<ReportOption>; }' is not assignable to type '(new (...args: string[]) => Function) | PropOptions<unknown, unknown> | (new (...args: any[]) => object) | (() => unknown) | PropConstructor<unknown>[] | null | undefined'.
Types of property 'type' are incompatible.
Type 'PropType<ReportOption>' is not assignable to type 'true | (new (...args: string[]) => Function) | (new (...args: any[]) => object) | (() => unknown) | PropConstructor<unknown>[] | null | undefined'.
Type 'new (...args: never[]) => ReportOption & object' is not assignable to type 'true | (new (...args: string[]) => Function) | (new (...args: any[]) => object) | (() => unknown) | PropConstructor<unknown>[] | null | undefined'.
Type 'new (...args: never[]) => ReportOption & object' is not assignable to type 'new (...args: string[]) => Function'.
Types of parameters 'args' and 'args' are incompatible.
Type 'string' is not assignable to type 'never'.
from protobuf-ts.
Related Issues (20)
- unused parameters in the empty.ts are causing TypeScript check errors HOT 6
- Global `Object` is not referenced when there is a message named Object. HOT 2
- Proto2 required fields are not serialized when they are the default value HOT 3
- Is this compiling error could be turned off by Typescript or Option in protobuf-ts HOT 2
- 2.9.2 not working with 'exactOptionalPropertyTypes: true' HOT 1
- Release 2.9.3 breaks serialization for me HOT 6
- Generated message classes cannot be subclassed because of missing 'export' HOT 1
- Error decoding from binary: "cant skip wire type 4" HOT 1
- How to debug INVALID_ARGUMENT? HOT 1
- Missing headers on RPCError HOT 8
- rpcError cannot support Chinese
- [Request] Flag to handle google wrapper types HOT 1
- Vite cannot found module HOT 2
- Invalid typescript in descriptor.ts HOT 2
- Can't retry request after awaiting response HOT 2
- Typesafe API to retrieve enums from strings HOT 4
- `output_javascript` no longer emits `.d.ts` files HOT 6
- Request: Support for moduleResolution "nodenext" and "node16" HOT 2
- Fails to download v27.0-rc1 (which was just released) HOT 7
- invalid url for latest v27.0-rc1 release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf-ts.