-
Notifications
You must be signed in to change notification settings - Fork 904
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
chore: convert init command to TS #708
chore: convert init command to TS #708
Conversation
@@ -22,7 +19,7 @@ afterEach(() => { | |||
}); | |||
|
|||
test('installTemplatePackage', async () => { | |||
jest.spyOn(PackageManger, 'install').mockImplementationOnce(() => {}); | |||
jest.spyOn(PackageManger, 'install').mockImplementationOnce(() => null); |
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.
Changed the mock implementation to avoid type conflicts. There was no change in the overall outcome from the unit tests since we're not asserting the result from the mock.
@@ -63,7 +60,7 @@ test('copyTemplate', async () => { | |||
const CWD = '.'; | |||
|
|||
jest.spyOn(path, 'resolve').mockImplementationOnce((...e) => e.join('/')); | |||
jest.spyOn(copyFiles, 'default').mockImplementationOnce(() => {}); | |||
jest.spyOn(copyFiles, 'default').mockImplementationOnce(() => null); |
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 as the comment above.
])("'%s' is invalid name", ({name, error}: {name: string, error: Error}) => { | ||
// @ts-ignore-next-line FIXME extending the Error class causes weird TS validation errors | ||
// https://stackoverflow.com/questions/41102060/typescript-extending-error-class | ||
])("'%s' is invalid name", ({name, error}: {name: string; error: 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.
This is the only unsolved case from the conversion.
Apparently TS has weird issues when extending the Error
class by not recognizing the correct properties.
Tried different solutions with no success. 😞
@@ -103,7 +103,7 @@ async function installPods({ | |||
}: { | |||
projectName: string; | |||
loader?: ora.Ora; | |||
shouldUpdatePods: boolean; | |||
shouldUpdatePods?: boolean; |
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.
Updated the type definition for this property as a proposition since we're checking if it is passed or not in the method execution.
I'll be happy to revert this and explicitly pass the false
option on commands/init/initCompat:88
if needed.
147cbc3
to
849c1c2
Compare
849c1c2
to
10a45f5
Compare
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.
👍
@@ -136,7 +140,7 @@ async function createFromTemplate({ | |||
projectName, | |||
projectTitle, | |||
placeholderName: templateConfig.placeholderName, | |||
titlePlaceholder: templateConfig.titlePlaceholder, | |||
placeholderTitle: templateConfig.titlePlaceholder, |
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.
Good catch. cc @Esemesek – 0.61 is right behind the corner, so I guess we'll need to keep this name for a while?
Summary:
Part of issue #683
Converted
commands/init/*
to typescript.The conversion involved the following steps:
.js
to.ts
;@flow
annotations from the header;Test Plan:
yarn flow
andyarn lint
to guarantee static analysis with no errorsyarn test
to guarantee unit test coverage (this also involved making sure that the new snapshots are generated in the correct.ts
format).cli
, following the guidelines from theCONTRIBUTING.md
file.