more JavaScript and TypeScript shenanigans

I’m still working on my fairly ridiculous JavaScript/TypeScript/SharePoint project, which I’ve mentioned previously. I’ve got the Q (promises) stuff all worked out now, I think.

I wanted to be able to read in a standard Microsoft Excel file as part of this project. To handle that, I looked at SheetJS. This looked like it would be pretty straightforward. But I hit a few issues in trying to integrate it into my project. There was a TypeScript definition file for it available via NuGet in Visual Studio. But the way the file was written led me down a rabbit hole of trying to figure out JavaScript modularization standards. This probably isn’t that tough a subject to figure out. I got as far as figuring that I should be using AMD and RequireJS. But, after about 20 minutes of reading RequireJS documentation and some related articles about how to use it in TypeScript, I decided that maybe I was better off skipping the whole thing and sticking with a CSV input instead of Excel.

I assumed I’d be able to read and parse a CSV file pretty easily, with the native JavaScript FileReader and some simple string operations to break up the lines into fields. But figuring out how to parse a CSV file sent me down a rabbit hole too. But it wasn’t a terribly deep rabbit hole. The end result is that I’m using a little library called Papa Parse to deal with the CSV parsing. (It turns out that the kind of CSV files I have will be a little too complex for “string.split(‘,’)”.)

Despite all the little issues, I’m learning a lot on this project. Maybe, most importantly, I’m learning about how far JavaScript development has come since the last time I did any major JS work. I need to do some catch-up work. Time for some more PluralSight videos.

Leave a Reply