looking for input from those that may have already...
# suitescript
d
looking for input from those that may have already been down this road: would it be a perfectly valid/reasonable approach to use the TypeScript Compiler purely as a means to transpile JS files from ~ESNext (mainly looking to leverage import/export module syntax, and the vscode intellisense that will be provided) down to ~ES6 & AMD module syntax? I am not ready to completely bite off on switching to TypeScript, but would definitely like to modernize our solutions and development away from AMD. (I am mainly contrasting using tsc (with pure Js for the time being) as opposed to something more like Babel) Thanks
s
I've never tried it myself - have you confirmed that
tsc
will even do that (transpile JS to JS)?
a
Isn't that what babel is for?
d
I figured you would reply 😅 I honestly have not looked into it much at all thus far, was hoping was possible with the
allowJs
flag or some combination of configs - was just getting a feel for if this is valid. and ya seemed babel is more targeted fit, just seemed tsc could be an option as well and maybe a bit more modern/supported/easy to setup if was even possible
s
actually, I just did a quick test and I'm pleasantly surprised to see it does transpile
all you need is
allowJs
and
outDir
(so that you have somewhere to write the .js file that would otherwise overwrite the source JS)
d
cool cool ya figured would be similar setup to https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html steps good to know it seems at least possible! I have just been playing around with this idea, but have not had time to actually explore too much, I will have to report back with other findings if I ever get the time :)
s
you might also just start using TS - my understanding is you can literally take a
.js
file and change that suffix to
.ts
to get started (i.e. no code change) then gradually add type info
again, I don't have a lot of experience with that since we've been using TS as source for years, but it's supposed to be a no-friction way to get started and incrementally type your stuff
d
is there a TS equivalent of
--checkJs
flag? was just thinking would get a ton of compilation errors then if switching to .ts , or is there a way to ignore those if I do not care about them until wanting to more fully convert to TS. Edit: I guess there is some "transpile only" type of solutions available, if not directly in base tsc, will research more online.