Comments (4)
@NfNitLoop yes that would be great. Also, a clear description of the problem would make it easier for me to solve.
from protoc-gen-ts.
Just adding some extra detail to this ticket for why strict mode is important.
Currently if you have a proto like:
message Example {
oneof foo_or_bar {
Foo foo = 1;
Bar bar = 2;
}
}
then the Example
type will get generated with:
get foo(): Foo {
return pb_1.Message.getWrapperField(this, Foo, 1) as Foo;
}
This advertises that Foo is unconditionally available, but in fact sometimes it can be undefined
.
I've been confused a couple times when my TypeScript code ran into undefined
values that shouldn't have been possible according to annotated types. :)
from protoc-gen-ts.
You are definitely right about this. getters
should be annoted as possibly return undefined cause they are optional. May be we could leverage a feature of typescript which could be some kind of "optional chaining feature" designed for "return" statements. Or maybe we could just use Type | undefined | null
as type annotation.
I'm not sure what we should use.
from protoc-gen-ts.
Ah, I saw that this issue was closed, so I thought the as Foo
(vs. as Foo|undefined
) issue had been fixed. But I guess the main bug here was different.
Should I open a separate issue for the Foo
vs. Foo|undefined
type problem?
(Unrelated: I'm using the generated code in Deno (with a very small manual update) and it seems to be working well so far!)
from protoc-gen-ts.
Related Issues (20)
- Generation with target=web HOT 3
- Cannot use ‘in’ operator to search for ‘Array’ in undefined; HOT 2
- Get `Error: EAGAIN: resource temporarily unavailable, read` when maybe many files are specified as input HOT 1
- Support Promises in Server Definition
- npm package needs publishing to include fix for typescript >= 5 HOT 8
- The namespace 'Google protobuf' does not have an exported member 'BinaryWriter' HOT 1
- `toObject()` inferred type too long when compiled with `declaration: true` HOT 1
- More fleshed out example
- Proto with oneof and other field is generated as union instead of intersect
- `Property 'xy' of type 'z' is not assignable to 'string' index type 'UntypedHandleCall'.` for class properties
- Add `as const` to UnimplementedService definition
- TSC error with compiler option noUnusedLocals HOT 2
- import_style=es6 ? HOT 1
- Consuming JSON For Tests and Converting To Protoc HOT 1
- I need to generate file interface IUser {} HOT 3
- Property 'Buffer' does not exist on type 'typeof globalThis' HOT 2
- [rust] Error starting the proto build with new rust wasm package. Error when executing /usr/bin/protoc-gen-ts HOT 1
- [rust] proto3 optional fields support
- methodName conflict HOT 1
- snake_case to camelCase conversion HOT 7
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 protoc-gen-ts.