简体   繁体   中英

Use js file with angular (d.ts file)

I try since yesterday to write a correct d.ts file in order to use my personal js file into angular.io

This is a piece of my js file :

let usersSpeak = {};
let remoteStreams = [];
let idSpeaker;
function updateUser(id, value) {
   //do something
}

function stop(type, id) {
    //do something
}

For the moment my d.ts file looks like this :

declare namespace MyNamespace {
   let usersSpeak: any;
   let idSpeaker: number;
   let remoteStreams: any;
   function updateUser(id: number, value: string);
   function stop(type: string, id: number);
}

I know this can't work because i create a namespace MyNamespace which doesn't exist on my js.file but i tried a lot of things and nothing work... I succeed with this on my ts file directly :

declare let usersSpeak: any;
declare let idSpeaker: any;
declare let remoteStreams: any;
declare let updateUser: any;
declare let stop: any;

But that's not what i want, i really want a d.ts file

Do you have any idea ?

Have you tried this?

export namespace MyNameSpace {
   let usersSpeak: any;
   let idSpeaker: number;
   let remoteStreams: any;
   function updateUser(id: number, value: string);
   function stop(type: string, id: number);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM