{"record":{"id":"0aebd03ab2c97857","repo":"slidevjs/slidev","slug":"invalid-timestamp-unit-unit","errorCode":null,"errorMessage":"Invalid timestamp unit: ${unit}","messagePattern":"Invalid timestamp unit: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/parser/src/timesplit/timestring.ts","lineNumber":94,"sourceCode":"      days: 86400,\n      week: 604800,\n      weeks: 604800,\n      month: 2629746,\n      months: 2629746,\n      year: 31556952,\n      years: 31556952,\n    }\n    const regex = /([\\d.]+)([a-z]+)/gi\n    const matches = timestamp.matchAll(regex)\n    if (matches) {\n      for (const match of matches) {\n        const value = Number(match[1])\n        if (Number.isNaN(value)) {\n          throw new TypeError(`Invalid timestamp value: ${match[1]}`)\n        }\n        const unit = match[2].toLowerCase()\n        if (!(unit in unitMap)) {\n          throw new TypeError(`Invalid timestamp unit: ${unit}`)\n        }\n        seconds += value * unitMap[unit]\n      }\n    }\n    const remaining = timestamp.replace(regex, '').trim()\n    if (remaining) {\n      throw new TypeError(`Unknown timestamp remaining: ${remaining}`)\n    }\n  }\n\n  return {\n    seconds,\n    relative,\n  }\n}\n","sourceCodeStart":76,"sourceCodeEnd":110,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/parser/src/timesplit/timestring.ts#L76-L110","documentation":"The unit-based parser only recognizes a fixed set of units (s/sec/secs, m/min/mins, h/hr/hrs/hour/hours, day/days, week/weeks, month/months, year/years). Any other suffix throws.","triggerScenarios":"Writing 5ms (milliseconds unsupported), 5secounds (typo), or any unrecognized unit string.","commonSituations":"Typos, assuming ms/us are supported, locale-specific abbreviations.","solutions":["Use one of the supported unit names (s, sec, m, min, h, hr, day, week, month, year and plurals)","Convert sub-second values to a fractional second (0.5s)","Double-check the spelling of the unit"],"exampleFix":"// before\ntimesplit: 5ms\n// after\ntimesplit: 0.005s","handlingStrategy":"validation","validationCode":"const SUPPORTED_UNITS = new Set(['s','sec','secs','m','min','mins','h','hr','hrs','hour','hours','day','days','week','weeks','month','months','year','years'])\nfunction validUnits(ts: string): boolean {\n  return Array.from(ts.matchAll(/([\\d.]+)([a-z]+)/gi)).every(m => SUPPORTED_UNITS.has(m[2].toLowerCase()))\n}","typeGuard":"function isSupportedUnit(u: string): u is string {\n  const set = new Set(['s','sec','secs','m','min','mins','h','hr','hrs','hour','hours','day','days','week','weeks','month','months','year','years'])\n  return set.has(u.toLowerCase())\n}","tryCatchPattern":null,"preventionTips":["Spellcheck unit suffixes against the supported list","Use fractional seconds instead of ms/us"],"tags":["timestamp","parser","validation"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}