-
Notifications
You must be signed in to change notification settings - Fork 517
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
TypeScript rewrite #441
TypeScript rewrite #441
Conversation
6259ea6
to
08fdbe9
Compare
Definitely a good start. There are still many I'm gonna do a full review later today locally and check what can be written more strictly. |
One thing that really confuses me is the angle bracket syntax |
They can be used for type casting, but only in Another use that you might see (basically all the time) is as generic type. It works sort of like a function parameter. More info here. |
Yeah I thought the generic type would be good for the util functions but seemed to cause problems so just fell back to |
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.
That was quite a ride. Probably missed a few things 😅
Good job 👍
Thank you tons for the help @KubaJastrz ! I think we've caught a few obscure bugs thanks to TS 😎 It seems like there are lots of these errors now:
With regards to the instance props, etc. Any ideas of what to do? |
I think we need to distinguish the Props interface and Options Like this? export interface Props {
[all required, no ?:]
}
export type Options = Partial<Props> That would probably be a breaking change for the types though...? |
Managed to get all types passing 🤷♂️ Had to hack the |
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.
There are still some Function
types to remove.
We could drop index.d.ts
and replace it with --declaration
flag during the build process. I'll look into it.
We need to keep the |
There's something weird going on. We have our internal types in So the flow would be something like this: // in src/types.ts
import defaults from './defaults'
type Defaults = typeof defaults
interface Props extends Defaults /* maybe omit some props */ {
/* and override them here, like we do in @tippy.js/react */
} No need for Because we're using typescript, we could potentially drop |
Well ideally we don't have a Defaults interface. I only added it as part of There should be two interfaces: |
@KubaJastrz I think this is pretty decent now? I'll keep |
So why do we have it now? I thought that could be used for fixing this, but currently it's just a copy of previous |
Cuz I copy-pasted the Props interface from Moving forward, people should import |
Going to merge this in now as linting, types and tests pass fine, I'll do a minor release in the next week sometime. Feel free to make some PRs in the meantime to improve the current types 🙂 |
I don't know what type WholeProps = Required<Options> I suggest just sticking to |
It types People were doing #408; import { Props } from 'tippy.js' But it will break if we change |
Resolves #378
cc @KubaJastrz, also how do I use a single declaration file (
./types.ts
andindex.d.ts
are duplicates?)