Vampire
09/13/2024, 1:58 AMOutgoingHttpHeaders used to be typealias OutgoingHttpHeaders = Dict, so it was used like
additionalHeaders = recordOf(
"Content-Type" to "application/x-www-form-urlencoded",
"User-Agent" to "Setup WSL GitHub Action"
)
how do you do it now that it is a sealed external interface OutgoingHttpHeaders : Dict?
Like this?
additionalHeaders = jso {
set("Content-Type", "application/x-www-form-urlencoded")
this["User-Agent"] = "Setup WSL GitHub Action"
}Vampire
09/13/2024, 2:21 AMnode.http.IncomingMessage.statusCode which used to be Number? now is Double??
I had if (response.message.statusCode != 200) which now does not compile anymore.Vampire
09/13/2024, 2:43 AMProcess.exit you now have to give String or Double as argument, when before it was Number, so process.exit(1) does no longer compilehfhbd
09/13/2024, 6:51 AMVampire
09/13/2024, 7:28 AMhfhbd
09/13/2024, 7:29 AMhfhbd
09/13/2024, 7:31 AMVampire
09/13/2024, 7:33 AMVampire
09/13/2024, 7:42 AMhfhbd
09/13/2024, 7:45 AMhfhbd
09/13/2024, 7:46 AMval requestOptions = RequestOptions(maxRetries = 3)hfhbd
09/13/2024, 7:46 AMVampire
09/13/2024, 9:21 AMJsPlainObject, it is just missing on OutgoingHttpHeaders, I see, thanks.
Besides that it would not actually help in my case, as user-agent is only there as comment and content-type not even as comment. π
So even if it had JsPlainObject I would need to use jso { ... } in my case.
Which jso line do you think is more idiomatic?
The set(..., ...) or the this[...] = ...?
Or is there another option I'm not aware of?hfhbd
09/13/2024, 9:27 AMVampire
09/13/2024, 9:33 AMturansky
09/13/2024, 10:00 AM2.1.0 we will generate missed accessors for properties like thisturansky
09/13/2024, 10:01 AMadditionalHeaders = jso {
contentType = "application/x-www-form-urlencoded"
userAgent = "Setup WSL GitHub Action"
}turansky
09/13/2024, 10:01 AMadditionalHeaders = OutgoingHttpHeaders(
contentType = "application/x-www-form-urlencoded"
userAgent = "Setup WSL GitHub Action"
)Vampire
09/13/2024, 10:02 AMturansky
09/13/2024, 10:22 AMVampire
09/13/2024, 10:23 AMturansky
09/13/2024, 10:23 AMOutgoingHttpHeadersturansky
09/13/2024, 10:23 AMVampire
09/13/2024, 10:24 AMVampire
09/13/2024, 10:24 AMturansky
09/13/2024, 10:25 AMvar OutgoingHttpHeaders.contentType: String
get() = asDynamic()["content-type"]
set(value) {
asDynamic()["content-type"] = value
}
and so onturansky
09/13/2024, 10:25 AMOutgoingHttpHeaders.ext.ktVampire
09/13/2024, 10:27 AMturansky
09/13/2024, 10:27 AM2.1.0 isn't releasedVampire
09/13/2024, 10:34 AMnode.fs.writeFile?
It used to be
suspend fun writeFile(
file: PathLike, /* | FileHandle */
data: Any, /* string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream */
options: WriteFileOptions,
)
and I used it like
writeFile(assetFilePath, asset.source, jso<WriteFileOptions> {
mode = asset.permissions
})
where assetFilePath is String and asset.source is node.buffer.Buffer.
Now writeFile got split into multiple signatures,
but none accepts Buffer as data,
WriteFileOptions does not accept mode anymore,
and "Type argument is not within its bounds. Expected: Any Found: WriteFileOptions /* = Any? */" :-/Vampire
09/13/2024, 10:35 AMWriteFileAsyncOptions while the old one is still there but just an alias for Any?. o_OVampire
09/13/2024, 10:36 AMWriteFileOptions is still there or a bug?
And should there be an overload accepting Buffer or do I need to transform it somehow?Vampire
09/13/2024, 10:45 AMBuffer should implement ArrayBufferView if I'm not mistakenturansky
09/13/2024, 10:51 AMBuffer in child types πVampire
09/13/2024, 10:52 AMVampire
09/13/2024, 10:54 AMturansky
09/13/2024, 10:55 AMBuffer implements both π§Vampire
09/13/2024, 11:01 AMVampire
09/13/2024, 11:01 AMVampire
09/13/2024, 11:03 AMasset.source as ArrayBufferView an "Unchecked cast to external interface: Buffer to ArrayBufferView" ?turansky
09/13/2024, 11:10 AMCan there be anything done in the wrappers about it, or do I need to cast?Do you mean in Kotlin? π
turansky
09/13/2024, 11:11 AMHm, and why isNo runtime = no cast πan "Unchecked cast to external interface: Buffer to ArrayBufferView" ?asset.source as ArrayBufferView
Vampire
09/13/2024, 11:12 AMasset.source.unsafeCast<ArrayBufferView>(), correct?Edoardo Luppi
09/13/2024, 11:12 AMIf you use Kotlin 2.0.20, afaik, you should be able to use JsPlainObjectsNope, the plugin has to be bundled with the IDEA distribution first. Otherwise you'll see errors in K2 mode.
turansky
09/13/2024, 11:14 AMasset.source.let<ArrayBufferView> { it }turansky
09/13/2024, 11:15 AMunsafeCast isn't recommended π€¨Edoardo Luppi
09/13/2024, 11:16 AMSo unless we have union types, I need to doA workaround would be renaming the named parameter. Specifying the argument name would then get rid of the ambiguity., correct?asset.source.unsafeCast<ArrayBufferView>()
isn't recommendedunsafeCast
unsafeCast-ing is still the best approach in certain scenarios. I don't like going down the route of using overly complex solution for a simple cast.Vampire
09/13/2024, 11:17 AMasset.source.let<ArrayBufferView> { it } does not compile, it would be
asset.source.let<ArrayBufferView, ArrayBufferView> { it }.
And for that you then get "Redundant 'let' call could be removed" :-/Edoardo Luppi
09/13/2024, 11:18 AMunsafeCast. It's there for this exact reasonEdoardo Luppi
09/13/2024, 11:18 AMunsafeCast in a more appropriately named function.Vampire
09/13/2024, 11:23 AMasset.source.run<ArrayBufferView, ArrayBufferView> { this } does not have an IJ finding tough πturansky
09/13/2024, 11:23 AMasset.source.run<_, ArrayBufferView> { this } ?Edoardo Luppi
09/13/2024, 11:24 AMturansky
09/13/2024, 11:25 AMVampire
09/13/2024, 11:25 AMval Buffer.asArrayBufferView: ArrayBufferView get() = run { this }Vampire
09/13/2024, 11:26 AMasset.source.asArrayBufferViewturansky
09/13/2024, 11:27 AMrun is redundantVampire
09/13/2024, 11:28 AMval Buffer.asArrayBufferView: ArrayBufferView get() = this, now we become pretty finally πVampire
09/13/2024, 11:28 AMturansky
09/13/2024, 11:29 AM<http://asset.source.as|asset.source.as><ArrayBufferView>() with as in wrappersturansky
09/13/2024, 11:29 AMunsafeCast on reviews πturansky
09/13/2024, 11:30 AMVampire
09/13/2024, 11:31 AMI might be blind, where is it? IJ doesn't want to find itwith<http://asset.source.as|asset.source.as><ArrayBufferView>()in wrappersas
Edoardo Luppi
09/13/2024, 11:32 AMunsafeCast over creating additional functions, which seems unnecessary to me.
With unsafeCast you're making your intent clear, that is, I'm casting it to that type because I'm confident in what I'm doingturansky
09/13/2024, 11:32 AMVampire
09/13/2024, 11:32 AMVampire
09/13/2024, 11:33 AMunsafeCast, is it?turansky
09/13/2024, 11:33 AMWhat I meant is I prefer to useUnnecessary type checking?over creating additional functions, which seems unnecessary to me.unsafeCast
turansky
09/13/2024, 11:33 AMBut that's then not different fromit will check types, is it?unsafeCast
Vampire
09/13/2024, 11:34 AMturansky
09/13/2024, 11:34 AMsafeCast() πEdoardo Luppi
09/13/2024, 11:35 AMBuffer is indeed an ArrayBufferView.
In this specific case, casting is performed to avoid the overload ambiguity.Vampire
09/13/2024, 11:38 AMas is of course a keywordVampire
09/13/2024, 11:38 AMfun <T> T.safeCast(): T = this it is and then asset.source.safeCast<ArrayBufferView>()Vampire
09/13/2024, 11:40 AMadditionalHeaders = jso {
this["Content-Type"] = "application/x-www-form-urlencoded"
this["User-Agent"] = "Setup WSL GitHub Action"
}
indeed did not work πEdoardo Luppi
09/13/2024, 12:08 PMval additionalHeaders = jso<Record<String, String>> {
this["Content-Type"] = "application/x-www-form-urlencoded"
this["User-Agent"] = "Setup WSL GitHub Action"
}
Starting from 2.1.0, you'll be able to create a function like
record {
`Content-Type` = "application/x-www-form-urlencoded"
`User-Agent` = "Setup WSL GitHub Action"
}turansky
09/13/2024, 8:13 PMturansky
09/13/2024, 8:51 PMOutgoingHttpHeaders fixed πturansky
09/13/2024, 10:15 PMupcast extension on board!Vampire
09/14/2024, 2:22 PM