TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
let a = async (s) => {
var result = await Promise.resolve("Data recieved");
return "blaa";
};
Eg. I can do:
"filesGlob": ["*.ts", "typings/**/*.ts"]
or I can do:
"files": ["main.ts", "typings/a/a.d.ts", "typings/b/b.d.ts", ...]
But if I do:
"filesGlob": ["main.ts", "typings/**/*.ts"]
It will bundle all .ts
files it finds, not just the ones required by main.ts
. If I use "files"
it will only bundle the required ones, but I have to list every typings file by name.
Thanks for the mention @Ciantic :rose:
The playground I once worked on that is easy to upgrade to ts latest although I don't have the heart to do that anymore basarat/TypeScriptEditor@b90d00b
This i the project I am working on for this year http://alm.tools/ Will most likely create a hosted version of alm for demo so people can try it before npm installing
at some point :heart:
you can think of any javascript file as a typescript file without typings. it's designed for maximum interoperability. if you want, you can include js files in your ts compilation too
https://www.typescriptlang.org/docs/release-notes/typescript-1.8.html
Including .js files with --allowJs
Often there are external source files in your project that may not be authored in TypeScript. Alternatively, you might be in the middle of converting a JS code base into TS, but still want to bundle all your JS code into a single file with the output of your new TS code.
.js files are now allowed as input to tsc. The TypeScript compiler checks the input .js files for syntax errors, and emits valid output based on the --target and --module flags. The output can be combined with other .ts files as well. Source maps are still generated for .js files just like with .ts files.
*.js
files. Check this article out for more: Incrementally migrating to TypeScript.
Hi all, I've got a tricky generics problem I'm hoping someone can help me solve:
I want to have a map
function that supports any object that implements the Functor interface.
But I want to declare that map will always return the same type that it received.
e.g. if I pass in an array, I want tsc to know its an array. Or if I pass in a Maybe, I want tsc to know its a Maybe.
I'm losing precision when I receive the result. The type signature can only guarantee that V
is a Functor, instead I want to guarantee that V
is the same type that was received.
interface Functor<T> {
map<T>(a: any): Functor<T>;
}
interface Ramda {
map<T, U, V extends Functor<U>>(fn: (x: T) => U): (obj: V) => V;
}
interface Maybe<T> {
map<T2> ( f: (value: T) => T2 ) : Maybe<T2>
}
var m : Maybe<string>;
declare var R : Ramda
// tsc says b is Functor<Number>
// but I want it to be a Maybe<Number>
var b = R.map( (a:number) => a)(m)
Is this possible?
Maybe
return type is captured here map<T, U, V extends Functor<U>>(fn: (x: T) => U): (obj: V) => V;
V
from, as it is not passed to the original function anywhere
V