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

add type alias to toObject method to prevent from inferred type too long error when compiling #232

Closed
wants to merge 2 commits into from

Conversation

Yo-mah-Ya
Copy link

fixes #231

@Yo-mah-Ya Yo-mah-Ya changed the title Define types add type alias to toObject method to prevent from inferred type too long error when compiling Oct 7, 2023
Comment on lines +2270 to +2279
const objectTypeName = `ObjectTypeFor${parentName}${descriptor.name}`;
const statements: ts.Statement[] = [
createMessage(rootDescriptor, descriptor, pbIdentifier, parentName),
ts.factory.createTypeAliasDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
ts.factory.createIdentifier(objectTypeName),
undefined,
createPrimitiveMessageSignature(rootDescriptor, descriptor),
),
createMessage(rootDescriptor, descriptor, pbIdentifier, parentName, objectTypeName),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type of toObject and the parameter of fromObject are supposed to be compatible.

Aside from preventing from duplicated source codes, we might wanna use only object type other than protocol Buffer. For example, this open source project, which provides PostgreSQL parser, uses .proto file as a common language across several languages. So we actually need only data types corresponding to .proto file, instead of serializing/deserializing Protocol buffer and whatnot.

@thesayyn thesayyn closed this Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toObject() inferred type too long when compiled with declaration: true
2 participants