Skip to content

Cannot define key "constructor" in object literal (ParseError: Duplicate key)Β #1572

@MioYiSama

Description

@MioYiSama

Report a bug

πŸ”Ž Search Terms

constructor, duplicate key, prototype collision, ParseError, object literal

🧩 Context

  • ArkType version: arktype@2.1.29
  • TypeScript version: typescript@5.9.3
  • Other context: Node.js / Bun

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

import { type } from "arktype";

// This throws a "Duplicate key" error because it likely collides 
// with the internal Object.prototype.constructor check.
type({ constructor: "string" });

Playground Link: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%253B%250Atype%28%257B%2520constructor%253A%2520%2522string%2522%2520%257D%29%253B%250A

Stack Trace

ParseError: Duplicate key "constructor"  
      at throwError (node_modules\@ark\util\out\errors.js:5:11)  
      at reduce (node_modules\@ark\schema\out\structure\structure.js:204:21)  
      at parseNode (node_modules\@ark\schema\out\parse.js:92:30)  
      at node (node_modules\@ark\schema\out\scope.js:362:22)  
      at parseObjectLiteral (node_modules\arktype\out\parser\objectLiteral.js:80:33)

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