-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add --show-diff
cli option
#165
Conversation
Currently the feature is only implemented in |
I can't work on this feature any time soon... Anyway I was thinking of doing it in another PR. So I won't add anything more in this PR. Waiting for your feedback for eventual changes. |
Co-authored-by: Tommy <[email protected]>
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.
Sorry for taking so long to review. Besides some minor things, this looks good to me. How were you thinking of doing a normalized typeToString
function? I could try implementing it.
Co-authored-by: Tommy <[email protected]>
Co-authored-by: Tommy <[email protected]>
You have to explore the AST of the type if it is not stringifiable, you have to browse its properties and format them. It's a huge job with a lot of edge cases to take into account. |
@tommy-mitchell I don't know why the CI doesn't pass... I don't see any difference in the output and all the tests run locally under Windows and WLS. Sorry but I can't investigate further. |
Seems like the CI is failing because the +'dist/test/fixtures/diff/index.test-d.ts:8:0',
'✖ 8:0 Parameter type { life?: number | undefined; } is declared too wide for argument type { life: number; }.',
'',
'- { life?: number | undefined; }',
'+ { life: number; }',
// ... |
Looks good to me. |
This PR add the
--show-diff
cli option.Some limitations:
typeToString
method of theTypeChecker
does not parse all types in the same way. For example, an interface will return its name and not its contents, whereas an type alias will return its contents, which makes it difficult to compare the two types by string comparison.typeToString
method of theTypeChecker
does not allow the indentation of the inspected/resolved type to be preserved, so at the moment the types are displayed inline which is not very readable on complex types.TODO:
typeToString
function.