Release of jsii 1.31, C#, Go, Java and Python code generator from TypeScript

Amazon has published the jsii 1.31 compiler, which is a modification of the TypeScript compiler that allows you to extract API information from compiled modules and generate a universal representation of this API for accessing JavaScript classes from applications in various programming languages. The project code is written in TypeScript and distributed under the Apache 2.0 license.

Jsii makes it possible to create class libraries in TypeScript that can be used in projects in C#, Go, Java and Python by translating into native modules for these languages ​​that provide the same API. Tooling is used in the AWS Cloud Development Kit to provide libraries for different programming languages, built from a single code base.

The new release is notable for the addition of the "jsii-rosetta transliterate" command, which allows you to transliterate ".jsii" files with intermediate code representation into one or more target programming languages.

For example, based on JavaScript/TypeScript code: export class HelloWorld { public sayHello(name: string) { return `Hello, ${name}`; } public fibonacci(num: number) { let array = [0, 1]; for (let i = 2; i < num + 1; i++) { array.push(array[i - 2] + array[i - 1]); } return array[num]; } }

jsii will generate Python code: class HelloWorld: def say_hello(self, name): return 'Hello, ' + name def fibonacci(self, n): table = [0, 1] for i in range(2, n + 1) : table.append(table[i - 2] + table[i - 1]) return table[n]
Source: opennet.ru

Add a comment