union types in nested objects causes error [BUG]
See original GitHub issueSummary:
I tried to create a schema with union types in a nested object.
Code sample:
Schema
const NestedObjectWithUnionType = {
type: Object,
schema: {
attribute1: [String, Boolean, Number],
attribute2: String,
},
};
const MyModel = dynamoose.model(
`test`,
new dynamoose.Schema({
exampleId: {
type: String,
hashKey: true,
},
name: String,
myNestedObject: NestedObjectWithUnionType,
})
);
Current output and behavior (including stack trace):
InvalidParameter: Index must be at root object and not nested in object or array.
at node_modules/dynamoose/lib/Schema.ts:587:11
at Array.forEach (<anonymous>)
at new Schema (node_modules/dynamoose/lib/Schema.ts:585:21)
at Object.<anonymous> (src/example.ts:648:102)
at Object.<anonymous> (src/example.ts:1456:27)
Environment:
Operating System: macOS
Operating System Version: Sierra
Node.js version (node -v
): 14.8.0
NPM version: (npm -v
): 6.14.5
Dynamoose version: 2.5.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Typescript union of nested type loses key that isn't shared ...
Object types in TypeScript are extendible via adding of properties, due to structural subtyping. And so the compiler decides to infer just X ......
Read more >Bug: nested object lose intellisense when defined in union ...
Since we have a structural type system, we can't tell just by looking at an interface whether it's meant to be implemented by...
Read more >Types - Julia Documentation
It is the exact opposite of Any : no object is an instance of Union{} and all types are supertypes of Union{} ....
Read more >Structs, Unions - D Programming Language
A struct or union is Plain Old Data (POD) if it meets the following criteria: it is not nested; it has no postblits,...
Read more >Mastering TypeScript mapped types - LogRocket Blog
In this post, we'll cover mapped types in TypeScript, a real-world example of them, ... A union type is a combination of two...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@julada Oh maybe the problem is that this was fixed in #985. Just hasn’t been released yet. Still doesn’t completely explain why I couldn’t reproduce it. Maybe NPM was caching a local version?? A new release with this fix should be coming out soon.
@julada I ran the following code (just like in your original post).
And got this as the result:
As you can see, no error, no problem. It ran successfully.