@types/css

  • Version 0.0.37
  • Published
  • 10.6 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 Charset

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

property charset

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

interface Comment

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

property comment

comment?: string | undefined;

    interface CustomMedia

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

    property media

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

    property name

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

    interface Declaration

    interface Declaration extends Node {}

      property property

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

      property value

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

      interface Document

      interface Document extends Node {}
      • 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 vendor

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

      interface FontFace

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

      property declarations

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

      interface Host

      interface Host extends Node {}
      • 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.

      interface Import

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

      property import

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

      interface KeyFrame

      interface KeyFrame extends Node {}

        property declarations

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

        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 Node {}
        • 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 vendor

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

        interface Media

        interface Media extends Node {}
        • 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.

        interface Namespace

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

        property namespace

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

        interface Node

        interface Node {}
        • 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.

        property type

        type?: string | undefined;
        • The possible values are the ones listed in the Types section on https://github.com/reworkcss/css page.

        interface Page

        interface Page extends Node {}
        • 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.

        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 Node {}

                  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.

                  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 Node {}
                  • The root node returned by css.parse.

                  property stylesheet

                  stylesheet?: StyleRules | undefined;

                    interface Supports

                    interface Supports extends Node {}
                    • 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.

                    Type Aliases

                    type AtRule

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

                    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>