Currently, I am in the process of transitioning a website to utilize TypeScript by converting one JavaScript file at a time. All pages on my site are already linked to moment.js, such as:
<script src="/scripts/moment.min.js"></script>
I have successfully added other TypeScript definition files using the following command:
npm install --save-dev @types/jquery
However, it seems that this approach may not be suitable for Moment.js. After running the above command with 'moment' instead of 'jquery', a readme file is downloaded indicating:
This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need @types/moment installed!
As an alternative solution, I attempted to save the moment.d.ts file from its GitHub repository and reference it in the TypeScript file like this:
///<reference path="../../Scripts/typeDeclarations/moment.d.ts"/>
var now:any = moment.utc();
However, TypeScript issued a warning:
Cannot find the name 'moment'