✅ Upgrading Javascript to Typescript in MVC project
I globally installed npm and typescript. Then created a tsconfig.json in my project. But I have no idea what to do after that.
I am trying to put my .ts files in TypeScript folder directly under the App.Web. Both TypeScript folder and tsconfig.json are right under App.Web.
(I have 2 apps in one project. App.Web and App.Api)
Installing typescript in App.Web was a torture. I gave up and installed it globally.
22 Replies
Don't know what's the best way is, I just used vite, set up a reverse proxy on the aspnet core side, and made some tag helpers that remap the links to ts files to js bundles in production
Umm... english?
I have a local development server for serving the static files (vite)
I see. I want the other ways then
the aspnet core server uses a reverse proxy to reroute the requests it doesn't know about to it
aka static files
in development
ts files are compiled and transformed into js files to be used by the app later right?
transpiled, minimized and bundled
I copy them in my publish script (using Nuke)
In this case it should have a small code to transform all of them in one go. For this I need a root folder for ts files and output folder for transformed js files right?
I see. But I don't want to make it too complicated
then you'll have to do builds manually
alright.
setting up msbuild to do this is insanity
copying files in a batch or shell script is a pain and is not portable
I mean, I saw something like "tsc: build" on internet. Had no luck finding it though
in ctrl shift p
Nuke is pretty easy to use, take a look at it eventually
okay i will
I just wanted to learn the normal way of doing it first
most primordinal one
so i can grasp it better
GitHub
49/Build.cs at main · AntonC9018/49
Contribute to AntonC9018/49 development by creating an account on GitHub.
yeah there may be tools for it that do typescript in another way
I guess I forgot to mention it. I am doing "npx tsc firsttry.ts". If they are all in root folder, it works. But I have problem with giving locations. It says it can't find it
error TS6053: File 'index.ts' not found. The file is in the program because: Root file specified for compilation
Idk, haven't used raw typescript, only used vite
I see, no problem. I will wait for an another kind soul I guess 😄 Thanks for the try!
npx tsc TypeScript/index.ts
I see, it still needs the location. It transformed it but outDir is not working.
I want it to send it to wwwroot/jsthere might be some option for it, or a setting in a config file
found it
no, you CAN'T DO THIS TO ME!!! 😄 😄
it's just tsc
"tsc"
done
what happens is basically it reads tsconfig.json. When I write "tsc TypeScript/index.ts", it doesn't read it or something and hence puts the js file right next to it.
tsconfig.json has "include" which tries to find .ts files to compile. Then puts them in "outDir" location. smh!
Closed!