mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Deprecate disableAutoBOM as per file-saver 2.0 (#35617)
* Deprecate `disableAutoBOM` as per FileSaver 2.0 * Lint rules
This commit is contained in:
parent
6bad2d5410
commit
283d30a07a
@ -1,9 +1,22 @@
|
||||
import "file-saver";
|
||||
import { FileSaverOptions } from "file-saver";
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function.
|
||||
*/
|
||||
function testSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
const options: FileSaverOptions = {
|
||||
autoBom: false
|
||||
};
|
||||
|
||||
saveAs(data, filename, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for deprecated "saveAs" function.
|
||||
*/
|
||||
function testDeprecatedSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
const disableAutoBOM = true;
|
||||
@ -17,9 +30,11 @@ function testSaveAs() {
|
||||
function testWindowSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
const disableAutoBOM = true;
|
||||
const options: FileSaverOptions = {
|
||||
autoBom: false
|
||||
};
|
||||
|
||||
window.saveAs(data, filename, disableAutoBOM);
|
||||
window.saveAs(data, filename, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -28,9 +43,11 @@ function testWindowSaveAs() {
|
||||
function testUrlSaveAs() {
|
||||
const url = 'https://example.com/test.txt';
|
||||
const filename = 'hello world.txt';
|
||||
const disableAutoBOM = true;
|
||||
const options: FileSaverOptions = {
|
||||
autoBom: false
|
||||
};
|
||||
|
||||
window.saveAs(url, filename, disableAutoBOM);
|
||||
window.saveAs(url, filename, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
19
types/file-saver/index.d.ts
vendored
19
types/file-saver/index.d.ts
vendored
@ -3,15 +3,34 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Daniel Roth <https://github.com/DaIgeb>
|
||||
// Chris Barr <https://github.com/chrismbarr>
|
||||
// HitkoDev <https://github.com/HitkoDev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/file-saver
|
||||
|
||||
declare namespace FileSaver {
|
||||
interface FileSaverOptions {
|
||||
/**
|
||||
* Automatically provide Unicode text encoding hints
|
||||
* @default false
|
||||
*/
|
||||
autoBom: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
|
||||
* @param data - The actual file data blob or URL.
|
||||
* @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
|
||||
* @param options - Optional FileSaver.js config
|
||||
*/
|
||||
function saveAs(data: Blob | string, filename?: string, options?: FileSaverOptions): void;
|
||||
|
||||
/**
|
||||
* FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
|
||||
* @param data - The actual file data blob or URL.
|
||||
* @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
|
||||
* @param disableAutoBOM - Optional & defaults to `false`. Set to `true` if you want FileSaver.js to automatically provide Unicode text encoding hints
|
||||
* @deprecated use `{ autoBom: false }` as the third argument
|
||||
*/
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
function saveAs(data: Blob | string, filename?: string, disableAutoBOM?: boolean): void;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user