@types/css

  • Version 0.0.38
  • Published
  • 11 kB
  • No dependencies
  • MIT license

Install

npm i @types/css
yarn add @types/css
pnpm add @types/css

Overview

TypeScript definitions for css

Index

Functions

function parse

parse: (code: string, options?: ParserOptions) => Stylesheet;
  • Accepts a CSS string and returns an AST object.

    Parameter code

    CSS code.

    Parameter options

    CSS parser options. {Stylesheet} AST object built using provides CSS code.

function stringify

stringify: (stylesheet: Stylesheet, options?: StringifyOptions) => string;
  • Accepts an AST object (as css.parse produces) and returns a CSS string.

    Parameter stylesheet

    AST tree.

    Parameter options

    AST tree to string serializaiton options. {string} CSS code.

Interfaces

interface BaseNode

interface BaseNode {}
  • Base AST Tree Node.

property parent

parent?: Node | undefined;
  • A reference to the parent node, or null if the node has no parent.

property position

position?:
| {
start?: Position | undefined;
end?: Position | undefined;
/** The value of options.source if passed to css.parse. Otherwise undefined. */
source?: string | undefined;
/** The full source string passed to css.parse. */
content?: string | undefined;
}
| undefined;
  • Information about the position in the source string that corresponds to the node.

interface Charset

interface Charset extends BaseNode {}
  • The at-rule.

property charset

charset?: string | undefined;
  • The part following @charset.

property type

type: 'charset';

    interface Comment

    interface Comment extends BaseNode {}
    • A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.

    property comment

    comment?: string | undefined;

      property type

      type: 'comment';

        interface CustomMedia

        interface CustomMedia extends BaseNode {}
        • The @custom-media at-rule

        property media

        media?: string | undefined;
        • The part following the name.

        property name

        name?: string | undefined;
        • The ---prefixed name.

        property type

        type: 'custom-media';

          interface Declaration

          interface Declaration extends BaseNode {}

            property property

            property?: string | undefined;
            • The property name, trimmed from whitespace and comments. May not be empty.

            property type

            type: 'declaration';

              property value

              value?: string | undefined;
              • The value of the property, trimmed from whitespace and comments. Empty values are allowed.

              interface Document

              interface Document extends BaseNode {}
              • The at-rule.

              property document

              document?: string | undefined;
              • The part following @document.

              property rules

              rules?: Array<Rule | Comment | AtRule> | undefined;
              • Array of nodes with the types rule, comment and any of the at-rule types.

              property type

              type: 'document';

                property vendor

                vendor?: string | undefined;
                • The vendor prefix in @document, or undefined if there is none.

                interface FontFace

                interface FontFace extends BaseNode {}
                • The @font-face at-rule.

                property declarations

                declarations?: Array<Declaration | Comment> | undefined;
                • Array of nodes with the types declaration and comment.

                property type

                type: 'font-face';

                  interface Host

                  interface Host extends BaseNode {}
                  • The at-rule.

                  property rules

                  rules?: Array<Rule | Comment | AtRule> | undefined;
                  • Array of nodes with the types rule, comment and any of the at-rule types.

                  property type

                  type: 'host';

                    interface Import

                    interface Import extends BaseNode {}
                    • The at-rule.

                    property import

                    import?: string | undefined;
                    • The part following @import.

                    property type

                    type: 'import';

                      interface KeyFrame

                      interface KeyFrame extends BaseNode {}

                        property declarations

                        declarations?: Array<Declaration | Comment> | undefined;
                        • Array of nodes with the types declaration and comment.

                        property type

                        type: 'keyframe';

                          property values

                          values?: string[] | undefined;
                          • The list of "selectors" of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace.

                          interface KeyFrames

                          interface KeyFrames extends BaseNode {}
                          • The at-rule.

                          property keyframes

                          keyframes?: Array<KeyFrame | Comment> | undefined;
                          • Array of nodes with the types keyframe and comment.

                          property name

                          name?: string | undefined;
                          • The name of the keyframes rule.

                          property type

                          type: 'keyframes';

                            property vendor

                            vendor?: string | undefined;
                            • The vendor prefix in @keyframes, or undefined if there is none.

                            interface Media

                            interface Media extends BaseNode {}
                            • The at-rule.

                            property media

                            media?: string | undefined;
                            • The part following @media.

                            property rules

                            rules?: Array<Rule | Comment | AtRule> | undefined;
                            • Array of nodes with the types rule, comment and any of the at-rule types.

                            property type

                            type: 'media';

                              interface Namespace

                              interface Namespace extends BaseNode {}
                              • The at-rule.

                              property namespace

                              namespace?: string | undefined;
                              • The part following @namespace.

                              property type

                              type: 'namespace';

                                interface Page

                                interface Page extends BaseNode {}
                                • The at-rule.

                                property declarations

                                declarations?: Array<Declaration | Comment> | undefined;
                                • Array of nodes with the types declaration and comment.

                                property selectors

                                selectors?: string[] | undefined;
                                • The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments.

                                property type

                                type: 'page';

                                  interface ParserError

                                  interface ParserError {}
                                  • Error thrown during parsing.

                                  property column

                                  column?: number | undefined;

                                    property filename

                                    filename?: string | undefined;
                                    • The value of options.source if passed to css.parse. Otherwise undefined.

                                    property line

                                    line?: number | undefined;

                                      property message

                                      message?: string | undefined;
                                      • The full error message with the source position.

                                      property reason

                                      reason?: string | undefined;
                                      • The error message without position.

                                      property source

                                      source?: string | undefined;
                                      • The portion of code that couldn't be parsed.

                                      interface ParserOptions

                                      interface ParserOptions {}
                                      • css.parse options

                                      property silent

                                      silent?: boolean | undefined;
                                      • Silently fail on parse errors

                                      property source

                                      source?: string | undefined;
                                      • The path to the file containing css. Makes errors and source maps more helpful, by letting them know where code comes from.

                                      interface Position

                                      interface Position {}
                                      • Information about a position in the code. The line and column numbers are 1-based: The first line is 1 and the first column of a line is 1 (not 0).

                                      property column

                                      column?: number | undefined;

                                        property line

                                        line?: number | undefined;

                                          interface Rule

                                          interface Rule extends BaseNode {}

                                            property declarations

                                            declarations?: Array<Declaration | Comment> | undefined;
                                            • Array of nodes with the types declaration and comment.

                                            property selectors

                                            selectors?: string[] | undefined;
                                            • The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments.

                                            property type

                                            type: 'rule';

                                              interface StringifyOptions

                                              interface StringifyOptions {}
                                              • css.stringify options

                                              property compress

                                              compress?: boolean | undefined;
                                              • Omit comments and extraneous whitespace.

                                              property indent

                                              indent?: string | undefined;
                                              • The string used to indent the output. Defaults to two spaces.

                                              property inputSourcemaps

                                              inputSourcemaps?: boolean | undefined;
                                              • (enabled by default, specify false to disable) Reads any source maps referenced by the input files when generating the output source map. When enabled, file system access may be required for reading the referenced source maps.

                                              property sourcemap

                                              sourcemap?: string | undefined;
                                              • Return a sourcemap along with the CSS output. Using the source option of css.parse is strongly recommended when creating a source map. Specify sourcemap: 'generator' to return the SourceMapGenerator object instead of serializing the source map.

                                              interface StyleRules

                                              interface StyleRules {}
                                              • A collection of rules

                                              property parsingErrors

                                              parsingErrors?: ParserError[] | undefined;
                                              • Array of Errors. Errors collected during parsing when option silent is true.

                                              property rules

                                              rules: Array<Rule | Comment | AtRule>;
                                              • Array of nodes with the types rule, comment and any of the at-rule types.

                                              interface Stylesheet

                                              interface Stylesheet extends BaseNode {}
                                              • The root node returned by css.parse.

                                              property stylesheet

                                              stylesheet?: StyleRules | undefined;

                                                property type

                                                type: 'stylesheet';

                                                  interface Supports

                                                  interface Supports extends BaseNode {}
                                                  • The at-rule.

                                                  property rules

                                                  rules?: Array<Rule | Comment | AtRule> | undefined;
                                                  • Array of nodes with the types rule, comment and any of the at-rule types.

                                                  property supports

                                                  supports?: string | undefined;
                                                  • The part following @supports.

                                                  property type

                                                  type: 'supports';

                                                    Type Aliases

                                                    type AtRule

                                                    type AtRule =
                                                    | Charset
                                                    | CustomMedia
                                                    | Document
                                                    | FontFace
                                                    | Host
                                                    | Import
                                                    | KeyFrames
                                                    | Media
                                                    | Namespace
                                                    | Page
                                                    | Supports;
                                                    • All at-rules.

                                                    type Node

                                                    type Node = Rule | Declaration | Comment | AtRule | Stylesheet;
                                                    • All possible AST nodes.

                                                    Package Files (1)

                                                    Dependencies (0)

                                                    No dependencies.

                                                    Dev Dependencies (0)

                                                    No dev dependencies.

                                                    Peer Dependencies (0)

                                                    No peer dependencies.

                                                    Badge

                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/css.

                                                    • Markdown
                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/css)
                                                    • HTML
                                                      <a href="https://www.jsdocs.io/package/@types/css"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>