Is it possible to mix TypeScript & ClojureScript

I am currently using TypeScript 2.0 with React and webpack in one of my projects. I am thinking about trying ClojureScript, but I would like to start small, perhaps create one screen first.

Is it possible to mix two together in one project?

Ideally, I would like to use a component built into Clojure that will be used through ES6 import.

The main reason for this is to introduce the / myslef command in Clojure, but we already have a bitcode in TypeScript. I understand that it is easy to create a completely separate package and reference it, but this is not ideal.

+4
source share
3 answers

Yes.

ClojureScript - JavaScript, React . , Reagent 0.6.0, create-class .

! . , ClojureScript , -, ClojureScript, . , ( figwheel/devcards).

+4

? . ? , . , , . , .

0

, , . , , , , , , .

, (, ES6, ), ClojureScript, my-cjs.js, my-cjs.d.ts TypeScript declare module "my-cjs";, TS import { export1, export2 } from "my-cjs" .

, , , , , ( , any ClojureScript). , ClojureScript, , , , , API script .

, , , ES6. TypeScript JS , ClojureScript JS , ( , , ). , , , , .

, - :

/cjs-output
 |- /my-component
    |- my-cjs-script.js
/ts-output
 |- my-ts-code.js
 |- some-more-ts-code.js

:

/output
 |- /my-component
    |- my-cjs-script.js
 |- my-ts-code.js
 |- some-more-ts-code.js

, - ClojureScript, . Webpack - - , TS + CJS JS- webpack, webpack JS, , , , YMMV.

my-ts-code.js my-component/my-cjs-script , my-component/my-cjs-script, tsc .

0

Source: https://habr.com/ru/post/1661120/


All Articles