Skip to content

Commit 5e15f12

Browse files
authoredMay 24, 2024··
fix: crash on envelopItems.filter (#6662)
* refactor: remove typescript type error suppresion * fix: type error * fix: another type error supression
1 parent 6ae6de0 commit 5e15f12

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed
 

‎src/commands/env/env-get.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const envGet = async (name: string, options: OptionValues, command: BaseC
1717
const { siteInfo } = cachedConfig
1818
const env = await getEnvelopeEnv({ api, context, env: cachedConfig.env, key: name, scope, siteInfo })
1919

20-
// @ts-expect-error TS(7053) - Element implicitly has an 'any' type
2120
const { value } = env[name] || {}
2221

2322
// Return json response for piping commands

‎src/utils/env/index.ts

+25-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { $TSFixMe } from '../../commands/types.js'
12
import { error } from '../command-helpers.js'
23

34
export const AVAILABLE_CONTEXTS = ['all', 'production', 'deploy-preview', 'branch-deploy', 'dev']
@@ -57,18 +58,20 @@ export const filterEnvBySource = (env, source) =>
5758
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
5859
Object.fromEntries(Object.entries(env).filter(([, variable]) => variable.sources[0] === source))
5960

60-
/**
61-
* Fetches data from Envelope
62-
* @param {string} accountId - The account id
63-
* @param {object} api - The api singleton object
64-
* @param {string} key - If present, fetch a single key (case-sensitive)
65-
* @param {string} siteId - The site id
66-
* @returns {Array<object>} An array of environment variables from the Envelope service
67-
*/
68-
// @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message
69-
const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) {
61+
// Fetches data from Envelope
62+
const fetchEnvelopeItems = async function ({
63+
accountId,
64+
api,
65+
key,
66+
siteId,
67+
}: {
68+
accountId: string
69+
api: $TSFixMe
70+
key: string
71+
siteId: string
72+
}): Promise<$TSFixMe[]> {
7073
if (accountId === undefined) {
71-
return {}
74+
return []
7275
}
7376
try {
7477
// if a single key is passed, fetch that single env var
@@ -109,28 +112,32 @@ const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) {
109112
* },
110113
* }
111114
*/
112-
// @ts-expect-error TS(7031) FIXME: Binding element 'source' implicitly has an 'any' t... Remove this comment to see the full error message
113-
export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope = 'any', source }) =>
115+
export const formatEnvelopeData = ({
116+
context = 'dev',
117+
envelopeItems = [],
118+
scope = 'any',
119+
source,
120+
}: {
121+
context?: string
122+
envelopeItems: $TSFixMe[]
123+
scope?: string
124+
source: string
125+
}) =>
114126
envelopeItems
115127
// filter by context
116128
.filter(({ values }) => Boolean(findValueInValues(values, context)))
117129
// filter by scope
118-
// @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'never'... Remove this comment to see the full error message
119130
.filter(({ scopes }) => (scope === 'any' ? true : scopes.includes(scope)))
120131
// sort alphabetically, case insensitive
121-
// @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'.
122132
.sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
123133
// format the data
124134
.reduce((acc, cur) => {
125-
// @ts-expect-error TS(2339) FIXME: Property 'values' does not exist on type 'never'.
126135
const { context: ctx, context_parameter: branch, value } = findValueInValues(cur.values, context)
127136
return {
128137
...acc,
129-
// @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'.
130138
[cur.key]: {
131139
context: ctx,
132140
branch,
133-
// @ts-expect-error TS(2339) FIXME: Property 'scopes' does not exist on type 'never'.
134141
scopes: cur.scopes,
135142
sources: [source],
136143
value,

2 commit comments

Comments
 (2)

github-actions[bot] commented on May 24, 2024

@github-actions[bot]

📊 Benchmark results

  • Dependency count: 1,231
  • Package size: 295 MB
  • Number of ts-expect-error directives: 989

github-actions[bot] commented on May 24, 2024

@github-actions[bot]

📊 Benchmark results

  • Dependency count: 1,231
  • Package size: 295 MB
  • Number of ts-expect-error directives: 989
Please sign in to comment.