Slackbot
09/09/2021, 11:40 AMleandro
09/10/2021, 7:56 PM@Test fun `on zero throws`() {
assertFailsWith<ArithmeticException> {
1 / 0
}
}
it fails with the following message “AssertionError: Expected an exception of class ArithmeticException to be thrown, but was completed successfully.”andylamax
09/11/2021, 11:08 AM@file:JsExports
external interface ServiceConfiguration {
var appId: String
var debug: Boolean?
}
fun service(config: ServiceConfiguration)
Yields the following typescript declaration (code out of this context is redacted): [Snippet 2]
type Nullable<T> = T | undefined | null
export interface ServiceConfiguration {
appId: string;
debug: Nullable<boolean> // want this to be optionally provided
}
export function service(config: ServiceConfiguration);
After importing this bundled library in typescript, calling [Snippet 3]
const service = service({ appId: "<app-id>" }) // troubles the ts compiler
The compiler expects both arguments like so [Snippet 4]
const service1 = service({ appId: "<app-id>", debug: undefined }) // ts compiler is happy
const service2 = service({ appId: "<app-id>", debug: true }) // ts compiler still happy
Question is, how do I make the kotlin compiler to generate [Snippet 5]
export interface ServiceConfiguration {
appId: string;
debug?: boolean // want this to be optionally provided
}
instead of the one being generated on [Snippet 2].
So that I may use it as written in [Snippet 3]?Nikola Milovic
09/11/2021, 8:41 PMandylamax
09/13/2021, 9:43 AM./gradlew jsTest --tests integration.*
Throws with
Unknown command-line option '--tests'.
./gradlew jsBrowserTest --tests integration.*
runs all the tests (does not filter)
./gradlew jsNodeTest --tests integration.*
runs all the tests (does not filter)Chukwukammadu Anizoba
09/13/2021, 11:11 AMPitel
09/13/2021, 1:00 PM-Xir-property-lazy-initialization
? I thought the lazy init is exeprimental, and stuff might broke with it, not without it. 🤡Reuben F
09/14/2021, 11:45 AMdynamic
using require (val DB = require("pouchdb-browser").default; val db = DB("my_new_db")
) and am just delegating to that in a wrapper class, which is fine.) Just an example, but maybe useful to help illustrate the process one can step through to make the JsModule approach work.Nikola Milovic
09/14/2021, 11:52 AM./gradlew run
gives no errors, and the devtools are disconnected. How do I go about debugging this? I have no feedback and absolutely no idea what is causing this, gradle is giving me thumbs up and successful tasks for build and run.
:web-app:browserDevelopmentRun > webpack 5.35.0 compiled successfully in 9236 ms
Chukwukammadu Anizoba
09/15/2021, 9:27 AMpromise
keyword doesn't exist in Kotlin/JS alone.Nicodemus Ojwee
09/16/2021, 9:31 AMNorbi
09/16/2021, 6:57 PMUncaught Error: Module build failed (from ../../node_modules/source-map-loader/dist/cjs.js):
Error: ENOENT: no such file or directory, open '...idea-project-folder\build\js\node_modules\webpack-dev-server\client\index.js'
I use Kotlin 1.5.30 with Compose/Web 1.0.0-alpha4-build348.
The build\js\node_modules\webpack-dev-server
folder really does not exist.
I have already tried setting versions.webpackDevServer.version = "4.0.0"
(I found this hint somewhere), and setting config.watchOptions
but nothing seems to help 😞
Do you have any idea? Thanks.Reuben F
09/16/2021, 11:47 PMCLOVIS
09/17/2021, 8:28 AMchild(MyClassComponent::class) {
child(SomeFunctionalComponent)
}
then, in MyClassComponent.render:
if (...) {
props.children()
}
This works fine with run
, but fails with `browserProductionWebpack`:
TypeError: _.render is not a function
andylamax
09/17/2021, 10:28 AMval lambdaFunction: (user: User)->Unit
yields the following typescript definitions
readonly lambdaFunction: (p0: User)-> void
Which hurts readability.
I would expect it to be exported to
readonly lambdaFunction: (user: User)-> void
Is there already a ticket for this?peekandpoke
09/17/2021, 1:37 PM> Task :commonmp:compileKotlinJs FAILED
e: org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration TypedAttributes
File being compiled: (3,1) in .../TypedAttributes.kt
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:93)
at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:43)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:453)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtVisitor.visitNamedDeclaration(KtVisitor.java:398)
...
Caused by: java.lang.AssertionError: Built-in class kotlin.Any is not found
at org.jetbrains.kotlin.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:93)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:88)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getBuiltInClassByName(KotlinBuiltIns.java:223)
at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getAny(KotlinBuiltIns.java:228)
...
Yan Pujante
09/18/2021, 5:34 PMYan Pujante
09/19/2021, 8:15 PMval templateEngine: dynamic = js("Sqrl")
templateEngine.render(content, tokens)
The issue is that tokens
is a Map<String, String>
and Sqrl is not happy with it... I used this code to workaround the issue:
val data: dynamic = js("{}")
tokens.forEach { e -> val k = e.key; val v = e.value; js("data[k] = v") }
templateEngine.render(content, data)
which works... But this seems so hacky. Is there a better way?Rescribet
09/20/2021, 7:59 AMsalomonbrys
09/20/2021, 11:55 AMLong
to JS with the IR compiler ???
@JsExport
fun long(): Long = 0x12_34_56_78_9A_BC_DE_F0
Calling this long
function with typescript returns the following object: Long { _low: -1698898192, _high: 305419896 }
Casting to int does NOT do the trick as the compiler overflows :
@JsExport
fun int(): Int = 0x12_34_56_78_9A_BC_DE_F0.toInt()
Calling this int
function with typescript returns a negative number: -1698898192
How can I export a Long
?cafonsomota
09/20/2021, 2:04 PMPitel
09/21/2021, 7:51 AMankushg
09/22/2021, 8:04 PMjsTest
sourceset which would basically do something ugly like:
js("""
var assert = require('assert');
var moduleUnderTest = require('myGroup-myModule');
assert(moduleUnderTest.method("parameter") == expectedResponse);
""")
While a little janky, this kind of test let us verify that things like JsName were added where expected and that we didn't accidentally break the public API for our JS consumers.
Now, under JS IR, the require
for my module is failing, because there's no JS file in the expected path. There is a package.json though.
Does anyone know how to get the module import working again under IR?
I'd also be happy to replace this with a JS file (instead of using js()
) that actually uses the final JS artifacts if anyone has an example of a project that does that!
EDIT: it looks like I can remove the require(…)
and get some stuff working, but not everything...ankushg
09/22/2021, 11:53 PM> Task :my-module:compileTestDevelopmentExecutableKotlinJs FAILED
e: java.lang.NullPointerException
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsStatementTransformer.visitCall(IrElementToJsStatementTransformer.kt:132)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsStatementTransformer.visitCall(IrElementToJsStatementTransformer.kt:20)
* What went wrong:
Execution failed for task ':my-module:compileTestDevelopmentExecutableKotlinJs'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
Pitel
09/24/2021, 11:32 AMval MessageTemplateTextDtoCreateInput.gql
get() = buildString {
append('{')
appendKV("body", body)
appendKV("languageId", languageId)
appendKV("subject", subject, true)
append('}')
}
fun StringBuilder.appendKV(key: CharSequence, value: Any?, last: Boolean = false) {
append(key)
append(':')
if (value is String) {
append('"')
}
append(
when (value) {
is Array<*> -> value.joinToString(",", "[", "]") {
it.asDynamic().gql as? CharSequence ?: "" // !!! PROBLEM HERE !!!
}
else -> value
}
)
if (value is String) {
append('"')
}
if (!last) {
append(',')
}
}
The problem is, how can I dynamicaly get the .gql
extension value I created?
• I understand, that Kotlin can't know from Array<*>
that the members has the .gql
extension.
• I know I can't use rflection in JS to look if the extension is there.
• Sealed classes/interfaces might be the solutionm, but I can't change the DTOs.
• asDynamic().gql
does not work (this is a bit WTF to me, I thought this might work and at worst throw an exception or something.)
So, any idea how to do this?Rohan Maity
09/26/2021, 11:42 AMwebpack.config.js
I will be able to set custom file name (instead of webApp.js)Piotr Krzemiński
09/27/2021, 8:21 AMjush
09/27/2021, 12:52 PMpackages.json
generated has neither dependencies
nor bundledDependencies
entries. Do we need to explicitly set those from now on?Dra
09/27/2021, 5:24 PMtesting
part saying this :
> Failed to execute all tests:
:browserTest: java.lang.IllegalStateException: Errors occurred during launch of browser for testing.
- Opera
- Firefox
- Chromium
Please make sure that you have installed browsers.
Or change it via
browser {
testTask {
useKarma {
useFirefox()
useChrome()
useSafari()
}
}
}
I know that the issue is related to the fact that it can't find firefox / chromium / opera... But how can I make it so tests are run correctly when deploying without having to remove the whole UI related part in my tests ?Todd
09/28/2021, 3:48 PMexternal fun Blob.stream(): Promise<ReadableStream>
But the compiler told me that's illegal. Intellij suggested I change it to
@Suppress("NOTHING_TO_INLINE")
inline fun Blob.stream(): Promise<ReadableStream> = asDynamic().stream() as Promise<ReadableStream>
which I think will work for me, but I was wondering if anyone knows of a better way to do this?