diff --git a/lib/typelizer/dsl.rb b/lib/typelizer/dsl.rb index ff0ce67..2b6d6aa 100644 --- a/lib/typelizer/dsl.rb +++ b/lib/typelizer/dsl.rb @@ -64,7 +64,7 @@ def assign_type_information(attribute_name, attributes) unless respond_to?(attribute_name) define_singleton_method(attribute_name) do - result = instance_variable_get(instance_variable) + result = instance_variable_get(instance_variable) || {} if superclass.respond_to?(attribute_name) result.merge(superclass.send(attribute_name)) else diff --git a/spec/__snapshots__/AlbaUserEmptyNested.ts.snap b/spec/__snapshots__/AlbaUserEmptyNested.ts.snap new file mode 100644 index 0000000..57a4cb0 --- /dev/null +++ b/spec/__snapshots__/AlbaUserEmptyNested.ts.snap @@ -0,0 +1,14 @@ +// Typelizer digest 1002a651beda81fd3d91636e80542552 +// +// DO NOT MODIFY: This file was automatically generated by Typelizer. +import type {AlbaPost} from '@/types' + +type AlbaUserEmptyNested = { + id: number; + username: string | null; + posts?: Array; + avatar: unknown; + typed_avatar: string | null; +} + +export default AlbaUserEmptyNested; diff --git a/spec/__snapshots__/AmsUserEmptyNested.ts.snap b/spec/__snapshots__/AmsUserEmptyNested.ts.snap new file mode 100644 index 0000000..3c6d503 --- /dev/null +++ b/spec/__snapshots__/AmsUserEmptyNested.ts.snap @@ -0,0 +1,14 @@ +// Typelizer digest 8c962041f6d8142284309a7a7695ccff +// +// DO NOT MODIFY: This file was automatically generated by Typelizer. +import type {AmsPost} from '@/types' + +type AmsUserEmptyNested = { + id: number; + username: string | null; + avatar: unknown; + typed_avatar: string | null; + posts?: Array; +} + +export default AmsUserEmptyNested; diff --git a/spec/__snapshots__/OjSerializersUserEmptyNested.ts.snap b/spec/__snapshots__/OjSerializersUserEmptyNested.ts.snap new file mode 100644 index 0000000..cf27da9 --- /dev/null +++ b/spec/__snapshots__/OjSerializersUserEmptyNested.ts.snap @@ -0,0 +1,14 @@ +// Typelizer digest 792747cc9a6687f61568633186ee265d +// +// DO NOT MODIFY: This file was automatically generated by Typelizer. +import type {OjSerializersPost} from '@/types' + +type OjSerializersUserEmptyNested = { + id: number; + username: string | null; + posts?: Array; + avatar: unknown; + typed_avatar: string | null; +} + +export default OjSerializersUserEmptyNested; diff --git a/spec/__snapshots__/index.ts.snap b/spec/__snapshots__/index.ts.snap index 98c2387..7bd9bca 100644 --- a/spec/__snapshots__/index.ts.snap +++ b/spec/__snapshots__/index.ts.snap @@ -1,4 +1,4 @@ -// Typelizer digest b30b67423d9475d4fb19db422c52a55f +// Typelizer digest 22ff4b5bc8af67e16ccf03d2d3b8aad2 // // DO NOT MODIFY: This file was automatically generated by Typelizer. export type { default as AlbaInline } from './AlbaInline' @@ -7,17 +7,20 @@ export type { default as AlbaMeta } from './AlbaMeta' export type { default as AlbaPoro } from './AlbaPoro' export type { default as AlbaPost } from './AlbaPost' export type { default as AlbaUserAuthor } from './AlbaUserAuthor' +export type { default as AlbaUserEmptyNested } from './AlbaUserEmptyNested' export type { default as AlbaUser } from './AlbaUser' export type { default as AlbaUserSerializerFoo } from './AlbaUserSerializerFoo' export type { AlbaVerbatimModuleSyntax } from './AlbaVerbatimModuleSyntax' export type { default as AmsPost } from './AmsPost' export type { default as AmsUserAuthor } from './AmsUserAuthor' +export type { default as AmsUserEmptyNested } from './AmsUserEmptyNested' export type { default as AmsUser } from './AmsUser' export type { default as AmsUserSerializerFoo } from './AmsUserSerializerFoo' export type { AmsVerbatimModuleSyntax } from './AmsVerbatimModuleSyntax' export type { default as OjSerializersFlatUser } from './OjSerializersFlatUser' export type { default as OjSerializersPost } from './OjSerializersPost' export type { default as OjSerializersUserAuthor } from './OjSerializersUserAuthor' +export type { default as OjSerializersUserEmptyNested } from './OjSerializersUserEmptyNested' export type { default as OjSerializersUser } from './OjSerializersUser' export type { default as OjSerializersUserSerializerFoo } from './OjSerializersUserSerializerFoo' export type { OjSerializersVerbatimModuleSyntax } from './OjSerializersVerbatimModuleSyntax' diff --git a/spec/app/app/serializers/alba/user/empty_nested_serializer.rb b/spec/app/app/serializers/alba/user/empty_nested_serializer.rb new file mode 100644 index 0000000..1657656 --- /dev/null +++ b/spec/app/app/serializers/alba/user/empty_nested_serializer.rb @@ -0,0 +1,6 @@ +module Alba + module User + class EmptyNestedSerializer < AuthorSerializer + end + end +end diff --git a/spec/app/app/serializers/ams/user/empty_nested_serializer.rb b/spec/app/app/serializers/ams/user/empty_nested_serializer.rb new file mode 100644 index 0000000..40301a8 --- /dev/null +++ b/spec/app/app/serializers/ams/user/empty_nested_serializer.rb @@ -0,0 +1,6 @@ +module Ams + module User + class EmptyNestedSerializer < AuthorSerializer + end + end +end diff --git a/spec/app/app/serializers/oj_serializers/user/empty_nested_serializer.rb b/spec/app/app/serializers/oj_serializers/user/empty_nested_serializer.rb new file mode 100644 index 0000000..dcaf222 --- /dev/null +++ b/spec/app/app/serializers/oj_serializers/user/empty_nested_serializer.rb @@ -0,0 +1,6 @@ +module OjSerializers + module User + class EmptyNestedSerializer < AuthorSerializer + end + end +end