Originally created by @holzensp on GitHub (Nov 1, 2024).
Currently, toTyped is shallow. For example, given
class Bird {
name: String
diet: Listing<String>
}
local example: Dynamic = new {
name = "Pigeon"
diet {
"seeds"
"fast food"
}
}
succeeds = example.toTyped(Bird).name
fails = example.toTyped(Bird)
would correctly produce
succeeds = "Pigeon"
if it did not throw on fails:
–– Pkl Error ––
Expected value of type Listing, but got type Dynamic.
Value: new Dynamic { ?; ? }
3 | diet: Listing<String>
^^^^^^^^^^^^^^^
at repl#Bird.diet (repl:pkl0)
This is why deepToTyped was developed. However, toTypedshould recursively convert to the required typed structure.
By default this should retain laziness.
Originally created by @holzensp on GitHub (Nov 1, 2024).
Currently, `toTyped` is _shallow_. For example, given
```
class Bird {
name: String
diet: Listing<String>
}
local example: Dynamic = new {
name = "Pigeon"
diet {
"seeds"
"fast food"
}
}
succeeds = example.toTyped(Bird).name
fails = example.toTyped(Bird)
```
would correctly produce
```
succeeds = "Pigeon"
```
if it did not throw on `fails`:
```
–– Pkl Error ––
Expected value of type Listing, but got type Dynamic.
Value: new Dynamic { ?; ? }
3 | diet: Listing<String>
^^^^^^^^^^^^^^^
at repl#Bird.diet (repl:pkl0)
```
This is why [`deepToTyped`](https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped/current/index.html) was developed. However, `toTyped` _should_ recursively convert to the required typed structure.
By default this should retain laziness.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @holzensp on GitHub (Nov 1, 2024).
Currently,
toTypedis shallow. For example, givenwould correctly produce
if it did not throw on
fails:This is why
deepToTypedwas developed. However,toTypedshould recursively convert to the required typed structure.By default this should retain laziness.