Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho committed May 19, 2019
1 parent 30804fb commit c6fecdf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions lib/core.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Formats, Pattern } from "./compiler";
import { MessageFormatPattern } from "intl-messageformat-parser";
interface LocaleData {
export interface LocaleData {
locale: string;
parentLocale?: string;
[k: string]: any;
}
export default class MessageFormat {
static defaultLocale: string;
static __localeData__: Record<string, any>;
static __localeData__: Record<string, LocaleData>;
static readonly formats: Formats;
private _locale;
private pattern;
Expand All @@ -23,4 +23,3 @@ export default class MessageFormat {
_compilePattern(ast: MessageFormatPattern, locales: string | string[], formats: Formats): Pattern[];
_format(pattern: Pattern[], values?: Record<string, string | number | boolean | null | undefined>): string;
}
export {};
2 changes: 1 addition & 1 deletion lib/core.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import parser, { MessageFormatPattern } from "intl-messageformat-parser";

// -- MessageFormat --------------------------------------------------------

interface LocaleData {
export interface LocaleData {
locale: string
parentLocale?: string
[k: string]: any
}

export default class MessageFormat {
public static defaultLocale: string = "en";
public static __localeData__: Record<string, any> = {};
public static __localeData__: Record<string, LocaleData> = {};
// Default format options used as the prototype of the `formats` provided to the
// constructor. These are used when constructing the internal Intl.NumberFormat
// and Intl.DateTimeFormat instances.
Expand Down Expand Up @@ -89,7 +89,7 @@ export default class MessageFormat {
}
};
private _locale: string;
private pattern: ReturnType<Compiler["compile"]>;
private pattern: Pattern[];
private message: string;
constructor(
message: string,
Expand Down
7 changes: 4 additions & 3 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require("intl-pluralrules");
const expect = require("expect.js");
import IntlMessageFormat from "../src/locales";
import { LocaleData } from "../src/core";

describe("IntlMessageFormat", function() {
it("should be a function", function() {
Expand Down Expand Up @@ -36,13 +37,13 @@ describe("IntlMessageFormat", function() {

describe("`locale`", function() {
var IMFLocaleData = IntlMessageFormat.__localeData__;
var localeData: Record<string, string> = {};
var localeData: Record<string, LocaleData> = {};

// Helper to remove and replace the locale data available during the
// the different tests.
function transferLocaleData(
from: Record<string, string>,
to: Record<string, string>
from: Record<string, LocaleData>,
to: Record<string, LocaleData>
) {
for (var locale in from) {
if (Object.prototype.hasOwnProperty.call(from, locale)) {
Expand Down

0 comments on commit c6fecdf

Please sign in to comment.