Type: bug
Ionic Version: 2.x
Platform: all
I had the project working with js, then i started a new typescript project and copy the configs to mine, i have the moment package installed but the compilator complains that can't find the moment package.
I tried to install and import inside the new typescript project just to ensure it isn't my bad when copying the configs and happens the same, why if i had it working with the js project? i think it's the same with D3 data visualization package, had it working and now it doesn't, help?
Update, it's the linter, the code still works, it's just the linter that can't detect the packages, that's heavily missleading, both the syntax highlight in sublime and the console logs says Cannot find module 'moment', at least the linter should be fixed.
Did you try to import the typescript definition! Something like tsd import moment --save
Oh i didn't, i forgot that typescript needed the definitions, but in such case where does the ones for ionic come from?
However i did as you mentioned but with tsd install moment --save && tsd install d3 --save and the error persists.
Do i have to reference the definition file somewhere like this?:
/// <reference path="moment/moment-node.d.ts" /> /// <reference path="moment/moment.d.ts" /> /// <reference path="d3/d3.d.ts" />
Just use:
const moment = require("moment");
to silent TS.
Actually i did use the reference way, i think looks cleaner.
@manucorporat Found another way, just include the typings/tsd.d.ts file in the files array in the tsconfig.json file to make the typings available in all the project.
@Luchillo cool! thanks for the info! looks like a cleaner solution
can anyone explain solution ?
@Anujmoglix Which one? the one i suggested? the comment is very explicit, though outdated, what did not understand?
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.