Accessing an interface inside a declared module... I have no clue

Does anyone know how to do this?

I need to be able to access or loop through the property keys of the embedded interface.

let server = server.calendar;
server = undefined

Why is this undefined?

This seems like it should be simple to do but I spent way more than is reasonable on it. I’m still relatively new to Typescript and Ionic so any help would greatly be appreciated.

Calendar.d.ts file looks like…

declare module server {

interface calendar {

mobileID: string;
extid: string;
date?: Date;
contactid: string;

Hi, @Slitelee
try below code:

Interface : calendar.ts

export interface calendar {
       mobileID: string;
       extid: string;
       date?: Date;
       contactid: string;
}

Use :

let server = {} as calender;

Thanks ,

besides what @addwebsolution gave you: you cannot loop through the properties of the interface as an interface will not exist during runtime. So you need to make the keys explicit or assume you have an instantiated object with all keys filled, so you can use Object.keys(…) to retrieve the keys.

Btw, I wonder if let server = {} as calender;will work.

I would instantiate:

let server:calendar = {
       mobileID: '',
       extid: '',
       date: 0,
       contactid: '',
}

The module is being produced by a black box plugin for C# for Visual Studio 2017 so modifying is a non-option. It’s output d.ts file are copied to our mobile project where they are leveraged to ensure data consistency.

let server = {} as calender; Worked !!! Thanks!!!

1 Like

Hi, @Slitelee

If your issue was resolved to please mark as a solution.

thanks

And how do I do that? I don’t know where on the forum marks as solution.

01%20AM

You would see this kind of options at my reply. You can click on first icon which is kind of check box with correct tick mark just left of heart symbol.

I do not see any check box. But have now clicked the heart