This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
// tworzymy listę tablicową | |
var list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useInjection } from './ioc.react'; | |
import { IProvider } from './providers'; | |
export const Hello: React.FC = () => { | |
const provider = useInjection<IProvider<string>>('nameProvider'); | |
return ( | |
<h1>Hello {provider.provide()}!</h1> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import { Container, interfaces } from 'inversify'; | |
const InversifyContext = React.createContext<{ container: Container | null }>({ container: null }); | |
type Props = { | |
container: Container; | |
}; | |
export const Provider: React.FC<Props> = (props) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'reflect-metadata'; | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { Hello } from './Hello'; | |
import { container } from './ioc'; | |
import { Provider } from './ioc.react'; | |
const App: React.FC = () => { | |
return ( | |
<Provider container={container}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Container } from 'inversify'; | |
const InversifyContext = React.createContext<{ container: Container | null }>({ container: null }); | |
type Props = { | |
container: Container; | |
}; | |
export const Provider: React.FC<Props> = (props) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useInjection } from './ioc.react'; | |
import { IProvider } from './providers'; | |
export const Hello: React.FC = () => { | |
const provider: IProvider<string>; // here we need to inject our provider | |
return ( | |
<h1>Hello {provider.provide()}!</h1> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type C = { a: string; b: string; c: boolean; d: string; } | |
type D = { b: string; c: boolean; } | |
type ComitKeys = Omit<C, 'c'>; | |
type ComitD = Omit<C, keyof D>; | |
const e: ComitKeys = { a: 'b', b: 'b', d: 'd' }; // c doesn't exist | |
const f: ComitD = { a: 'b', d: 'd' }; // b, c doesn't exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type E = { a: string; b: string; } | |
function withPick<K extends keyof E>(state: Pick<E, K>): void { return; } | |
function withPartial<E>(state: Partial<E>) { return; } | |
withPick({ a: null }); // 'null' is not assignable to type string | |
withPartial({ a: null }); // no error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type C = { a: string; b: string; c: boolean; d: string; } | |
type D = { b: string; c: boolean; } | |
type pickCkeys = Pick<C, 'c'> | |
type pickCD = Pick<C, keyof D>; | |
const c: pickCkeys = { c: true }; // a, b, d doesn't exist | |
const d: pickCD = { b: 'a', c: true }; // a, d doesn't exist |
NewerOlder