Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions spec/types_from_serializers/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,21 @@ def generate_serializers

expect(ts_type).to eq(:string)
end

it "maps json type from SQL to object type in TypeScript" do
db_type = :json

ts_type = TypesFromSerializers.config.sql_to_typescript_type_mapping[db_type]

expect(ts_type).to eq("Record<string, any>")
end

it "maps jsonb type from SQL to object type in TypeScript" do
db_type = :jsonb

ts_type = TypesFromSerializers.config.sql_to_typescript_type_mapping[db_type]

expect(ts_type).to eq("Record<string, any>")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ def default_config(root)
string: :string,
text: :string,
citext: :string,
json: "Record<string, any>",
jsonb: "Record<string, any>",
}.tap do |types|
types.default = :unknown
end,
Expand Down
Loading