sindresorhus / type-fest

A collection of essential TypeScript types
Creative Commons Zero v1.0 Universal
14.31k stars 543 forks source link

`JsonObject` not limit object keys type #679

Open Emiyaaaaa opened 1 year ago

Emiyaaaaa commented 1 year ago

typescript: 5.1.6

type JsonObject not limit Object key type like symbol

const a = {[Symbol(1)]: 1}
function test(v: JsonObject) {}

// issue
test(a) // no ts error, should throw ts error
type b = typeof a extends JsonObject ? true : false // true, should be false

Upvote & Fund

Fund with Polar

Emiyaaaaa commented 1 year ago

found this: https://github.com/microsoft/TypeScript/issues/53265 https://github.com/microsoft/TypeScript/issues/44794

have any way to fix it in type-fast?