mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #62624 encoding-japanese: Remove the redundant type and add more tests by @rhysd
* Remove unnecessary `RawType` * Test more array types * Add tests for zenkaku/hankaku conversion
This commit is contained in:
13
types/encoding-japanese/index.d.ts
vendored
13
types/encoding-japanese/index.d.ts
vendored
@@ -27,7 +27,6 @@ type IntArrayType =
|
||||
| Int8Array
|
||||
| Int16Array
|
||||
| Int32Array;
|
||||
type RawType = IntArrayType | ReadonlyArray<number>;
|
||||
type EncodingDetection = Encoding | false;
|
||||
|
||||
export type ConvertOptions =
|
||||
@@ -67,14 +66,14 @@ export interface ConvertUnknownOptions {
|
||||
bom?: boolean | string | undefined;
|
||||
}
|
||||
|
||||
export function detect(data: RawType | string, encodings?: Encoding | Encoding[]): EncodingDetection;
|
||||
export function convert(data: RawType, to: Encoding, from?: Encoding): number[];
|
||||
export function detect(data: IntArrayType | string, encodings?: Encoding | Encoding[]): EncodingDetection;
|
||||
export function convert(data: IntArrayType, to: Encoding, from?: Encoding): number[];
|
||||
export function convert(data: string, to: Encoding, from?: Encoding): string;
|
||||
export function convert(data: RawType | string, options: ConvertStringOptions): string;
|
||||
export function convert(data: RawType | string, options: ConvertArrayBufferOptions): ArrayBuffer;
|
||||
export function convert(data: RawType | string, options: ConvertArrayOptions): number[];
|
||||
export function convert(data: IntArrayType | string, options: ConvertStringOptions): string;
|
||||
export function convert(data: IntArrayType | string, options: ConvertArrayBufferOptions): ArrayBuffer;
|
||||
export function convert(data: IntArrayType | string, options: ConvertArrayOptions): number[];
|
||||
export function convert(data: string, options: ConvertUnknownOptions): string;
|
||||
export function convert(data: RawType, options: ConvertUnknownOptions): number[];
|
||||
export function convert(data: IntArrayType, options: ConvertUnknownOptions): number[];
|
||||
export function urlEncode(data: IntArrayType): string;
|
||||
export function urlDecode(data: string): number[];
|
||||
export function base64Encode(data: IntArrayType): string;
|
||||
|
||||
@@ -9,6 +9,8 @@ const utf8Array_4 = new Uint16Array([1, 2, 3]);
|
||||
const utf8Array_5 = new Uint32Array([1, 2, 3]);
|
||||
const utf8Array_6 = new Int16Array([1, 2, 3]);
|
||||
const utf8Array_7 = new Int32Array([1, 2, 3]);
|
||||
const utf8Array_8 = new Int8Array([1, 2, 3]);
|
||||
const utf8Array_9: ReadonlyArray<number> = [1, 2, 3];
|
||||
Encoding.convert(utf8Array_1, 'SJIS', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_2, 'UTF16', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_3, 'UTF16LE', 'UTF8'); // $ExpectType number[]
|
||||
@@ -16,6 +18,8 @@ Encoding.convert(utf8Array_4, 'UTF16BE', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_5, 'BINARY', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_6, 'UTF32', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_7, 'AUTO', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_8, 'ASCII', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert(utf8Array_9, 'JIS', 'UTF8'); // $ExpectType number[]
|
||||
Encoding.convert('string value', 'UTF16', 'UTF8'); // $ExpectType string
|
||||
|
||||
// Convert character encoding by automatic detection (AUTO detect).
|
||||
@@ -138,3 +142,16 @@ const decoded2 = Encoding.base64Decode(encoded2); // $ExpectType number[]
|
||||
|
||||
Encoding.version; // $ExpectType string
|
||||
Encoding.orders; // $ExpectType string[]
|
||||
|
||||
Encoding.toZenkakuCase([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toZenkakuCase('abcdef'); // $ExpectType string
|
||||
Encoding.toHankakuCase([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toHankakuCase('ABCDEF'); // $ExpectType string
|
||||
Encoding.toZenkanaCase([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toZenkanaCase('アイウエオ'); // $ExpectType string
|
||||
Encoding.toHankanaCase([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toHankanaCase('アイウエオ'); // $ExpectType string
|
||||
Encoding.toZenkakuSpace([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toZenkakuSpace(' '); // $ExpectType string
|
||||
Encoding.toHankakuSpace([1, 2, 3]); // $ExpectType number[]
|
||||
Encoding.toHankakuSpace('\u{3000}'); // $ExpectType string
|
||||
|
||||
Reference in New Issue
Block a user