Skip to content

DOM lib: CSS namespace breaks CSS Typed OM #38554

@jods4

Description

@jods4

TypeScript Version: 3.9.2

Search Terms: CSS level 1 types lib dom

PR #37616 changed the definition of CSS from an interface with a global var to a namespace.

// Before:
interface CSS {	
    escape(value: string): string;	
    supports(property: string, value?: string): boolean;	
}	
declare var CSS: CSS;

// After:
declare namespace CSS {
    function escape(ident: string): string;
    function supports(property: string, value: string): boolean;
    function supports(conditionText: string): boolean;
}

In isolation, this is all fine.

But it breaks additional definitions for newer standards.

I reference @types/w3c-css-typed-object-model-level-1 for typed CSS OM, which uses the same interface + global var approach as TS 3.8.

Before it was working fine.
After 3.9, code such as CSS.px(42) now errors with TS2339 'px' does not exist on type 'typeof CSS'

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions