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
Migrate from dtslint to tsd #1986
Conversation
There is a PR as can be seen in the changes that adds support for the test.
The migration is done and all tests pass.
There were three troublesome tests marked expectType<never>(Map({ a: 4, b: true }).getIn(['a'])); I don't know how important it is so I just changed it to The last one is an expected error while doing this: Map({ a: 1, b: 'b' }).update(v => ({ a: 'a' })) By the context it seems to be trying to assign a string to a number but that is tested a few lines down and the failure case is just that it's updating with a regular JS object instead of Immutable.Map or similar. |
"paths": { | ||
"immutable": ["../../type-definitions/immutable.d.ts"] | ||
} |
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.
Seems to be specified in ./type-definitions/ts-tests/tsconfig.json
:
immutable-js/type-definitions/ts-tests/tsconfig.json
Lines 13 to 15 in ac05955
"paths": { | |
"immutable": ["../../type-definitions/immutable.d.ts"] | |
} |
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.
Indeed it is. I was unable to make tsd read that tsconfig.json
file but did not put much time into it. If you know how, please share.
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.
Hard to say. Might be worth opening an issue in their repo.
Some time ago I was maintaining a forked tsd-lite
. All I remember is that the original config logic was rather some spaghetti code. It was fully replaced in the fork.
|
||
// $ExpectType Map<number, number> | ||
const numberMap: Map<number, number> = Map(); | ||
expectAssignable<Map<number, number>>(Map()); |
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.
Just to draw attention, here you are hitting one of tsd
s oddities. Both of the following tests are passing:
expectAssignable<Map<number, number>>(Map());
expectNotAssignable<Map<number, number>>(Map());
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.
Just above there is this test:
expectType<Map<unknown, unknown>>(Map())
If the inferred type of Map()
is Map<unknown, unknown>
, it cannot be assigned to Map<number, number>
.
To make it assignable, the type has to be cast to Map<number, number>
first. This is what expectAssignable()
does, but expectNotAssignable()
does not. In my opinion expectNotAssignable()
behaves correctly.
Superseeded by #1991. Thank you @arnfaldur for all the work you made here. Sorry that I did not discovered tstyche before ! |
You're welcome, no need to apologize. It's good to see the issue resolved nicely. Thanks for seeing it through @mrazauskas 🙌 |
This tracks the work spoken about in this issue #1985
It is not ready yet but I decided to make it a draft PR here so anyone could look at and comment on the changes if they wanted to.
I ran prettier on all the files to be changed so there are some non-functional changes but they will in almost all cases be overridden by functional changes.
I don't expect to change much of the code that has had a functional change on my volition, in case of suggestions, I will of course do so.