Vampire
09/15/2024, 3:19 PM@JsPlainObject
ignores @Deprecated
annotations?
I wanted to have one property with level HIDDEN
to have two methods, one that sets it to false
and one that sets it to true
as that changes what the handled JS lib returns and thus needs a different return type.
But with the invoke
and copy
methods by @JsPlainObject
I can just freely use the property and get not even a deprecation warning.turansky
09/15/2024, 3:26 PMVampire
09/15/2024, 3:28 PMjso { ... }
it works exactly like intendedturansky
09/15/2024, 3:29 PMVampire
09/15/2024, 3:30 PMVampire
09/15/2024, 3:35 PMERROR
or is hidden with HIDDEN
.
Wtf?Vampire
09/15/2024, 3:42 PM@Deprecated
kicks in. 😕Vampire
09/15/2024, 3:42 PMVampire
09/15/2024, 3:44 PMexternal
and then translate from one to the otherturansky
09/15/2024, 3:44 PM@Deprecated
var MyOptions.prop: String?
get() = asDynamic().prop
set(value) { asDynamic().prop = value }
Vampire
09/15/2024, 3:49 PMncc
has two modes.
If you give watch = false
(the default) you get a Promise
returned.
If you give watch = true
you instead get an object returned on which you can register two types of handlers and can close the watcher.
I always used the Promise
version so just left out the watch
parameter.
Now that I looked into your comments, I've seen again this situation and thought I try to implement it in my PR too.
So I need two separate functions with same parameters but different return type and for one watch
is fixed true
, for the other false
.
So I though I add watch
with deprecated hidden and just set it from the two separate methods, so the extension property wouldn't work here I think.
I probably have to go with two versions of the interface unless you have another great idea for me. 🙂turansky
09/15/2024, 3:51 PMturansky
09/15/2024, 3:51 PMVampire
09/15/2024, 4:05 PMturansky
09/15/2024, 4:18 PMnccWatch
is what I expectturansky
09/15/2024, 4:19 PMwatch
property - internal extension propertyturansky
09/15/2024, 4:21 PMVampire
09/15/2024, 4:27 PMturansky
09/15/2024, 4:28 PMwatch
type can be type parameterturansky
09/15/2024, 4:28 PMturansky
09/15/2024, 4:28 PMVampire
09/15/2024, 4:29 PMVampire
09/15/2024, 4:29 PMVampire
09/15/2024, 4:29 PMturansky
09/15/2024, 4:31 PM@JsName("true")
external object Watch
@JsPlainObject
external interface NccOptions<W: Watch?> {
val watch: W
}
external fun ncc(options: NccOptions<Nothing?>): Promise<CompileResult>
external fun ncc(options: NccOptions<Watch>): WatchResult
Vampire
09/15/2024, 4:32 PMturansky
09/15/2024, 4:32 PMNccOptions<out W: Watch?>
- out
should help alsoVampire
09/15/2024, 4:49 PMwatch = null
it uses the one, if I use watch = Watch
it uses the other.
But I have to set either explicitlyVampire
09/15/2024, 4:49 PMturansky
09/15/2024, 4:55 PMVampire
09/15/2024, 4:55 PMwatch
explicitly? 😕Vampire
09/15/2024, 4:56 PMturansky
09/15/2024, 4:57 PMturansky
09/15/2024, 5:00 PMturansky
09/15/2024, 5:01 PMwatch
if you will declare type parameter?turansky
09/15/2024, 5:02 PMncc(NccOptions<Void>())
?turansky
09/15/2024, 5:59 PM@JsName("true")
external object Watch
@JsPlainObject
external interface NccOptions {
// all options except `watch`
}
@JsPlainObject
external interface NccBuildOptions: NccOptions
@JsPlainObject
external interface NccWatchOptions {
val watch: Watch
}
external fun ncc(options: NccBuildOptions): Promise<BuildResult>
external fun ncc(options: NccWatchOptions): WatchResult
turansky
09/15/2024, 6:00 PMVampire
09/15/2024, 7:26 PMWill it requestif you will declare type parameter?watch
Yes, requires to givencc(NccOptions<Void>())
watch = null
.
And NccOptions<Watch>
requires to give watch = Watch
New favourite, without additional parameters:But this would then still require to declare twice that you want to watch, doesn't it? Because you will have to do
NccWatchOptions(watch = Watch)
.Vampire
09/15/2024, 7:46 PMncc()
and nccWatched()
, but now have a good way (I hope) to implement it thanks, you'll see the result in the PR.
Two more questions about the hardest part in software engineering, naming.
Maybe you have a better idea than me, I'm feeling a bit uncreative right now.
For the non-watched mode, an NccResult
is returned which has non-null code
and nullable map
and assets
.
For the watched mode the watch handler you can register gets something similar.
It is documented as having the same three fields, plus additionally err
where errors will be supplied.
Actually, in reality you either get an object that has only err
set, or one that is set like the result of non-watched execution.
Right now I have named the class NccResultWithError
, with the same fields as NccResult
, just all nullable (thus not subclass) and additionally err
nullable.
Do you have a better idea how to handle it or how to name it?
And the second thing is the thing you get returned in watched mode.
Right now I called it NccHandlerRegistry
, as you can register one watch handler and one rebuild handler.
But you can (and need to) also call close()
on it to close the watcher that is created internally.
So the NccHandlerRegistry
name does not fully apply.turansky
09/15/2024, 7:50 PMbuild
and watch
turansky
09/15/2024, 7:51 PMNccBuildOptions -> NccBuildResult
NccWatchOptions -> NccWatchResult
Vampire
09/15/2024, 7:53 PMturansky
09/15/2024, 7:54 PMSo I think I'm back toThis variant will be hard in support, when more watch options will be addedandncc()
nccWatched()
turansky
09/15/2024, 7:55 PMturansky
09/15/2024, 7:56 PMncc
callturansky
09/15/2024, 7:58 PMVampire
09/15/2024, 8:16 PMncc()
or ncc(NccOptions(...))
or ncc(NccWatchOptions(...))
without a consumer-facing watch
property. 🙂Vampire
09/15/2024, 8:17 PMNccWatchResult
for the thing with err
, or for the thing where you register the handlers and close the watcher?
I guess for the former one, any idea for the latter?turansky
09/15/2024, 8:33 PMinterface NccBuildResult {
val err?
}
interface NccBuildSuccessResult :
NccBuildResult {
val code
val map
val assets
}
interface NccBuildErrorResult :
NccBuildResult {
val err
}
Vampire
09/15/2024, 8:38 PMis
, can you?Vampire
09/15/2024, 8:41 PMerr
.
The non-watched call always gets code
, map?
, assets?
.
The handler you can register for the watched call is documented to get err
, code
, map
, assets
but actually is either getting err
or code
, map?
, assets?
Vampire
09/15/2024, 8:42 PM