[os-locale] add typings for v2, add strict null checks & linting (#18732)

This commit is contained in:
Dimitri Benin
2017-08-08 13:50:03 -07:00
committed by Mohamed Hegazy
parent f340893290
commit 734ea84afc
8 changed files with 72 additions and 17 deletions
+11 -7
View File
@@ -1,13 +1,17 @@
// Type definitions for os-locale 1.4.0
// Type definitions for os-locale 2.1
// Project: https://github.com/sindresorhus/os-locale
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = osLocale;
declare function osLocale(options: { spawn?: boolean }, cb: (err: any, locale: string) => void): void;
declare function osLocale(cb: (err: any, locale: string) => void): void;
declare function osLocaleSync(): string;
declare function osLocaleSync(options: { spawn?: boolean }): string;
declare function osLocale(options?: osLocale.Options): Promise<string>;
export { osLocaleSync as sync };
export default osLocale;
declare namespace osLocale {
function sync(options?: Options): string;
interface Options {
spawn?: boolean;
}
}
+8 -8
View File
@@ -1,11 +1,11 @@
import osLocale = require('os-locale');
import osLocale, { sync } from 'os-locale';
osLocale((err: any, locale: string) => {
osLocale().then(locale => {
const str: string = locale;
});
osLocale({spawn: false}).then(locale => {
const str: string = locale;
});
osLocale({spawn: false}, (err: any, locale: string) => {
});
var locale1: string = sync();
var locale2: string = sync({spawn: false});
const locale1: string = osLocale.sync();
const locale2: string = osLocale.sync({spawn: false});
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -19,4 +19,4 @@
"index.d.ts",
"os-locale-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for os-locale 1.4
// Project: https://github.com/sindresorhus/os-locale
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = osLocale;
declare function osLocale(options: { spawn?: boolean }, cb: (err: any, locale: string) => void): void;
declare function osLocale(cb: (err: any, locale: string) => void): void;
declare namespace osLocale {
function sync(options?: { spawn?: boolean }): string;
}
+10
View File
@@ -0,0 +1,10 @@
import osLocale = require('os-locale');
osLocale((err: any, locale: string) => {
});
osLocale({spawn: false}, (err: any, locale: string) => {
});
const locale1: string = osLocale.sync();
const locale2: string = osLocale.sync({spawn: false});
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"os-locale": ["os-locale/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"os-locale-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }