Skip to content

Commit 6e34131

Browse files
authored
Add "noUncheckedIndexedAccess": true to compilerOptions (#744)
* Add "noUncheckedIndexedAccess": true to compilerOptions * Fix generated price transport
1 parent 343873b commit 6e34131

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

scripts/generator-adapter/generators/app/templates/src/transport/http.ts.ejs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,24 @@ export const httpTransport = new HttpTransport<HttpTransportTypes>({
6060
<% } -%>
6161
parseResponse: (params, response) => {
6262
<% if (includeComments) { -%>
63-
// In case error was received, it's a good practice to return meaningful information to user
63+
// For each 'param' a new response object is created and returned as an array
6464
<% } -%>
65-
if (!response.data) {
66-
return params.map((param) => {
65+
return params.map((param) => {
66+
<% if (includeComments) { -%>
67+
// In case error was received, it's a good practice to return meaningful information to user
68+
<% } -%>
69+
const baseSymbol = param.base.toUpperCase()
70+
if (!response.data || !response.data[baseSymbol]) {
6771
return {
6872
params: param,
6973
response: {
7074
errorMessage: `The data provider didn't return any value for ${param.base}/${param.quote}`,
7175
statusCode: 502,
7276
},
7377
}
74-
})
75-
}
78+
}
7679

77-
<% if (includeComments) { -%>
78-
// For successful responses for each 'param' a new response object is created and returned as an array
79-
<% } -%>
80-
return params.map((param) => {
81-
const result = response.data[param.base.toUpperCase()].price
80+
const result = response.data[baseSymbol].price
8281
<% if (includeComments) { -%>
8382
// Response objects, whether successful or errors, contain two properties, 'params' and 'response'. 'response' is what will be
8483
// stored in the cache and returned as adapter response and 'params' determines the identifier so that the next request with same 'params'

scripts/generator-adapter/generators/app/templates/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "<%- standalone ? "./tsconfig.base.json" : "../../tsconfig.base.json" %>",
33
"compilerOptions": {
44
"outDir": "dist",
5-
"rootDir": "src"
5+
"rootDir": "src",
6+
"noUncheckedIndexedAccess": true
67
},
78
"include": ["src/**/*", "src/**/*.json"],
89
"exclude": ["dist", "**/*.spec.ts", "**/*.test.ts"]

0 commit comments

Comments
 (0)