Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Why TypesScript let use key which is does not specified?

$
0
0

Here I have this line:

const _quantity = startPaymentFrontend?.products[productSlug]?.invoiceData?.[key2]

This here

startPaymentFrontend?.products[productSlug]

is a StartPaymentProduct

export interface StartPaymentProduct {    pricingOptionId?: string    passTypeId?: string    quantity: number    eventTimes?: { [eventTimeId: string]: StartPaymentProductEventTime }    invoiceItems?: { [key: string]: number }    teamSlug: string}

Even developer environment recognize it.

enter image description here

which does not have invoiceData only invoiceItems.

Why running yarn build does not raise error on it?

This here is the tsconfig.json

{"compilerOptions": {"target": "es5","lib": ["dom", "dom.iterable", "esnext"],"allowJs": true,"skipLibCheck": true,"strict": true,"forceConsistentCasingInFileNames": true,"noEmit": false,"esModuleInterop": true,"module": "esnext","moduleResolution": "node","resolveJsonModule": true,"isolatedModules": true,"jsx": "preserve","sourceMap": true,"importHelpers": true,"outDir": "./built"    },"include": ["app/**/*", "index.d.ts", "index2.d.ts"],"exclude": ["node_modules"]}

How can I force to raise error in those cases?!


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>