Skip to content

Commit 915d070

Browse files
committed
Improve typing in code generator
1 parent 9fa2cc3 commit 915d070

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

packages/apollo-codegen-scala/src/codeGeneration.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,10 @@ function dataContainerDeclaration(
443443
insideCompanion
444444
}: {
445445
name: string;
446-
properties: (Property & ({ name: string } | { responseName: string }))[];
446+
properties: (Property & {
447+
name?: string;
448+
responseName?: string;
449+
})[];
447450
extraSuperClasses?: string[];
448451
description?: string;
449452
insideCompanion?: () => void;
@@ -460,7 +463,7 @@ function dataContainerDeclaration(
460463
() => {
461464
properties.forEach(p => {
462465
propertyDeclaration(generator, {
463-
jsName: (p as any).name || (p as any).responseName,
466+
jsName: p.name || p.responseName,
464467
propertyName: p.propertyName,
465468
typeName: p.typeName
466469
});
@@ -490,12 +493,7 @@ function dataContainerDeclaration(
490493
},
491494
() => {
492495
const propertiesIn = properties
493-
.map(
494-
p =>
495-
`"${(p as any).name || (p as any).responseName}" -> ${
496-
p.propertyName
497-
}`
498-
)
496+
.map(p => `"${p.name || p.responseName}" -> ${p.propertyName}`)
499497
.join(", ");
500498
generator.printOnNewline(
501499
`scala.scalajs.js.Dynamic.literal(${propertiesIn}).asInstanceOf[${name}]`
@@ -542,12 +540,7 @@ function dataContainerDeclaration(
542540
},
543541
() => {
544542
const propertiesIn = properties
545-
.map(
546-
p =>
547-
`"${(p as any).name || (p as any).responseName}" -> ${
548-
p.propertyName
549-
}`
550-
)
543+
.map(p => `"${p.name || p.responseName}" -> ${p.propertyName}`)
551544
.join(", ");
552545
generator.printOnNewline(
553546
`scala.scalajs.js.Dynamic.literal(${propertiesIn}).asInstanceOf[${name}]`

0 commit comments

Comments
 (0)