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
// Указать тип | |
const style :ComponentButton = require<ComponentButton>('button.css'); | |
// Если указали тип, то и генерик уже не нужен | |
const style :ComponentButton = require('button.css'); | |
// Применить typecast | |
const style = <ComponentButton> require<ComponentButton>('button.css'); | |
// Ну тогда генерик и ненужен | |
const style = <ComponentButton> require('button.css'); |
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
// Где-то в декларации прописано так: | |
declare var require: <T>(s :string) => T; | |
// Есть интерфейсы | |
interface ICSSModule { | |
font :string; | |
background :string; | |
} | |
interface ComponentButton extends ICSSModule { |
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
#!/bin/sh | |
local prefix=$2 | |
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') | |
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | |
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | | |
awk -F$fs '{ | |
indent = length($1)/2; |
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
function logClass(target:any, filterName?:string):any { | |
var original = target; | |
function construct(constructor, args) { | |
let c:any = function () { | |
return constructor.apply(this, args); | |
}; | |
c.prototype = constructor.prototype; | |
return new c; | |
} |
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
//"use strict"; | |
function logProperty(target:Object, key:string):void { | |
var val:any = this[key]; | |
const getter = function():any { | |
console.log(`Get: ${key} => ${val}`); | |
return val; | |
}; |
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
"use strict"; | |
function logParameter(target:Object, key:string, index:number) { | |
var metadataKey = `log_${key}_parameters`; | |
if (Array.isArray(target[metadataKey])) { | |
target[metadataKey].push(index); | |
} | |
else { | |
target[metadataKey] = [index]; | |
} |
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
"use strict"; | |
function logClass(target:any):any { | |
// save a reference to the original constructor | |
var original = target; | |
// a utility function to generate instances of a class | |
function construct(constructor, args) { | |
let c:any = function(){ |
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
"use strict"; | |
/** | |
* Декоратор для логирования свойств | |
* @param target | |
* @param key | |
*/ | |
function logprop(target:any, key:string):any { | |
var val:any, |
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
/** | |
* Декоратор для логирования статических свойств | |
* @param target | |
* @param key | |
*/ | |
function log_static_prop(target:any, key:string):any { | |
var val = target[key]; | |
return { | |
get: ():any => { | |
console.log(`Get: ${key} => ${val}`); |
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
/** | |
* Декоратор для логирования свойств | |
* @param target | |
* @param key | |
*/ | |
function logprop(target:any, key:string):void { | |
// получаем значение свойства | |
var val:any = this[key]; |