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

Improve typing #102

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
69ad545
Add sorbet and tapioca as development dependencies
TobiasBales Jul 3, 2024
ec499d2
Add extend T::Sig to enums
TobiasBales Jul 3, 2024
6e8b8fb
Generate type signatures for oneof setters
TobiasBales Jul 3, 2024
4cce8b1
Make Enum.lookup and Enum.resolve return nilable types
TobiasBales Jul 3, 2024
16f79d1
Add type shims to work around String#getbyte returning T.nilable
TobiasBales Jul 3, 2024
f58e18f
Type oneof sub-fields as nilable in the constructor
TobiasBales Jul 3, 2024
5ef080a
Remove unneeded assignments during encoding
TobiasBales Jul 3, 2024
375440b
Drop oneof enums from typed test
TobiasBales Jul 4, 2024
d76f702
Initialize optional fields in a way that sorbet can derive types corr…
TobiasBales Jul 4, 2024
20c75ee
Fix argument types for optional and array fields
TobiasBales Jul 4, 2024
c5be5fd
Set optional fields to default value when nil is passed in
TobiasBales Jul 8, 2024
a93ecba
Generate code that is typed: strict
TobiasBales Jul 8, 2024
e7f48fa
Initialize ivar types for bitmask, optional and required fields
TobiasBales Jul 8, 2024
3754858
Initialize ivar types for oneof fields
TobiasBales Jul 8, 2024
0852c49
Generate oneof discriminator field types as nilable
TobiasBales Jul 8, 2024
88dfd1b
Force non nilable ivars for optional fields
TobiasBales Jul 8, 2024
5005e54
Correctly initialize byte (for sorbet) while encoding lists and maps
TobiasBales Jul 8, 2024
1cd4c74
Run sorbet tc to check generated types
TobiasBales Jul 8, 2024
5bfdc3b
Change oneof value to int in typed codegen test
TobiasBales Jul 8, 2024
ff3faff
Fix optional oneof fields bounds checks
TobiasBales Jul 8, 2024
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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ gem "rake"
gem "minitest"
gem "benchmark-ips"
gem "syntax_tree"
gem 'sorbet'
gem 'sorbet-runtime'
gem 'tapioca'
27 changes: 27 additions & 0 deletions bin/srb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'srb' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("sorbet", "srb")
27 changes: 27 additions & 0 deletions bin/srb-rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'srb-rbi' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("sorbet", "srb-rbi")
27 changes: 27 additions & 0 deletions bin/tapioca
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("tapioca", "tapioca")
Loading
Loading