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

no-duplicate-spread-property: handle spread of type variables #447

Closed
ajafff opened this issue Oct 30, 2018 · 0 comments
Closed

no-duplicate-spread-property: handle spread of type variables #447

ajafff opened this issue Oct 30, 2018 · 0 comments
Labels
help wanted upstream compatibility Changes needed to support new/upcoming language features or API changes in the TypeScript compiler

Comments

@ajafff
Copy link
Member

ajafff commented Oct 30, 2018

microsoft/TypeScript#28234 adds support for spreading type parameters (and other instantiable types) into object literals.
These need to be handled by no-duplicate-spread-property to get all known properties of the constraint but treat the type as open ended, so that so that there's no error on it (with the exception of #399).

This is also relevant for JSX (#433) because you can already spread type variables in JsxSpreadAttribute.

function test<T extends {foo: number}, U>(t: T, u: U) {
  ({foo: 1, ...t}); // error on `foo: 1`
  ({...t, foo: 1}); // no error as `T`'s properties are not fully known
  ({foo: 1, ...u}); // no error as `U` is unconstrained
  ({...u, foo: 1}); // no error
  let t2: {foo: number} = {...t, foo: 1}; // could be an error if #399 is implemented
  let t3: T = {...t, foo: 1}; // no error
  let t4: T = {...t, ...t3}; // could be an error, but may be too complex
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted upstream compatibility Changes needed to support new/upcoming language features or API changes in the TypeScript compiler
Projects
None yet
Development

No branches or pull requests

1 participant