Need a way to get access to webchat.d.ts file.
I tried building the repo, but it generates multiple d.ts files, and consolidating them is painful. It's really helpful in writing typescript code. Please provide a way to get it, either directly from cdn or by building the code.
Would prefer to write it manually because:
tsc expose unnecessary internals of Web Chat, which confuse userplease find this d.ts code as a starter. I just added the ones needed for me, feel free to take it, improve it and make a PR out of it.
Use it from your .ts with:
import 'typings/WebChat' //you'll need to adjust this to your own setup
interface Window {
WebChat: WebChat.IWebChat;
}
declare namespace WebChat {
interface IWebChat {
createStore(): IStore,
renderWebChat(options: IWebChatOptions, element: HTMLElement): void,
createDirectLine(tokenData: IDirectLineToken): IDirectLine
}
interface IDirectLineToken {
token: string
}
interface IWebChatOptions {
directLine: IDirectLine,
store: IStore,
styleOptions: IStyleOptions
}
interface IStyleOptions {
[index: string]: number | string | boolean;
botAvatarInitials: string,
botAvatarBackground: string,
botAvatarImage: string,
bubbleBorderRadius: string,
bubbleTextColor: string,
bubbleFromUserBackground: string,
bubbleFromUserTextColor: string,
bubbleFromUserBorderRadius: string,
hideUploadButton: boolean
}
interface IDirectLine { }
interface IDispatchPayload {
text: string
}
interface IDispatchAction {
type: string,
payload: IDispatchPayload
}
interface IStore {
dispatch(action: IDispatchAction)
}
}
@corinagum will implement the initial .d.ts file. As a team we'll think about a way to automatically generate this file with a level of control over the exposed interface that we want.
That's great to hear :) I just wanted to contribute something for the time being since it is unclear when it will be implemented by the webchat team?
@cwhitten @corinagum Could you please give some more insight into when we can expect this?
@hansmbakker, thanks for your patience! This is assigned to me in our current milestone 4.6, which is due for release at the end of October. I am finishing up some other assignments first, but I hope to get to this one soon! Unfortunately I don't have further detail than that right now. When I begin working on this, I will move it from 'To-Do' to 'In progress' in our Project board. :)
@tdurnford while you are working on this, since we are don't really need TypeScript anymore (we build *.d.ts by hand and our *.ts are just a few files that can be converted to JS), it may make sense to remove TypeScript from Babel to speed up the build.
Any progress on this guys? I have a project with react-based webchat which use typescript and I can't use the power of it. For example, I can't normally work with redux, just because you don't declare or export any types and most consts like INCOMING_ACTIVITY. It will be very useful if you will provide typings for project or rewrite it with typescript. I was very confused when found Microsoft project doesn't use typescript and instead use pure js.
I am okay to inference the types automatically, as long as:
any type, everything must be concretely-typed.d.tsWe can progressively add typings, I think the most needed is defaultStyleOptions.
FYI, our project already have TypeScript set up through Babel.
Discussed offline with @corinagum, we will try this route:
webchat.d.ts manuallydefaultStyleOptionsindex.d.ts? Let's see how other TypeScript projects name this file)package.json and add a new field to point to this webchat.d.ts filedefaultStyleOptions.js to defaultStyleOptions.tsdefaultStyleOptions.ts, reference webchat.d.ts and import the typesComposer and other entrypoints that, when the developer type renderWebChat({ styleOptions:, IntelliSense will autocomplete the types
Most helpful comment
please find this d.ts code as a starter. I just added the ones needed for me, feel free to take it, improve it and make a PR out of it.
Use it from your .ts with: