Skip to content
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

Fix text prop type #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/createCnt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Map } from 'immutable';
import * as React from 'react';
import { classifyKey } from './classifyKey';
import { MsgClickHanlder } from './translator';
import { MsgClickHandler } from './translator';
import { TranslationResult } from './types';

export interface CntProps {
Expand All @@ -10,7 +10,7 @@ export interface CntProps {
}

export interface CreateCnt {
(key: string, result: TranslationResult, onClick?: MsgClickHanlder): JSX.Element;
(key: string, result: TranslationResult, onClick?: MsgClickHandler): JSX.Element;
}

export const createCnt: CreateCnt = (key, result, onClick) => {
Expand Down Expand Up @@ -56,7 +56,7 @@ export const createCnt: CreateCnt = (key, result, onClick) => {

export const memoizeCreateCnt = (fn: CreateCnt) => {
let memoizeCache = Map<string, Map<TranslationResult, JSX.Element>>();
return (key: string, result: TranslationResult, onClick?: MsgClickHanlder): JSX.Element => {
return (key: string, result: TranslationResult, onClick?: MsgClickHandler): JSX.Element => {
if (memoizeCache.hasIn([key, result])) {
return memoizeCache.getIn([key, result]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/translate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface HasMsgFunc {
export interface TranslateProps {
cnt: CntFunc;
msg: CntFunc;
text: Msg;
text: TextFunc;
hasMsg: HasMsgFunc;
resolveMsg: Resolve;
formatDate: FormatDate;
Expand Down
8 changes: 4 additions & 4 deletions src/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface Msg {
(key: string | string[], options?: MsgOptions): TranslationResult;
}

export interface MsgClickHanlder {
export interface MsgClickHandler {
(key: string | string[], element: React.Component<any, any>): void;
}

Expand Down Expand Up @@ -49,7 +49,7 @@ export class Translator {
fallbackLocale = '';
store: AppStore | null = null;
connector: Connector | undefined;
listeners: MsgClickHanlder[] = [];
listeners: MsgClickHandler[] = [];

constructor(options: TranslatorOptions | AppStore, connector?: Connector) {
if (isAppStore(options)) {
Expand All @@ -62,11 +62,11 @@ export class Translator {
this.connector = connector;
}

onMsgClick: MsgClickHanlder = (key, element) => {
onMsgClick: MsgClickHandler = (key, element) => {
this.listeners.forEach((listener) => listener(key, element));
}

subscribeMsgClick(listener: MsgClickHanlder): () => void {
subscribeMsgClick(listener: MsgClickHandler): () => void {
this.listeners.push(listener);

const unsubscribe = () => {
Expand Down