From 08d820c93bfd29652e4bf4daab50a4e28934555e Mon Sep 17 00:00:00 2001 From: chenyang Date: Sat, 17 Feb 2018 19:52:34 +0800 Subject: [PATCH 1/3] Added new type definition for aoo-root-dir --- types/app-root-dir/app-root-dir-tests.ts | 7 +++++++ types/app-root-dir/index.d.ts | 21 +++++++++++++++++++++ types/app-root-dir/tsconfig.json | 23 +++++++++++++++++++++++ types/app-root-dir/tslint.json | 3 +++ 4 files changed, 54 insertions(+) create mode 100644 types/app-root-dir/app-root-dir-tests.ts create mode 100644 types/app-root-dir/index.d.ts create mode 100644 types/app-root-dir/tsconfig.json create mode 100644 types/app-root-dir/tslint.json diff --git a/types/app-root-dir/app-root-dir-tests.ts b/types/app-root-dir/app-root-dir-tests.ts new file mode 100644 index 0000000000..eecfc42d03 --- /dev/null +++ b/types/app-root-dir/app-root-dir-tests.ts @@ -0,0 +1,7 @@ +import * as rootDir from 'app-root-dir' + +let appRootPath: string + +rootDir.set(__dirname) +appRootPath = rootDir.get() + diff --git a/types/app-root-dir/index.d.ts b/types/app-root-dir/index.d.ts new file mode 100644 index 0000000000..9c7fb51cbc --- /dev/null +++ b/types/app-root-dir/index.d.ts @@ -0,0 +1,21 @@ +import { interfaceExtends } from '../babel-types/index.d' +// Type definitions for [ app-root-dir ] [ 1.0.2 ] +// Project : [ https://github.com/philidem/node-app-root-dir ] +// Definitions by: shaochenyang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface AppRootDir { + // Get the application's root directory + get(): string + /** + * Set the application's root directory + * this will set a global so that no matter + * how many instances of app-root-dir module are installed, + * they will all return the same directory + */ + set(dirname: string): void +} + +declare const AppRootDir: AppRootDir + +export = AppRootDir diff --git a/types/app-root-dir/tsconfig.json b/types/app-root-dir/tsconfig.json new file mode 100644 index 0000000000..c3a03ef0b7 --- /dev/null +++ b/types/app-root-dir/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "app-root-dir-tests.ts" + ] +} diff --git a/types/app-root-dir/tslint.json b/types/app-root-dir/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/app-root-dir/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 78a202e81dd7546e0fa6e4747495db1f4bb4a3fb Mon Sep 17 00:00:00 2001 From: chenyang Date: Sat, 17 Feb 2018 20:28:04 +0800 Subject: [PATCH 2/3] fix: 1.add semicolon 2. tsconfig.types set to [] 3. Correct the index.d.ts header format --- types/app-root-dir/app-root-dir-tests.ts | 9 ++++----- types/app-root-dir/index.d.ts | 13 ++++++------- types/app-root-dir/tsconfig.json | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/types/app-root-dir/app-root-dir-tests.ts b/types/app-root-dir/app-root-dir-tests.ts index eecfc42d03..bff8969927 100644 --- a/types/app-root-dir/app-root-dir-tests.ts +++ b/types/app-root-dir/app-root-dir-tests.ts @@ -1,7 +1,6 @@ -import * as rootDir from 'app-root-dir' +import * as rootDir from 'app-root-dir'; -let appRootPath: string - -rootDir.set(__dirname) -appRootPath = rootDir.get() +let appRootPath: string; +rootDir.set('__dirname'); +appRootPath = rootDir.get(); diff --git a/types/app-root-dir/index.d.ts b/types/app-root-dir/index.d.ts index 9c7fb51cbc..8b0bf5bc6a 100644 --- a/types/app-root-dir/index.d.ts +++ b/types/app-root-dir/index.d.ts @@ -1,21 +1,20 @@ -import { interfaceExtends } from '../babel-types/index.d' -// Type definitions for [ app-root-dir ] [ 1.0.2 ] -// Project : [ https://github.com/philidem/node-app-root-dir ] +// Type definitions for app-root-dir 0.1 +// Project: https://github.com/philidem/node-app-root-dir // Definitions by: shaochenyang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface AppRootDir { // Get the application's root directory - get(): string + get(): string; /** * Set the application's root directory * this will set a global so that no matter * how many instances of app-root-dir module are installed, * they will all return the same directory */ - set(dirname: string): void + set(dirname: string): void; } -declare const AppRootDir: AppRootDir +declare const AppRootDir: AppRootDir; -export = AppRootDir +export = AppRootDir; diff --git a/types/app-root-dir/tsconfig.json b/types/app-root-dir/tsconfig.json index c3a03ef0b7..9fc4a91fff 100644 --- a/types/app-root-dir/tsconfig.json +++ b/types/app-root-dir/tsconfig.json @@ -12,7 +12,7 @@ "typeRoots": [ "../" ], - "types": ["node"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From 8931cb93ce230cf88a7cd16af996fc8abb39d2a6 Mon Sep 17 00:00:00 2001 From: chenyang Date: Sun, 18 Feb 2018 19:38:32 +0800 Subject: [PATCH 3/3] pref: use strict null checking mode --- types/app-root-dir/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/app-root-dir/tsconfig.json b/types/app-root-dir/tsconfig.json index 9fc4a91fff..f378c094db 100644 --- a/types/app-root-dir/tsconfig.json +++ b/types/app-root-dir/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [