Jim
09/28/2021, 9:24 PMBart
09/29/2021, 7:58 PMval post = window
.fetch(URL, RequestInit("post",HEADER,"{$bodyVar})
But its ending with error:
Failed to execude 'fetch' {...} Failed to read 'headers' from RequestInit
Already i try few types of typing header but all ends with same result. How fetch function should looks? How i can but header to IT? I want to put Content-Type and Authorizationandylamax
09/29/2021, 11:59 PM:compileDevelopmentExecutableKotlinJs
can really make your day so bad.
I am currently getting this error
e: java.lang.IllegalStateException: Variable name is not found user
at org.jetbrains.kotlin.ir.backend.js.utils.JsGenerationContext.getNameForValueDeclaration(JsGenerationContext.kt:65)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsExpressionTransformer.visitGetValue(IrElementToJsExpressionTransformer.kt:106)
. . .
It is a kotlin compiler error. Has anyone being getting this?
It worked a few minutes ago. I ddn't change any dependencies. Using Kotlin 1.5.30Rohan Maity
09/30/2021, 3:31 AMMathias Cochet
09/30/2021, 7:20 AMMiquel Àngel Román
10/03/2021, 7:34 PMankushg
10/05/2021, 1:01 AMexternal interface
s for `data class`es when working in a multiplatform project with JS targets?
What about generating/maintaining the methods to map between the two?
Context/Problem:
We've written some `external interface`s for JS interop for methods that use simpler classes, but for complicated, nested, interconnected classes, it's a lot of effort to maintain this code.
We're currently using kotlinx.serialization
and encodeToDynamic
/`encodeFromDynamic` to handle those complicated types. The developer experience within KMP when using kotlinx.serialization
is much nicer, but:
1. we get dynamic
types back instead of rich external interface
s, so we don't get typescript definitions
2. serialization's json artifact is extremely heavyweight for this on web because it pulls in full JSON support for strings and JsonElement trees when we really just need lightweight methods that create and return plain JS objects as described here
Potential Solution?
It seems like those two problems above might be separately solvable?
1. Could be solved with an annotation processor to generate `external interface`s for classes annotated with @Serializable
(or some other annotation) (which we can then cast the serialization-generated `dynamic`s to/from)
2. Can maybe be solved with an alternative serialization format that is
a. only usable by the js
target,
b. operates directly on JS `Object`s, and
c. excludes all the heavy stuff for string or JsonElements in the official json
format
If this sounds like stuff that anyone else is working on or running up against, I'd love to chat!Alexander
10/05/2021, 8:38 AMDouble
. Here is an example:
val n = 1.1 as Any
if (n is Number) {
println(n.toLong())
println(n.toLong() == 1L)
}
if (n is Int) {
println(n.toLong())
println(n.toLong() == 1L)
}
Both conditions are resolved to true
(I know that Javascript hasn't integer numbers so its ok). But what is more interesting it prints:
1
true
1
false
When I use kotest
it fails with expected:<1L> but was:<1.1L>
.
1.1L
looks really strange for me.jonnyzzz
10/06/2021, 10:46 AMAleksandar Milojević
10/06/2021, 12:51 PM@JsExport
open class MyFirstClass {
open fun myFirstClassFunction() {
println("################ MyFirstClass")
}
}
@JsExport
open class MySecondClass {
open fun mySecondClassFunction(){
println("################ MySecondClass")
}
}
@JsExport
open class MyThirdClass {
open fun myThirdClassFunction() {
println("################ MyThirdClass")
}
}
Basically, these classes are the same.
After compile, a get d.ts. file and .js
d.ts. file looks like:
export class MyFirstClass {
constructor();
myFirstClassFunction(): void;
}
export class MySecondClass {
constructor();
mySecondClassFunction(): void;
}
export class MyThirdClass {
constructor();
myThirdClassFunction(): void;
}
but, the .js file added some numbers beside the methods name
MyFirstClass.prototype.myFirstClassFunction_0 = function () {
println('################ MyFirstClass');
};
MyFirstClass.$metadata$ = {
simpleName: 'MyFirstClass',
kind: 'class',
interfaces: []
};
function MySecondClass() {
}
MySecondClass.prototype.mySecondClassFunction = function () {
println('################ MySecondClass');
};
MySecondClass.$metadata$ = {
simpleName: 'MySecondClass',
kind: 'class',
interfaces: []
};
function MyThirdClass() {
}
MyThirdClass.prototype.myThirdClassFunction_3 = function () {
println('################ MyThirdClass');
};
MyThirdClass.$metadata$ = {
simpleName: 'MyThirdClass',
kind: 'class',
interfaces: []
};
After inheritance like in example
class MyFirstClassTS extends MyFirstClass {
constructor() {
super();
}
myFirstClassFunction() {
<http://console.info|console.info>("############ MyFirstClassTS")
}
}
class MySecondClassTS extends MySecondClass {
constructor() {
super();
}
mySecondClassFunction() {
<http://console.info|console.info>("############ MySecondClassTS")
}
}
class MyThirdClassTS extends MyThirdClass {
constructor() {
super();
}
myThirdClassFunction() {
<http://console.info|console.info>("############ MyThirdClassTS")
}
}
in console I got very different result as in picture below.Robert Jaros
10/07/2021, 7:01 AMmbonnin
10/07/2021, 12:48 PMPlease choose a JavaScript environment to build distributions and run tests.
. I understand the need to specify browser or nodejs for running tests but how does that impact building distribution? I'm building a lib and I would expect the lib to be consumed from both browser and nodejs project so it feels weird having to chose one there.Gabriel Duncan
10/08/2021, 10:34 PMJilles van Gurp
10/11/2021, 8:46 AMjsBrowserDevelopmentRun
from doing its thing. Is anyone else running into this? Or better still, have a workaround?
Basically, started happening after I did a gradle clean on my fritz2 project. After this it pulled in the latest npm dependencies. Was working fine before the gradle clean.
[webpack-cli] Unable to load '@webpack-cli/serve' command
[webpack-cli] TypeError: options.forEach is not a function
[webpack-cli] TypeError: options.forEach is not a function
at WebpackCLI.makeCommand (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/webpack-cli/lib/webpack-cli.js:173:21)
at ServeCommand.apply (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/@webpack-cli/serve/lib/index.js:41:19)
at loadCommandByName (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/webpack-cli/lib/webpack-cli.js:907:35)
at async Command.<anonymous> (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/webpack-cli/lib/webpack-cli.js:1462:17)
at async Promise.all (index 0)
at async WebpackCLI.run (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/webpack-cli/lib/webpack-cli.js:1500:9)
at async runCLI (/Volumes/SAMSUNG_2TB/git/formation/maptool/build/js/node_modules/webpack-cli/lib/bootstrap.js:11:9)
It seems the solution is somehow downgrading webpack. https://github.com/webpack/webpack-cli/issues/2990Pitel
10/11/2021, 9:41 AMclass TemplateParser : StreamParser {
override fun token(stream: StringStream, state: dynamic): String? {
console.log(stream, state)
return null
}
}
This gets compile to this JS:
function TemplateParser() {}
TemplateParser.prototype.token_qt5re9_k$ = function(stream, state) {
console.log(stream, state);
return null;
}
;
TemplateParser.prototype.token = function(stream, state) {
return this.token_qt5re9_k$(stream, state);
}
;
Which crashes with Uncaught TypeError: this.token_qt5re9_k$ is not a function
WTF?!spand
10/11/2021, 12:24 PMspand
10/11/2021, 12:27 PMankushg
10/11/2021, 11:24 PMsuspend fun
to Promise
?Antoine Lamy
10/12/2021, 5:41 PMandylamax
10/13/2021, 3:09 AMmbonnin
10/13/2021, 9:14 AMNumber.toString()
method somewhere? (see https://youtrack.jetbrains.com/issue/KT-33358). I need to write some JVM code that maps 1:1 with some JS code.Alfred Lopez
10/13/2021, 1:39 PMmbonnin
10/13/2021, 3:38 PMExecution failed for task ':module:kotlinNpmInstall'.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
> Process 'Resolving NPM dependencies using yarn' returns 137
Anyone else noticing this? Any way to mitigate?Alexander Weickmann
10/13/2021, 4:30 PMThis declaration is experimental and its usage should be marked with '@org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDceDsl' or '@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDceDsl::class)'However, when I mark it with OptIn like so:
@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDceDsl::class)
dceTask {
then the above warning disappears, but I get a warning for the OptIn itself:
This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'I already enabled this compiler flag like so:
kotlin {
sourceSets.all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
However, this seems to enable the OptIn only for the app source code, but not for the Gradle build script itself. How can we enable @OptIn annotation for the Gradle build script itself, so we can annotate the dceTask with OptIn and not in turn get a warning for the OptIn usage?Tomasz Krakowiak
10/13/2021, 7:17 PMJérôme Gully
10/14/2021, 12:20 PMjs(IR) {
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
binaries.executable()
}
}
julien lengrand-lambert
10/15/2021, 1:10 PMjulien lengrand-lambert
10/15/2021, 1:19 PMChristian Gaisl
10/17/2021, 1:35 PMjs(IR) {
browser()
binaries.library()
}
which creates a folder inside the “build” folder called “productionLibrary”. This folder I could then import in my Angular App (or any other framework) with npm install absolutePathToProductionLibrary.
I have a few questions about that:
• Is this a/the recommended way to do this?
• I can only find classes annotated with @JsExport in the generated Javascript/Typescript code, do I have to do that for everything?
• I can’t annotate classes in the common/shared module of my Multiplatform library with @JsExport, how do I get those classes to show up in the generated JavaScript code?Harald Pehl
10/18/2021, 6:51 AMHarald Pehl
10/18/2021, 6:51 AMmax.kammerer
10/29/2021, 6:49 AMHarald Pehl
10/29/2021, 1:46 PM