Skip to content

Using .to after a .pipe throws a ParseError: instanceOf operand must be a function (was undefined)Β #1600

@abdelfattahradwan

Description

@abdelfattahradwan

Report a bug

πŸ”Ž Search Terms

instanceOf

🧩 Context

  • ArkType version: 2.2.0
  • TypeScript version (5.1+): 5.9.3

πŸ§‘β€πŸ’» Repro

Playground Link: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520type%28%257B%250A%2509tags%253A%2520type%250A%2509%2509.Record%28%2522string%2522%252C%2520%2522boolean%2522%29%250A%2509%2509.pipe%28%28tags%29%2520%253D%253E%2520Object.keys%28tags%29%29%250A%2509%2509.pipe%28%28tags%29%2520%253D%253E%2520tags.map%28%28tag%29%2520%253D%253E%2520tag.slice%281%29.replaceAll%28%2522_%2522%252C%2520%2522-%2522%29%29%29%250A%2509%252F%252F%2520.to%28%2522string.uuid%255B%255D%2520%253E%25200%2522%29%2520%252F%252F%2520Doesn%27t%2520work.%250A%2509%252F%252F%2520.pipe%28type%28%2522string.uuid%255B%255D%2520%253E%25200%2522%29%29%2520%252F%252F%2520Works.%250A%257D%29%250A%250Aconst%2520out%2520%253D%2520Thing%28%257B%250A%2509tags%253A%2520%257B%250A%2509%2509_6baf599f_8a93_478c_9a3b_51cc01451628%253A%2520true%250A%2509%257D%250A%257D%29%250A

import { type } from "arktype"

const Thing = type({
	tags: type
		.Record("string", "boolean")
		.pipe((tags) => Object.keys(tags))
		.pipe((tags) => tags.map((tag) => tag.slice(1).replaceAll("_", "-")))
		.to("string.uuid[] > 0") // Doesn't work.
	// .pipe(type("string.uuid[] > 0")) // Works.
})

const out = Thing({
	tags: {
		_6baf599f_8a93_478c_9a3b_51cc01451628: true
	}
})

The above code causes a ParseError to be thrown with the following message: instanceOf operand must be a function (was undefined).

Interestingly, using .pipe(type("string.uuid[] > 0")) works.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions