🤖 Merge PR #47624 [node][qs][history] UnknownFacade -> unknown by @OliverJAsh

This commit is contained in:
Oliver Joseph Ash 2020-09-16 23:23:30 +01:00 committed by GitHub
parent 7487d3c1f4
commit cc251bdaf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 9 additions and 37 deletions

View File

@ -153,5 +153,5 @@ let input = { value: '' };
{
const anything: any = {};
const history: History = anything;
history.location.state; // $ExpectType UnknownFacade
history.location.state; // $ExpectType unknown
}

View File

@ -45,14 +45,7 @@ export namespace History {
export type LocationKey = string;
export type LocationListener<S = LocationState> = (location: Location<S>, action: Action) => void;
// TODO: The value type here is a version of `unknown` with an acceptably lossy amount of accuracy.
// Now that TypeScript's DT support is 3.0+, we can look into replacing this with `unknown`.
type UnknownFacade = {} | null | undefined;
/** @deprecated - Use `UnknownFacade` instead. It is a better classifier for the type */
type PoorMansUnknown = UnknownFacade
export type LocationState = UnknownFacade;
export type LocationState = unknown;
export type Path = string;
export type Pathname = string;
export type Search = string;

View File

@ -1142,11 +1142,4 @@ declare namespace NodeJS {
}
type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
// TODO: The value type here is a version of `unknown` with an acceptably lossy amount of accuracy.
// Now that TypeScript's DT support is 3.0+, we can look into replacing this with `unknown`.
type UnknownFacade = {} | null | undefined;
/** @deprecated - Use `UnknownFacade` instead. It is a better classifier for the type */
type PoorMansUnknown = UnknownFacade;
}

View File

@ -11,7 +11,7 @@ declare module "querystring" {
interface ParsedUrlQuery { [key: string]: string | string[]; }
interface ParsedUrlQueryInput {
[key: string]: NodeJS.UnknownFacade;
[key: string]: unknown;
}
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;

View File

@ -1189,11 +1189,4 @@ declare namespace NodeJS {
type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
type ArrayBufferView = TypedArray | DataView;
// TODO: The value type here is a version of `unknown` with an acceptably lossy amount of accuracy.
// Now that TypeScript's DT support is 3.0+, we can look into replacing this with `unknown`.
type UnknownFacade = {} | null | undefined;
/** @deprecated - Use `UnknownFacade` instead. It is a better classifier for the type */
type PoorMansUnknown = UnknownFacade;
}

View File

@ -120,7 +120,7 @@ import { readFile } from 'fs';
const arg0: () => Promise<number> = util.promisify((cb: (err: Error | null, result: number) => void): void => { });
const arg0NoResult: () => Promise<any> = util.promisify((cb: (err: Error | null) => void): void => { });
const arg1: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: Error | null, result: number) => void): void => { });
const arg1UnknownError: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: NodeJS.UnknownFacade, result: number) => void): void => { });
const arg1UnknownError: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: unknown, result: number) => void): void => { });
const arg1NoResult: (arg: string) => Promise<any> = util.promisify((arg: string, cb: (err: Error | null) => void): void => { });
const cbOptionalError: () => Promise<void | {}> = util.promisify((cb: (err?: Error | null) => void): void => { cb(); }); // tslint:disable-line void-return
assert(typeof util.promisify.custom === 'symbol');

9
types/qs/index.d.ts vendored
View File

@ -54,16 +54,9 @@ declare namespace QueryString {
interpretNumericEntities?: boolean;
}
// TODO: The value type here is a version of `unknown` which replicates with an acceptably lossy amount of accuracy.
// When these types support TypeScript 3.0+, we can replace this with `unknown`.
type UnknownFacade = {} | null | undefined;
/** @deprecated - UnknownFacade is more clear about what's going on */
type PoorMansUnknown = UnknownFacade
interface ParsedQs { [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[] }
function stringify(obj: any, options?: IStringifyOptions): string;
function parse(str: string, options?: IParseOptions & { decoder?: never }): ParsedQs;
function parse(str: string, options?: IParseOptions): { [key: string]: UnknownFacade };
function parse(str: string, options?: IParseOptions): { [key: string]: unknown };
}

View File

@ -26,8 +26,8 @@ qs.parse('a=b&c=d', { delimiter: '&' });
}
},
});
obj; // $ExpectType { [key: string]: UnknownFacade; }
obj.a; // $ExpectType UnknownFacade
obj; // $ExpectType { [key: string]: unknown; }
obj.a; // $ExpectType unknown
}
{
@ -40,8 +40,8 @@ qs.parse('a=b&c=d', { delimiter: '&' });
},
};
let obj = qs.parse('a=c', options);
obj; // $ExpectType { [key: string]: UnknownFacade; }
obj.a; // $ExpectType UnknownFacade
obj; // $ExpectType { [key: string]: unknown; }
obj.a; // $ExpectType unknown
}
() => {