Closed skarab42 closed 1 year ago
Currently the feature is only implemented in expectType
and needs to be implemented in the other helpers that support it.
WIP... Done!
TODO:
- Implement a normalized
typeToString
function.
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.
How were you thinking of doing a normalized
typeToString
function? I could try implementing it.
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 diff cli
test reports the location of the errors, but doesn't locally:
+'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.