Skip to content

Commit 2d8d519

Browse files
Fix how custom element declarations extend class declarations (#73)
1 parent 2e391f2 commit 2d8d519

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
<!-- ### Removed -->
1818
<!-- ### Fixed -->
1919

20+
<!-- ## [x.y.z] - YYYY-MM-DD -->
21+
## Unreleased
22+
<!-- ### Changed -->
23+
<!-- ### Added -->
24+
<!-- ### Removed -->
25+
### Fixed
26+
27+
- Fixed how custom element declarations extend class declarations. Previously CustomElementDeclaration didn't include CustomElement properties, and MixinDeclaration required some CustomElement properties. Added new CustomElementMixinDeclaration interface. Fixes https://github.com/webcomponents/custom-elements-manifest/issues/69
28+
2029
## [1.0.0] - 2021-06-10
2130

2231
Initial release

schema.d.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,19 @@ export type Declaration =
131131
| FunctionDeclaration
132132
| MixinDeclaration
133133
| VariableDeclaration
134-
| CustomElementDeclaration;
134+
| CustomElementDeclaration
135+
| CustomElementMixinDeclaration;
135136

136137
/**
137138
* A reference to an export of a module.
138139
*
139140
* All references are required to be publically accessible, so the canonical
140141
* representation of a reference is the export it's available from.
141-
*
142+
*
142143
* `package` should generally refer to an npm package name. If `package` is
143144
* undefined then the reference is local to this package. If `module` is
144145
* undefined the reference is local to the containing module.
145-
*
146+
*
146147
* References to global symbols like `Array`, `HTMLElement`, or `Event` should
147148
* use a `package` name of `"global:"`.
148149
*/
@@ -173,16 +174,18 @@ export interface SourceReference {
173174
* neccessarily part of a custom element class, but belong to the definition
174175
* (often called the "registration") or the `customElements.define()` call.
175176
*
176-
* Because classes and tag anmes can only be registered once, there's a
177+
* Because classes and tag names can only be registered once, there's a
177178
* one-to-one relationship between classes and tag names. For ease of use,
178179
* we allow the tag name here.
179180
*
180181
* Some packages define and register custom elements in separate modules. In
181182
* these cases one `Module` should contain the `CustomElement` without a
182183
* tagName, and another `Module` should contain the
183-
* `CustomElement`.
184+
* `CustomElementExport`.
184185
*/
185-
export interface CustomElementDeclaration extends ClassDeclaration {}
186+
export interface CustomElementDeclaration
187+
extends ClassDeclaration,
188+
CustomElement {}
186189

187190
/**
188191
* The additional fields that a custom element adds to classes and mixins.
@@ -351,7 +354,7 @@ export interface Type {
351354
*/
352355
references?: TypeReference[];
353356

354-
source? : SourceReference;
357+
source?: SourceReference;
355358
}
356359

357360
/**
@@ -432,7 +435,7 @@ export interface ClassLike {
432435
mixins?: Array<Reference>;
433436
members?: Array<ClassMember>;
434437

435-
source? : SourceReference;
438+
source?: SourceReference;
436439
}
437440

438441
export interface ClassDeclaration extends ClassLike {
@@ -468,15 +471,15 @@ export interface ClassField extends PropertyLike {
468471
static?: boolean;
469472
privacy?: Privacy;
470473
inheritedFrom?: Reference;
471-
source? : SourceReference;
474+
source?: SourceReference;
472475
}
473476

474477
export interface ClassMethod extends FunctionLike {
475478
kind: 'method';
476479
static?: boolean;
477480
privacy?: Privacy;
478481
inheritedFrom?: Reference;
479-
source? : SourceReference;
482+
source?: SourceReference;
480483
}
481484

482485
/**
@@ -531,18 +534,24 @@ export interface ClassMethod extends FunctionLike {
531534
* }
532535
* ```
533536
*/
534-
export interface MixinDeclaration extends CustomElement, FunctionLike {
537+
export interface MixinDeclaration extends ClassLike, FunctionLike {
535538
kind: 'mixin';
536539
}
537540

541+
/**
542+
* A class mixin that also adds custom element related properties.
543+
*/
544+
export interface CustomElementMixinDeclaration extends MixinDeclaration, CustomElement {
545+
}
546+
538547
export interface VariableDeclaration extends PropertyLike {
539548
kind: 'variable';
540-
source? : SourceReference;
549+
source?: SourceReference;
541550
}
542551

543552
export interface FunctionDeclaration extends FunctionLike {
544553
kind: 'function';
545-
source? : SourceReference;
554+
source?: SourceReference;
546555
}
547556

548557
export interface Parameter extends PropertyLike {
@@ -587,5 +596,5 @@ export interface Demo {
587596
*/
588597
url: string;
589598

590-
source? : SourceReference;
599+
source?: SourceReference;
591600
}

0 commit comments

Comments
 (0)