read-json-sync: initial definition (#43755)

This commit is contained in:
Junxiao Shi
2020-04-10 22:42:45 -04:00
committed by GitHub
parent 368934537f
commit 18d07f6b56
4 changed files with 43 additions and 0 deletions

15
types/read-json-sync/index.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
// Type definitions for read-json-sync 2.0
// Project: https://github.com/shinnn/read-json-sync#readme
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
/// <reference types="node"/>
import { readFileSync } from "fs";
import { URL } from "url";
type ReadFileOptions = Extract<Parameters<typeof readFileSync>[1], object>;
declare function readJsonSync(path: string|Buffer|URL|number, options?: ReadFileOptions|string): any;
export = readJsonSync;

View File

@@ -0,0 +1,4 @@
import readJsonSync = require("read-json-sync");
readJsonSync("file.json", "utf8");
readJsonSync(1, { encoding: "gb2312" });

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"read-json-sync-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }