mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #31283 from BendingBender/file-type
Enable strictNullChecks for file-type
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import fileType = require("file-type");
|
||||
|
||||
// $ExpectType FileTypeResult | null
|
||||
fileType(new Buffer([0xFF, 0xD8, 0xFF]));
|
||||
fileType(new Uint8Array([0xFF, 0xD8, 0xFF]));
|
||||
|
||||
const minimumBytes: number = fileType.minimumBytes;
|
||||
// $ExpectType number
|
||||
fileType.minimumBytes;
|
||||
|
||||
Vendored
+16
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for file-type 5.2
|
||||
// Type definitions for file-type 10.6
|
||||
// Project: https://github.com/sindresorhus/file-type
|
||||
// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk <https://github.com/tcaesvk>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
@@ -8,7 +8,17 @@
|
||||
|
||||
export = FileType;
|
||||
|
||||
declare function FileType(buf: Buffer | Uint8Array): FileType.FileTypeResult;
|
||||
/**
|
||||
* The file type is detected by checking the
|
||||
* [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
|
||||
*
|
||||
* @param buf It only needs the first `.minimumBytes` bytes. The exception is detection of
|
||||
* `docx`, `pptx`, and `xlsx` which potentially requires reading the whole file.
|
||||
* @returns an Object with:
|
||||
* - ext - One of the [supported file types](https://github.com/sindresorhus/file-type/blob/master/readme.md#supported-file-types)
|
||||
* - mime - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
|
||||
*/
|
||||
declare function FileType(buf: Buffer | Uint8Array): FileType.FileTypeResult | null;
|
||||
|
||||
declare namespace FileType {
|
||||
interface FileTypeResult {
|
||||
@@ -16,5 +26,9 @@ declare namespace FileType {
|
||||
mime: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum amount of bytes needed to detect a file type. Currently,
|
||||
* it's 4100 bytes, but it can change, so don't hard-code it.
|
||||
*/
|
||||
const minimumBytes: number;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"file-type-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user