diff --git a/README.md b/README.md index 157b4d3..a81930b 100644 --- a/README.md +++ b/README.md @@ -106,4 +106,3 @@ pluralize(21, 'рубль', 'рубля', 'рублей'); # См.также + Подробно о склонении числительных в русском языке с примерами: http://numeralonline.ru/ -+ TypeScript: https://github.com/types/npm-numeralize-ru diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..73b2fe2 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,20 @@ +export = numeralize; + +declare function numeralize(number: number, gender?: numeralize.Gender, kase?: numeralize.Case, animate?: boolean): string; + +declare namespace numeralize { + export type Gender = number; + export const GENDER_MASCULINE: Gender; + export const GENDER_FEMININE: Gender; + export const GENDER_NEUTER: Gender; + + export type Case = number; + export const CASE_NOMINATIVE: Case; + export const CASE_GENITIVE: Case; + export const CASE_DATIVE: Case; + export const CASE_ACCUSATIVE: Case; + export const CASE_INSTRUMENTAL: Case; + export const CASE_PREPOSITIONAL: Case; + + export function pluralize(count: number, one: string, two: string, five: string): string; +} diff --git a/package.json b/package.json index a09b0a2..6b46ce6 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,12 @@ { "name": "numeralize-ru", - "version": "1.0.0", + "version": "1.0.1", "description": "Russian numerals", "main": "index.js", "scripts": { - "test": "./node_modules/.bin/mocha", + "test": "npm run test:js; npm run test:ts", + "test:js": "./node_modules/.bin/mocha", + "test:ts": "./node_modules/.bin/tsc ./test/*.d.spec.ts --noEmit --noImplicitAny --strictNullChecks --target ES6", "dev": "./node_modules/.bin/mocha --watch" }, "keywords": [ @@ -21,7 +23,8 @@ "author": "anotherpit ", "license": "MIT", "devDependencies": { - "mocha": "^2.4.5" + "mocha": "^2.4.5", + "typescript": "^2.0.10" }, "repository": { "type": "git", diff --git a/test/index.d.spec.ts b/test/index.d.spec.ts new file mode 100644 index 0000000..52d9f7b --- /dev/null +++ b/test/index.d.spec.ts @@ -0,0 +1,19 @@ +import * as numeralize from '../index'; + +let g: numeralize.Gender; +g = numeralize.GENDER_MASCULINE; +g = numeralize.GENDER_FEMININE; +g = numeralize.GENDER_NEUTER; + +let c: numeralize.Case; +c = numeralize.CASE_NOMINATIVE; +c = numeralize.CASE_GENITIVE; +c = numeralize.CASE_DATIVE; +c = numeralize.CASE_ACCUSATIVE; +c = numeralize.CASE_INSTRUMENTAL; +c = numeralize.CASE_PREPOSITIONAL; + +let s: string; +s = numeralize(123, g, c, true); +s = numeralize.pluralize(123, 'рубль', 'рубля', 'рублей'); + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..564ed18 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noImplicitAny": true, + "strictNullChecks": true, + "target": "es6" + } +}