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

TypeError when attempting to access property of union type #1537

Open
danaetroupe opened this issue Nov 18, 2024 · 0 comments
Open

TypeError when attempting to access property of union type #1537

danaetroupe opened this issue Nov 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@danaetroupe
Copy link

danaetroupe commented Nov 18, 2024

Previously opened an issue here trying to understand why when type is explicitly casted in codeblock, I am still getting type errors. It feels more intuitive to dismiss the error if the value is explicitly given.

--!strict

-- Example #1
type TestObj = {
	model : Model?
}

local object : TestObj = {
	model = nil
}

object.model = Instance.new("Model")
object.model.Parent = workspace  -- this line has an error

-- Example #2
local model : Model? = nil
model = Instance.new("Model")

model.Parent = workspace -- this line has an error
@danaetroupe danaetroupe added the enhancement New feature or request label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant