<commit_before>import Vue = require('vue')
import {ComponentOptions, PropOptions, VClass, $$Prop} from './interface'
import {Component} from './core'

import {getReflectType} from './util'

const PROP_KEY = '$$Prop' as $$Prop

type Props = {[key: string]: PropOptions}

export function Prop(target: Vue, key: string): void {
  let propKeys: string[] = target[PROP_KEY] = target[PROP_KEY] || []
  propKeys.push(key)
}

Component.register(PROP_KEY, function(proto, instance, options) {
  let propKeys: string[] = proto[PROP_KEY]
  let props: Props = {}

  for (let key of propKeys) {
    let prop: PropOptions = {}
    if (instance[key] != null) {
      prop = instance[key]
      delete instance[key]
    }
    // refill type if not existing, do we need this?
    if (!prop.type) {
      prop.type = getReflectType(proto, key)
    }
    props[key] = prop
  }
  options.props = props
})


type Class<T> = {new (...args: {}[]): T}

interface PlainProp<T> {
  type?: Class<T>
  required?: boolean
  default?: T | (() => T)
  validator?(value: T): boolean
}

// FuncPropOption is solely for bad API
interface FuncProp<T extends Function> {
  type: FunctionConstructor,
  defaultFunc: T
}

// we cast arugment's config object type into plain data object type
// say, p(Number) has a return type of `number`, but at runtime it is
// {type: Number}. This is solely for API user's conciseness
export function p<T>(tpe: NumberConstructor): number
export function p<T>(tpe: StringConstructor): string
export function p<T>(tpe: BooleanConstructor): boolean
export function p<T>(tpe: Class<T>): T
export function p<T>(conf: PlainProp<T>): T
export function p<T extends Function>(conf: FuncProp<T>): T
export function p<T>(confOrType: Class<T> | PlainProp<T>): T {
  if (typeof confOrType === 'function') {<commit_msg>express nullablity in type signature<commit_after>import Vue = require('vue')
import {ComponentOptions, PropOptions, VClass, $$Prop} from './interface'
import {Component} from './core'

import {getReflectType} from './util'

const PROP_KEY = '$$Prop' as $$Prop

type Props = {[key: string]: PropOptions}

export function Prop(target: Vue, key: string): void {
  let propKeys: string[] = target[PROP_KEY] = target[PROP_KEY] || []
  propKeys.push(key)
}

Component.register(PROP_KEY, function(proto, instance, options) {
  let propKeys: string[] = proto[PROP_KEY]
  let props: Props = {}

  for (let key of propKeys) {
    let prop: PropOptions = {}
    if (instance[key] != null) {
      prop = instance[key]
      delete instance[key]
    }
    // refill type if not existing, do we need this?
    if (!prop.type) {
      prop.type = getReflectType(proto, key)
    }
    props[key] = prop
  }
  options.props = props
})


type Class<T> = {new (...args: {}[]): T}

interface PlainProp<T> {
  type?: Class<T>
  validator?(value: T): boolean
}

interface DefaultProp<T> extends PlainProp<T> {
  default: T | (() => T)
  required?: boolean
}

interface RequiredProp<T> extends PlainProp<T> {
  required: true
  default?: T | (() => T)
}

// FuncPropOption is solely for bad API
interface FuncProp<T extends Function> {
  type: FunctionConstructor,
  defaultFunc: T
  required?: boolean
}

// we cast arugment's config object type into plain data object type
// say, p(Number) has a return type of `number`, but at runtime it is
// {type: Number}. This is solely for API user's conciseness
export function p<T>(tpe: NumberConstructor): number | undefined
export function p<T>(tpe: StringConstructor): string | undefined
export function p<T>(tpe: BooleanConstructor): boolean | undefined
export function p<T>(tpe: Class<T>): T | undefined
export function p<T>(conf: DefaultProp<T> | RequiredProp<T>): T
export function p<T>(conf: PlainProp<T>): T | undefined
export function p<T extends Function>(conf: FuncProp<T>): T
export function p<T>(confOrType: Class<T> | PlainProp<T>): T {
  if (typeof confOrType === 'function') {
{'fraction_non_alphanumeric': 0.14205559806171894, 'fraction_numerical': 0.0, 'mean_word_length': 4.285714285714286, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6904566', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1255, 'n_words': 412}