In the above file the first two types work in both ts compiler and webstorm. The final type works in ts compiler but fails in Web Storm
class Module: | |
@property | |
def session(self): | |
local = threading.local() | |
_session = getattr(local, 'session', None) | |
if _session is None: | |
local.session = build_session() | |
return _session | |
sys.modules[__name__] = Module() |
import {and as bool_and} from 'boolean' | |
import {and as num_and} from 'number' | |
@operator | |
export const and = overload(bool_and, num_and) |
As engineers we often hear about best practices, but we also see so many smart people disagree about what is or isn't best practice. While some things seem relatively clear and agreed upon many aren't. Many are often vigorously disagreed upon. These disagreements often happend between people at the top of their field. So what's the deal? Is one group just wrong?
I would like to posit that they can both be right but in different contexts. When you put a bunch of smart, motivated, passionate, and caring people together and give them a task to solve it is reasonable that they will do a good job within the context and constraints that they are working. Context and constraints being the key words there.
We all come from different places and are trying to solve different problems. To think that all our problems are the same and thus have the same solution is just as silly as to think that all our problems are completely unique. So many incredible people have come before us and we should learn from them and what
// this doesn't work just yet but I'm trying to figure out the idea because async testing in jest is driving me nuts | |
async function fixAsyncErrors(action: (expect: (x) => Matchers) => Promise<any>|void) { | |
let errors = new Array(); | |
await (action(x => { | |
let matchers = expect(x); | |
let matcherProps = Object.getOwnPropertyNames(matchers); | |
let safeMatchers = matcherProps.reduce((safeMatchers, p) => { | |
let safe = typeof matchers[p] === 'function' ? (...args) => { | |
try { matchers[p](...args); } | |
catch (e) { errors.push(e); console.error(e) } |
@editorFor("record", FieldSet, {isDefault: true}) | |
export class RecordEditor extends BaseEditorModel<{[key:string]:any}, RecordSchemaType, BaseEditorModel<RecordSchemaType>, void> { | |
render() { | |
let recordType = this.props.field.typeParameters.typeParams as SchemaRecordType; | |
let fields = recordType.fields; | |
return (<>{ | |
fields.map(field => | |
<FieldEditor value={this.props.value[field.name]} field={field} context={createContext(field, this.props.context)}/> | |
)} | |
</>) |
@model | |
export class Field { | |
@field("text", "Name", SchemaEntryType.entry, { required: true }) | |
name: string; | |
@field("text", "Label", SchemaEntryType.entry, { required: true }) | |
label: string; | |
@field("code", "Type", SchemaEntryType.selection, { required: true }) | |
typeName: string; |
@editorFor("numeric", InputBoxLabelContainer, { isDefault: true }) | |
export class NumericEditor extends BaseEditor<Numeric, NumericTypeInfo, BaseEditorModel<Numeric>, void> { | |
render() { | |
return ( | |
<input type="number" | |
id={this.uniqueId()} | |
value={this.value().toEditorString()} | |
required={this.field().required} | |
max={this.props.field.max || undefined} | |
min={this.props.field.min || undefined} |
import {Maybe, Nothing} from "CoreTypes"; | |
export type IdTypes = string|number; | |
export type IdRequest<TId extends IdTypes> = { id?: Maybe<TId> }; | |
export type QueryRequest<TQuery> = { query?: Maybe<TQuery> }; | |
export type ActionRequest = { action?: Maybe<string>; }; | |
export interface RestfulClient { | |
Get<TResult, TQuery, TId extends IdTypes>( | |
resourceUrl: string, | |
requestParams?: IdRequest<TId> & QueryRequest<TQuery> & ActionRequest): Promise<TResult> |