0

I need some of the GAPIs, but unfortunately, the best definitions I found are still not complete, and I don't have the time right now to make a tool to regenerate the .d.ts from the discovery files (if someone can suggest a quick way, I am happy to try it). Anyway, my "service" is ready in JavaScript (based on: How to inject custom service to angular component in plain ES5 (Javascript)?), and I am trying to use it in the project:

"use strict"; 
var ConfigurationService = ng.core.Injectable().Class({
  constructor: function() {},
  // Other methods here ...
});

export default ConfigurationService;

I have even created a .d.ts for it, but I still can't import: enter image description here Of course "allowJs": true is there.

Then I have removed the braces, and import was accepted (as long as there is a .d.ts file): enter image description here

But build fails anyway: enter image description here I suppose I am totally wrong here...

Could someone please post a skeleton of an Angular2+ service written in JS, but consumed in TS? Thank you!

Community
  • 1
  • 1
ZorgoZ
  • 2,974
  • 1
  • 12
  • 34
  • why dont you try and import the package like a third party lib into angular eg - https://stackoverflow.com/questions/35796961/angular-2-adding-3rd-party-libs – Rahul Singh Jul 12 '17 at 14:55
  • How will that make my code act as Service in Angular? 1) `gapi`, `gapi.client` and `gapi.auth2` are allready installed. I need them. It would help me if I could "extend" `gapi.client` somehow with a `gapi.client.drives:any` and `gapi.client.drives.files:any` – ZorgoZ Jul 13 '17 at 09:17
  • you can then use these js files in service and then inject them to your component that might help roight? – Rahul Singh Jul 13 '17 at 09:19
  • Yepp... this was ultimately the workaround. Still does not work as expected, but at least it gets compiled :) Anyway, it would be interesting to see such a skeleton... after all TypeScript is a superset of JavaScript – ZorgoZ Jul 13 '17 at 11:52

0 Answers0