Skip to content
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

Typing problem with new native props + plugins #631

Closed
atomiks opened this issue Oct 30, 2019 · 1 comment
Closed

Typing problem with new native props + plugins #631

atomiks opened this issue Oct 30, 2019 · 1 comment

Comments

@atomiks
Copy link
Owner

atomiks commented Oct 30, 2019

A user created a plugin with name x that takes a number:

tippy(reference, {
  x: 1000,
  plugins: [x]
});

We introduce a new native prop with name x that takes a string

tippy(reference, {
  x: 'content'
})
interface Props {
  // ...
  x: string;
}

With a runtime bailout check we can prevent errors and add a warning that their plugin now conflicts with a native prop (I expect this to be very rare):

bailIfPlugin(plugins, 'x', () => {...});

But for types, there is a problem. If they weren't typing their plugin prop, they will now get an error since Props now has x types as string, but they are passing in number.

Is it fine that types can suddenly emit errors/warnings upon minor updates? Or do we need to remove [key: string]: any and force strict types (which will still emit errors if they weren't strict typing their plugin prop, but only for that release, not future ones that introduce new props)?

Looking at the DefinitelyTyped repo, changes in types happen frequently for correctness between minors and aren't considered breaking changes. Even TS itself introduces breaking in minors.

/cc @KubaJastrz

@KubaJastrz
Copy link
Collaborator

I'm in favor of stricter types. Maybe TypeScript itself doesn't encourage strict typing by default (exhibit 1 and 2), it is a good idea to promote strictness wherever possible (exhibit 1). If you don't want types, you can just use plain JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants