С помощью машинописного текста 1.8 вы можете приблизиться, если вы определяете функцию как нечто, имеющее все 4 свойства: caller, bind, apply и call:
interface NoCaller {
caller?: void;
}
interface NoBind {
bind?: void;
}
interface NoApply {
apply?: void;
}
interface NoCall {
call?: void;
}
type NotAFunction = NoCaller | NoBind | NoApply | NoCall; // if it fails all 4 checks it's a function
function check<T extends NotAFunction>(t: T) {
// do something
}
function f() {
}
class T {
}
var o = new T();
check({});
check(o);
check({caller: 'ok', call: 3, apply: this});
//check(f); // fails
//check(T); // also fails: classes are functions, you can't really escape from javascript
Удивительно, но сообщение об ошибке не является bad:
error TS2345: Argument of type '() => void' is not assignable to parameter of type 'NoCaller | NoBind | NoApply | NoCall'.
Type '() => void' is not assignable to type 'NoCall'.
Types of property 'call' are incompatible.
Type '(thisArg: any, ...argArray: any[]) => any' is not assignable to type 'void'.
Вы можете передать code
, используя область сеанса для области Flash https://www.playframework.com/documentation/2.6.x/ScalaSessionFlash
Однако, там есть несколько преимуществ для сохранения code
в URL-адресе, таком как