question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is `DeclarationRaws#value` property optional?

See original GitHub issue

Summary

The DeclarationRaws#value property is required on the current PostCSS type definitions:

https://github.com/postcss/postcss/blob/0ab7a6ff80803ee4c9658a11d4932dcf5cc280bb/lib/declaration.d.ts#L21-L27

But actually, the property can be optional.

const src = "a { background: linear-gradient(to right, #fff, #ddd) }";
postcss.parse(src).walkDecls((decl) => {
  console.log(decl.raws.value.raw);
                     // ↑ undefined
});

See the following reproduction for details.

Reproduction

Type-checking passes, but running the code raises an error:

https://gist.github.com/ybiquitous/eabe11abd1ecb1feae79614ed12502bb

Environment

PostCSS 8.4.8

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Mar 15, 2022

Released in 8.4.11.

0reactions
ybiquitouscommented, Mar 15, 2022

@ai Thank you for the quick fix! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional property class in typescript - Stack Overflow
Optional property: In Typescript you can declare a property in your interface which will be optional. Suppose you have a interface for ...
Read more >
How to Make Certain Properties Optional in TypeScript
The declaration of the interface is a place to make some properties optional. You can achieve that with a question mark next to...
Read more >
How to Deal with Optional Things and "Undefined" in TypeScript
An uninitialized or absent property of an object; A potentially-omitted optional argument to a function; A return value to indicate something ...
Read more >
Wrong Type Error on missing property when using optional ...
missing property. Expected behavior: Typescript should handle the optional method as same as optional properties. Actual behavior: Typescript ...
Read more >
TypeScript - Interfaces with Optional Properties - LogicBig
In TypeScript, the interfaces which describe objects can have optional properties. Interfaces with optional properties are written similar ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found