Skip to content

TS 3.9+ missing registerProperty method in CSS #38593

Closed

Description

@daneden

TypeScript Version: both 3.9.2 and 4.0.0-dev20200514

Search Terms: registerProperty

Code

interface CSS {
  registerProperty: (any) => any
}

CSS?.registerProperty({
  name: "--line-direction",
  syntax: "trbl | tlbr | center",
  initialValue: "tlbr",
  inherits: true,
})

Expected behavior:

  • Code compiles successfully

Actual behavior:

  • TypeScript throws an error: “Property registerProperty does not exist on type typeof CSS.”

Playground Link:

Related Issues:

Activity

  1. BarnT commented on Mar 14, 2021

    @BarnT

    Also CSS.paintWorklet.addModule() throws error:
    "Property 'paintWorklet' does not exist on type 'typeof CSS'."

  2. kongxiangyan commented on Dec 29, 2021

    @kongxiangyan
    interface CSS {
      registerProperty: (any) => any
    }

    I am encountering the same problem, if you hadn't solve it, use namespace instead of interface.

    Here is my code, all definition is refer to CSS.registerProperty() - MDN

    declare namespace CSS {
      interface PropertyDefinition {
        name: string
        syntax?: string
        inherits: boolean
        initialValue?: string
      }
      function registerProperty (propertyDefinition: PropertyDefinition): undefined
    }

    Playground Link:

  3. scriptex commented on Mar 31, 2022

    @scriptex

    Also CSS.paintWorklet.addModule() throws error: "Property 'paintWorklet' does not exist on type 'typeof CSS'."

    I fixed this with the following code:

    declare namespace CSS {
    	namespace paintWorklet {
    		export function addModule(url: URL): void;
    	}
    }
  4. jakebailey commented on Jul 9, 2023

    @jakebailey
    Member

    This was fixed in #53133, which restored CSS as a namespace.

  5. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions