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

fix(typescript): ensure LazyResult complies with Promise interface. #1463

Merged
merged 1 commit into from Nov 19, 2020

Conversation

ludofischer
Copy link
Contributor

Hi, following our Gitter chat yesterday, I've learnt LazyResult was meant to implement the Promise contract. This pull request adds the [Symbol.toStringTag] property to LazyResult which Typescript requires to type something as a Promise.

  • Explicitly implement Promise in the type declaration
  • Add mising [Symbol.toStringTag] property
  • Add some type tests to ensure we can type postcss(plugins).process results

const processResult: Promise<Result> | Result = postcss([
plugin
]).process('h1{color: black;}', { from: undefined })
const processed:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we can use processed: Result = here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I am not sure I understand the question. I don't think processed can be of type result since I am mapping it to a different object in then(). If you want I can simplify this example, it actually comes from a real-life sample in the Vue.js 3 repo).

* Explicitly implement Promise<Result> in the type declaration
* Add mising [Symbol.toStringTag] property
* Add some type tests to ensure we can type `postcss(plugins).process` results
@ai ai merged commit 0d89106 into postcss:master Nov 19, 2020
@ai
Copy link
Member

ai commented Nov 19, 2020

Thanks. Released in 8.1.8.

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

Successfully merging this pull request may close these issues.

None yet

2 participants