bobril-g11n
Advanced tools
Comparing version 5.0.3 to 5.0.4
# CHANGELOG | ||
## 5.0.4 | ||
Make it compatible with noPropertyAccessFromIndexSignature. | ||
## 5.0.3 | ||
@@ -4,0 +8,0 @@ |
@@ -0,0 +0,0 @@ export * from './src/msgFormatParser'; |
{ | ||
"name": "bobril-g11n", | ||
"version": "5.0.3", | ||
"version": "5.0.4", | ||
"description": "Bobril globalization", | ||
@@ -30,2 +30,3 @@ "main": "index.js", | ||
"noUncheckedIndexedAccess": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"strict": true, | ||
@@ -32,0 +33,0 @@ "strictNullChecks": true |
@@ -42,4 +42,3 @@ import { MsgAst } from "./msgFormatParser"; | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
extractUsedParamsRec(usedParams, opt.value); | ||
extractUsedParamsRec(usedParams, options[i]!.value!); | ||
} | ||
@@ -54,4 +53,5 @@ break; | ||
for (let i = 0; i < options.length; i++) { | ||
if (typeof options[i].value === "object") { | ||
extractUsedParamsRec(usedParams, options[i].value); | ||
let opt = options[i]!; | ||
if (typeof opt.value === "object") { | ||
extractUsedParamsRec(usedParams, opt.value); | ||
} | ||
@@ -58,0 +58,0 @@ } |
@@ -12,3 +12,13 @@ import { isObject, isArray } from "bobril"; | ||
| { type: "el"; id: number; value?: MsgAst } | ||
| { type: "format"; id: string; format: Record<string, any> } | ||
| { | ||
type: "format"; | ||
id: string; | ||
format: { | ||
type: string; | ||
style?: string; | ||
offset?: number; | ||
ordinal?: boolean; | ||
options: { key?: string; selector?: number | string; value?: MsgAst }[]; | ||
}; | ||
} | ||
| { type: "concat"; values: Array<MsgAst> }; | ||
@@ -15,0 +25,0 @@ |
@@ -178,5 +178,5 @@ import * as moment from "moment"; | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
let opt = options[i]!; | ||
if (typeof opt.selector !== "number") continue; | ||
let fn = comp.addConstant(compile(locale, opt.value)); | ||
let fn = comp.addConstant(compile(locale, opt.value!)); | ||
comp.addBody( | ||
@@ -189,9 +189,9 @@ `if (${localArgOffset}===${opt.selector}) return ${fn}(${argParams},''+${localArgOffset});` | ||
comp.addBody( | ||
`var ${localCase}=${pluralFn}(${localArgOffset},${msgAst.format.ordinal ? "true" : "false"});` | ||
`var ${localCase}=${pluralFn}(${localArgOffset},${msgAst.format.ordinal ? "!0" : "!1"});` | ||
); | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
let opt = options[i]!; | ||
if (typeof opt.selector !== "string") continue; | ||
if (opt.selector === "other") continue; | ||
let fn = comp.addConstant(compile(locale, opt.value)); | ||
let fn = comp.addConstant(compile(locale, opt.value!)); | ||
comp.addBody( | ||
@@ -204,5 +204,5 @@ `if (${localCase}===${comp.addConstant( | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
let opt = options[i]!; | ||
if (opt.selector !== "other") continue; | ||
let fn = comp.addConstant(compile(locale, opt.value)); | ||
let fn = comp.addConstant(compile(locale, opt.value!)); | ||
comp.addBody(`return ${fn}(${argParams},''+${localArgOffset});`); | ||
@@ -215,6 +215,6 @@ } | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
let opt = options[i]!; | ||
if (typeof opt.selector !== "string") continue; | ||
if (opt.selector === "other") continue; | ||
let fn = comp.addConstant(compile(locale, opt.value)); | ||
let fn = comp.addConstant(compile(locale, opt.value!)); | ||
comp.addBody( | ||
@@ -227,5 +227,5 @@ `if (${localArg}===${comp.addConstant( | ||
for (let i = 0; i < options.length; i++) { | ||
let opt = options[i]; | ||
let opt = options[i]!; | ||
if (opt.selector !== "other") continue; | ||
let fn = comp.addConstant(compile(locale, opt.value)); | ||
let fn = comp.addConstant(compile(locale, opt.value!)); | ||
comp.addBody(`return ${fn}(${argParams},${localArg});`); | ||
@@ -241,17 +241,18 @@ } | ||
if (options) { | ||
let opt = {}; | ||
let opts = {} as Record<string, any>; | ||
let complex = false; | ||
for (let i = 0; i < options.length; i++) { | ||
if (typeof options[i].value === "object") { | ||
let opt = options[i]!; | ||
if (typeof opt.value === "object") { | ||
complex = true; | ||
(<any>opt)[options[i].key] = null; | ||
opts[opt.key!] = null; | ||
} else { | ||
let val = options[i].value; | ||
let val = opt.value as string | boolean | undefined; | ||
if (val === undefined) val = true; | ||
(<any>opt)[options[i].key] = val; | ||
opts[opt.key!] = val; | ||
} | ||
} | ||
let formatFn = comp.addConstant(AnyFormatter(locale, type, style, opt)); | ||
let formatFn = comp.addConstant(AnyFormatter(locale, type, style, opts)); | ||
if (complex) { | ||
let optConst = comp.addConstant(opt); | ||
let optConst = comp.addConstant(opts); | ||
let optLocal = comp.addLocal(); | ||
@@ -261,8 +262,7 @@ let hashArg = comp.addArg(1); | ||
for (let i = 0; i < options.length; i++) { | ||
if (typeof options[i].value === "object") { | ||
let fnConst = comp.addConstant(compile(locale, options[i].value)); | ||
let opt = options[i]!; | ||
if (typeof opt.value === "object") { | ||
let fnConst = comp.addConstant(compile(locale, opt.value)); | ||
comp.addBody( | ||
`${optLocal}[${comp.addConstant( | ||
options[i].key | ||
)}]=${fnConst}(${argParams},${hashArg});` | ||
`${optLocal}[${comp.addConstant(opt.key)}]=${fnConst}(${argParams},${hashArg});` | ||
); | ||
@@ -273,3 +273,3 @@ } | ||
} else { | ||
comp.addBody(`return ${formatFn}(${localArg},${comp.addConstant(opt)});`); | ||
comp.addBody(`return ${formatFn}(${localArg},${comp.addConstant(opts)});`); | ||
} | ||
@@ -276,0 +276,0 @@ } else { |
@@ -9,2 +9,3 @@ { | ||
"experimentalDecorators": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react", | ||
@@ -27,5 +28,5 @@ "lib": [ | ||
"noUncheckedIndexedAccess": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"preserveConstEnums": false, | ||
"reactNamespace": "b", | ||
@@ -42,3 +43,3 @@ "removeComments": false, | ||
"files": [ | ||
"C:/Users/b.letocha/.bbcore/tools/jasmine330.d.ts" | ||
"C:/Users/boris/.bbcore/tools/jasmine330.d.ts" | ||
], | ||
@@ -45,0 +46,0 @@ "include": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56454
1290