type declarations

This commit is contained in:
Reese Armstrong 2024-08-03 17:21:56 -04:00
commit d197ddd8e7
Signed by: reesericci
GPG key ID: 86A9594B08970A4B

19
sig/lib/svelte.rbs Normal file
View file

@ -0,0 +1,19 @@
type strict_hash = Hash[Symbol, String]
type flexi_hash = Hash[Symbol | String, String]
module Svelte
self.@ssr: bool
self.@aliases: strict_hash
self.@preprocess: flexi_hash
def self.ssr: -> bool
def self.aliases: -> strict_hash
def self.preprocess: -> flexi_hash
def self.ssr=: (boolish) -> void
def self.aliases=: (strict_hash) -> void
def self.preprocess=: (flexi_hash) -> void
def self.props: -> flexi_hash
def self.gem_dir: -> String
end

21
sig/lib/svelte/errors.rbs Normal file
View file

@ -0,0 +1,21 @@
module Svelte
class CompilerError
# TODO: ActiveSupport::SyntaxErrorProxy is untyped, so this is an incomplete type definition
attr_accessor location: { file: String, line: Integer, lineText: String, suggestion: String? }
attr_accessor suggestion: String
attr_accessor template: ActionView::Template
attr_accessor message: String
def initialize: (String, ActionView::Template) -> self
def backtrace: -> Array[String]
def cause: -> nil
def binding: -> Array[Binding]
def backtrace_locations: -> Array[untyped]
def annotated_source_code: -> Array[String]
end
class TemplateError
def initialize: () -> self
end
end

View file

@ -0,0 +1,6 @@
module Svelte
class Handler
def call: (ActionView::Template, String) -> String
def self.call: (ActionView::Template, String) -> String
end
end

View file

@ -0,0 +1,6 @@
module Svelte
module Helpers
include ActionView::Helpers
def svelte_tags: -> String
end
end