Skip to content

Commit

Permalink
fromatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pero5ar committed Sep 9, 2021
1 parent 9193f85 commit 95559ec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion 002.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ declare function verifyOIB(oib: string): boolean;

function payTaxes(entity: Human | Company): void {
verifyOIB(entity.oib);
// entity.companyName; -> Property 'companyName' does not exist on type 'Human'.ts(2339)
// entity.companyName;
// result: Property 'companyName' does not exist on type 'Human'.ts(2339)

let name: string;
if ('companyName' in entity) {
Expand Down
2 changes: 1 addition & 1 deletion 003.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let _myObject: ObjectInterface;
_myObject!.a // string
_myObject!.b // string

// Side note: Notice the `!` part, use it wisely
// Side note: Notice the `!` operator, use it wisely

// This throws an error:
// type ObjectType = {
Expand Down
8 changes: 6 additions & 2 deletions 007.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
* };
* type ResultType = KeyOfType<ExampleType, 'x'>; // "a" | "b" | "c" | "d" | "e"
*/
declare type KeyOfType<T, Type> = { [K in keyof T]: T[K] extends Type ? K : never}[keyof T];
declare type KeyOfType<T, Type> = {
[K in keyof T]: T[K] extends Type ? K : never
}[keyof T];

/**
* Get all keys of `T` that are assignable to `Type`.
Expand All @@ -118,7 +120,9 @@ declare type KeyOfType<T, Type> = { [K in keyof T]: T[K] extends Type ? K : neve
* };
* type ResultType = KeyWithType<ExampleType, 'x'>; // "a" | "b" | "c" | "d" | "f"
*/
declare type KeyWithType<T, Type> = { [K in keyof T]: Type extends T[K] ? K : never}[keyof T];
declare type KeyWithType<T, Type> = {
[K in keyof T]: Type extends T[K] ? K : never
}[keyof T];


// ---
Expand Down
2 changes: 1 addition & 1 deletion 008.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface OwnProps {
id: number;
}

function mapStateToProps<T>(rootState: RootStoreState, ownProps: OwnProps) {
function mapStateToProps(rootState: RootStoreState, ownProps: OwnProps) {
return {
value: rootState.targetReducer.lookup[ownProps.id]
}
Expand Down

0 comments on commit 95559ec

Please sign in to comment.