Would it be possible to use https://conversejs.org/ in an Angular 2 or 4 application?
Is it possible to import and use JavaScript libraries from a TypeScript app?
This article claims it is possible:
https://www.thepolyglotdeveloper.com/2017/03/javascript-libraries-in-a-typescript-application-revisited/
Yet my front-end developer says it’s impossible.
Can someone verify?
TypeScript is a superset of JavaScript, and the TypeScript transpiler will convert your code into JavaScript during compilation. Therefore, you can write as much pure JavaScript in a TypeScript app and it should transpile to JavaScript with no issues.
Is it possible to import and use JavaScript libraries from a TypeScript app?
Yes, it is possible. You will still need to appropriately declare/import the JavaScript libraries you want to use or else you will get compile errors.
Would it be possible to use https://conversejs.org/ in an Angular 2 or 4 application?
This really depends on the library. The general answer is "Yes, you can use JavaScript libraries/code in a TypeScript app." But you will personally need to read the documentation in order to verify for this particular library.
Related
In the CASL docs it states that...
CASL has sophisticated support for TypeScript
But you can use plain Javascript. I want to know if the same is true for the #casl/prisma package. The example given seems to use Typescript (type AppAbility...)
And the docs say...
TypeScript Support:
The Package is written in TypeScript...
But that sounds like it has support for TypeScript but if you want you can use vanilla Javascript.
Im angular developer.
In our front & back exists some magic calculation methods.
Classes same, but when anyone find bug in calculation need to fix it in two different projects.
maybe there is a way to create a generic codebase (maby function) that can be converted to js(or ts) & java and update two libraries based on the two results obtained
You could try to use kotlin.
Kotlin transpiles to JavaScript and also compiles to java bytecode.
However, you can only access kotlin utilities and neither access java or JS/TS types if you want to use the code in both java and ts/js code but you can use the kotlin stdlib.
But if it really is just a calculation, you may not need java/js specific classes/functions.
However, as VLAZ mentioned in the comments, you should consider doing the calculation only once in the backend.
Setting this up in IntelliJ
You can create such a project in IntelliJ by sekecting Kotlin in the New Project Window and using the project template Library.
Make sure you have the targets common, jvm and js. Since you didn't say you would do native stuff, you don't need the native target.
You can then use the kotlin library in both JavaScript (e.g. Angular) and Java projects as a dependency.
From a Java project, you can reference KOTLIN_PROJECT/build/classes/kotlin/jvm/main (this directory contains compiled Java classes).
From a JavaScript (e.g. Angular) project, you can reference KOTLIN_PROJECT/build/js/packages/kotlinToJavaAndJS.
As a proof of concept, I have made this repository on GitHub.
We recently migrated to Angular 9 (Type Script) from Angular.js and would like to continue writing our tests in Mocha, but keep the JavaScript syntax (not writing tests in TypeScript Mocha).
Is that possible to write JavaScript test for Type Script code (I know that JavaScript syntax is possible to write, this is not what I am asking) - the question is - is it possible to test the actual TypeScript components of Angular?
Any guides/article will be appreciated.
Thanks.
The required behavior should just work as you want it.
TypeScript is basically just a (visual) layer on top of JavaScript.
Either create a .spec.ts files and write default JavaScript code, or create .spec.js files and write JavaScript. Either way, it should "just work".
If anything you need to check if you have settings defined that mocha will only load certain extensions for your tests.
is there any way to start with angular2 material2 using ES6?
I have tried to find the way but Failed.
Also checked the git repo where found that all code exist for now with TS
so does it mean we can't able to use it with ES6
is there atlernative to overcome it?
Yes, with Angular you can use vanilla JavaScript - either es5 or es6 - your choice. You can also use Typescript or Dart. Many of the tutorials you see use Typescript, because it works so well with Angular, and because the Angular team use it as their default. But you're certainly not tied to having to use that. If you prefer to use vanilla JS you certainly can -- because, remember, it all gets compiled down to JS, regardless of what you use for your coding.
Also, you can use Material2 regardless of what language and language version you're using to code with in your Angular app.
More info here: https://angular.io/docs/js/latest/quickstart.html
And to use Material in your Angular app, see this: https://material.angular.io/guide/getting-started
i am starting documenting my java-script + typescript website with jsDuck
I've documented my class very well , but my problem is interfaces - they don't compile from the ts file over to the java-script.
here is my output, as u can see the page doesn't know who is IComboBoxScope
of course it understandable due to the fact it doesn't generated to the java-script
http://i.stack.imgur.com/PIVKe.jpg
is there a proper way to workaround this in jsDuck?
IF NOT, is there other products or solutions for documenting js with typescript out there?, maaybe jsDoc? ,typeDoc?
sorry for the poor sample/photo, i am working on a private network.
just wanted to share my findings,
i have found a great solution typeDoc is really good, it doesn't need the compiled javascripts, it is dedicated to the ts files,
new solution, active environment and the great thing is that i only need to run a 1 line script with the project library as a parameter.
typedoc --out path/to/documentation/ path/to/typescript/project/
output example
i have seen options to change themes, class hierarchy is working very well
installed by NPM and support es 3,es 5
great!.
From JSDuck side there is no simple workaround as JSDuck has no concept of interfaces. You might document your interfaces as abstract classes for JSDuck, but it's not really the same. You're better off using a tool that natively supports TypeScript.