-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript types #11
Comments
I have some experience with Flow, but haven't used TypeScript. |
yes - that's pretty much it - i'll look to complete that work in the coming weeks. I've got the very basics in so far |
Is there anything in progress with this issue? |
I have two version i need to reconcile, should have time in the next couple weeks |
If anyone needs it ASAP, here's what I threw together this morning. It's not perfect but it'll get you going at least. Be aware that it's missing:
There's probably a cleaner way to do the emitter and experiment debugger, but it works 🤷♂️ declare module '@marvelapp/react-ab-test' {
import * as React from 'react'
type ExperimentProps = {
name: string
userIdentifier?: string
defaultVariantName?: string
}
type VariantProps = {
name: string
}
export class Experiment extends React.Component<ExperimentProps, any> {}
export class Variant extends React.Component<VariantProps, any> {}
type EmitterCallback = (experimentName: string, variantName: string) => void
type Subscription = {
remove(): void
}
class Emitter {
emitWin(experimentName: string): void
addActiveVariantListener(experimentName?: string, callback: EmitterCallback): Subscription
addPlayListener(experimentName?: string, callback: EmitterCallback): Subscription
addWinListener(experimentName?: string, callback: EmitterCallback): Subscription
defineVariants(
experimentName: string,
variantNames: string[],
variantWeights: number[]
): void
setActiveVariant(experimentName: string, variantName: string): void
getActiveVariant(experimentName: string): string
calculateActiveVariant(
experimentName: string,
userIdentifier?: string,
defaultVariantName?: string
): string
getSortedVariants(experimentName: string)
}
class ExperimentDebugger {
setDebuggerAvailable(isAvailable: boolean): void
enable(): void
disable(): void
}
export const emitter = new Emitter()
export const experimentDebugger = new ExperimentDebugger()
} |
Any advances in this matter so far? |
I'm working on creating a typings file for this project. I'm curious if you would like to include this in the project - or should I plan on uploading to DefinitelyTyped?
The text was updated successfully, but these errors were encountered: