Any
The Any
type represents any type.
type.Any
Like an identity function, type.Any
is a TypeObject that allows any type of a value to be allowed without checking or coercion.
import { ObservableObject, type } from "can";
class EnvironmentVariable extends ObservableObject {
static props = {
value: type.Any
};
}
let env = new EnvironmentVariable();
env.value = 42;
console.log(env.value); // -> 42
env.value = null;
console.log(env.value); // -> null
env.value = [];
console.log(env.value); // -> []
env.value = new Date();
console.log(env.value); // -> Date
type.Any
returns the same instance as passed into convert so they are referentially identical.
import { ObservableObject, type } from "can";
class Schedule extends ObservableObject {
static props = {
firstPeriod: type.Any
};
}
let today = new Date();
let sched = new Schedule();
sched.firstPeriod = today;
console.log(sched.firstPeriod === today); // -> true
console.log(sched.firstPeriod); // -> today