Merge pull request #30552 from Microsoft/omit

Add the Omit helper type
This commit is contained in:
Daniel Rosenwasser 2019-04-04 13:37:33 -04:00 committed by GitHub
commit 586ecbf1d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 38 additions and 9 deletions

View file

@ -4507,6 +4507,7 @@ namespace FourSlashInterface {
typeEntry("Record"),
typeEntry("Exclude"),
typeEntry("Extract"),
typeEntry("Omit"),
typeEntry("NonNullable"),
typeEntry("Parameters"),
typeEntry("ConstructorParameters"),

5
src/lib/es5.d.ts vendored
View file

@ -1443,6 +1443,11 @@ type Exclude<T, U> = T extends U ? never : T;
*/
type Extract<T, U> = T extends U ? T : never;
/**
* Construct a type with the properties of T except for those in type K.
*/
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
/**
* Exclude null and undefined from T
*/

View file

@ -45,10 +45,14 @@ const myStoreConnect: Connect = function(
mergeProps,
options,
);
};
};
export {};
//// [circularlySimplifyingConditionalTypesNoCrash.js]
"use strict";
exports.__esModule = true;
var myStoreConnect = function (mapStateToProps, mapDispatchToProps, mergeProps, options) {
if (options === void 0) { options = {}; }
return connect(mapStateToProps, mapDispatchToProps, mergeProps, options);

View file

@ -152,3 +152,6 @@ const myStoreConnect: Connect = function(
);
};
export {};

View file

@ -90,3 +90,6 @@ const myStoreConnect: Connect = function(
);
};
export {};

View file

@ -8,8 +8,10 @@ type Omit1<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;
type Omit2<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
type O = Omit<{ a: number, b: string }, 'a'>
const o: O = { b: '' }
export const o: O = { b: '' }
//// [indexedAccessRetainsIndexSignature.js]
var o = { b: '' };
"use strict";
exports.__esModule = true;
exports.o = { b: '' };

View file

@ -55,8 +55,8 @@ type O = Omit<{ a: number, b: string }, 'a'>
>a : Symbol(a, Decl(indexedAccessRetainsIndexSignature.ts, 8, 15))
>b : Symbol(b, Decl(indexedAccessRetainsIndexSignature.ts, 8, 26))
const o: O = { b: '' }
>o : Symbol(o, Decl(indexedAccessRetainsIndexSignature.ts, 9, 5))
export const o: O = { b: '' }
>o : Symbol(o, Decl(indexedAccessRetainsIndexSignature.ts, 9, 12))
>O : Symbol(O, Decl(indexedAccessRetainsIndexSignature.ts, 6, 67))
>b : Symbol(b, Decl(indexedAccessRetainsIndexSignature.ts, 9, 14))
>b : Symbol(b, Decl(indexedAccessRetainsIndexSignature.ts, 9, 21))

View file

@ -21,7 +21,7 @@ type O = Omit<{ a: number, b: string }, 'a'>
>a : number
>b : string
const o: O = { b: '' }
export const o: O = { b: '' }
>o : Pick<{ a: number; b: string; }, "b">
>{ b: '' } : { b: string; }
>b : string

View file

@ -143,6 +143,8 @@ const Test1 = connect(
null,
mapDispatchToProps
)(TestComponent);
export {};
//// [reactReduxLikeDeferredInferenceAllowsAssignment.js]
@ -196,6 +198,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
var _this = this;
exports.__esModule = true;
var simpleAction = function (payload) { return ({
type: "SIMPLE_ACTION",
payload: payload

View file

@ -469,3 +469,5 @@ const Test1 = connect(
)(TestComponent);
>TestComponent : Symbol(TestComponent, Decl(reactReduxLikeDeferredInferenceAllowsAssignment.ts, 134, 1))
export {};

View file

@ -286,3 +286,5 @@ const Test1 = connect(
)(TestComponent);
>TestComponent : typeof TestComponent
export {};

View file

@ -45,4 +45,6 @@ const myStoreConnect: Connect = function(
mergeProps,
options,
);
};
};
export {};

View file

@ -7,4 +7,4 @@ type Omit1<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;
type Omit2<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
type O = Omit<{ a: number, b: string }, 'a'>
const o: O = { b: '' }
export const o: O = { b: '' }

View file

@ -143,3 +143,5 @@ const Test1 = connect(
null,
mapDispatchToProps
)(TestComponent);
export {};