-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: updates to typescript w/n the env command #6905
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Thomas Lane <[email protected]> Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]> Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]> Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Will <[email protected]>
Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Thomas Lane <[email protected]> Co-authored-by: Thomas Lane <[email protected]>
Co-authored-by: Will <[email protected]>
Co-authored-by: Will <[email protected]>
@DanielSLew Will you review this when you have a moment? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just a few small changes!
src/commands/api-types.d.ts
Outdated
body: EnvVar | ||
} | ||
|
||
interface createEnvVarParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface createEnvVarParams { | |
interface CreateEnvVarParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been updated
[key: string]: Record<string, unknown>; | ||
} | ||
|
||
// Processing Settings Interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need all these comments, they're all basically just saying the name of the interfaces are
src/commands/env/env-set.ts
Outdated
scopes = scopes.filter((sco) => !/post[-_]processing/.test(sco)) | ||
} | ||
|
||
// if the passed context is unknown, it is actually a branch name | ||
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. | ||
let values = contexts.map((ctx) => | ||
let values: Value[] = contexts.map((ctx) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the Value
type supposed to be? Can we give it a more descriptive name
src/utils/env/index.ts
Outdated
export const AVAILABLE_SCOPES = ['builds', 'functions', 'runtime', 'post_processing'] | ||
import { GetEnvelopeEnvParams, ProcessedEnvVars } from './types.js' | ||
|
||
export const AVAILABLE_CONTEXTS: Context[] = ['all', 'production', 'deploy-preview', 'branch-deploy', 'dev'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change that to DeployContext
, context on its own is too vague
export const AVAILABLE_CONTEXTS: Context[] = ['all', 'production', 'deploy-preview', 'branch-deploy', 'dev'] | |
export const AVAILABLE_CONTEXTS: DeployContext[] = ['all', 'production', 'deploy-preview', 'branch-deploy', 'dev'] |
Co-authored-by: Will <[email protected]>
Suggested changes were made w/ @wconrad265! |
@@ -26,7 +27,7 @@ export const envGet = async (name: string, options: OptionValues, command: BaseC | |||
} | |||
|
|||
if (!value) { | |||
const contextType = AVAILABLE_CONTEXTS.includes(context) ? 'context' : 'branch' | |||
const contextType = context === undefined ? 'branch' : AVAILABLE_CONTEXTS.includes(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed? It now returns a boolean instead of a string
if (isAPIEnvError(error)) { | ||
throw error.json ? error.json.msg : error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're doing this we should add an else
to throw. Otherwise we're swallowing the error if it if (isAPIEnvError(error))
returns false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or could we do something like this?
if (isAPIEnvError(error)) { | |
throw error.json ? error.json.msg : error | |
} | |
throw (error as APIError).json ? (error as APIError).json.msg : error |
if (error && typeof error === 'object' && 'message' in error && typeof error.message === 'string') { | ||
log(error.message) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, we could just do
if (error && typeof error === 'object' && 'message' in error && typeof error.message === 'string') { | |
log(error.message) | |
} | |
log((error as APIError).message) |
const errortoThrow = isAPIEnvError(error_) ? error_.json.msg : error_ | ||
throw errortoThrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is what I was mentioning above, to do it this way
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes #Typescript in Env Command
Fixes all
$TSFixMe
and@ts-ignore
within Env command directory. Added additional types for functions and API methods associated with env command.Thanks for the help @wconrad265!
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)