Programming language: Kotlin / JS Inspection Pack simplifies compiler migration

A week after the last version of Kotlin 1.5.30, the software company JetBrains which created the programming language released the Kotlin / JS Inspection Pack plug-in. It should support both creating new projects with Kotlin / JS and migrating existing projects to the new Kotlin / JS IR (Intermediate Representation) compiler. This is currently integrated as a beta in Kotlin and is intended to replace the old compiler.

With interfaces and classes, included data classthat come from pure JavaScript classes can lead to ClassCastException-An error message arrives. This happens, for example, with React classes State and Props and that’s because the IR compiler assumes that these are Kotlin objects rather than undefined JavaScript objects in the code. This is where the Kotlin / JS Inspection Pack comes in by highlighting these classes and interfaces and suggesting converting them to external interfaces:

The Kotlin / JS Inspection Pack suggests converting JavaScript classes to external interfaces.

(Image: JetBrains)

Additionally, the Inspection Pack provides workaround suggestions for dealing with external interfaces. Assigning values ​​to immutable (non-modifiable) properties would only be possible after the objects were created using js() Where jsObject() possible. However, as the plug-in suggests, this can be done by converting these properties to mutable properties using var bypasses.

The Kotlin / JS inspection pack also suggests using Boolean properties in external interfaces like nullable specify. that should help one more ClassCastException-Avoid errors because as long as these values ​​are in JavaScript null Where undefined Kotlin requires that they be explicitly specified.

The Kotlin / JS Inspection Pack is available from JetBrains and can be downloaded. It can be used with IntelliJ IDEA and Android Studio.

Additionally, JetBrains recommends reviewing the new Kotlin / JS IR backend read along with the Kotlin / JS Migration Guide to consider. Kotlin itself is currently available in version 1.5.30, Kotlin 1.6 is expected to appear in November.

More information about the Kotlin / JS Inspection Pack offers the JetBrains blog.


Source of the article

Disclaimer: This article is generated from the feed and is not edited by our team.

Categories Technology

About Mariel Baker

Check Also

Career Advice: My Path to Technical Programming

In a few weeks, my final year at Fisk University will begin. Freshman move-in day …