Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ark/schema/structure/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const implementation: nodeImplementationOf<Structure.Declaration> =
reduce: (inner, $) => {
if (!inner.required && !inner.optional) return

const seen: Record<Key, true | undefined> = {}
const seen: Record<Key, true | undefined> = Object.create(null)
let updated = false
const newOptionalProps: OptionalNode[] =
inner.optional ? [...inner.optional] : []
Expand Down
16 changes: 16 additions & 0 deletions ark/type/__tests__/objects/props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,20 @@ contextualize(() => {
})
).throws(writeDuplicateKeyMessage("a"))
})

it("allows prototype method names as keys", () => {
// constructor, hasOwnProperty, toString, etc. are valid object keys
// and should not be incorrectly flagged as duplicates
const T = type({
constructor: "string",
hasOwnProperty: "number",
toString: "boolean"
})

attest<{
constructor: string
hasOwnProperty: number
toString: boolean
}>(T.t)
})
})