Skip to content

Commit e4822c1

Browse files
authored
chore: update use of deprecated toMatchTypeOf (#231)
1 parent c960fe6 commit e4822c1

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

src/node-types.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,35 +143,35 @@ describe('type narrowing — compile-time', () => {
143143
test('is_stylesheet narrows type field', () => {
144144
const root = parse('a {}')
145145
if (is_stylesheet(root)) {
146-
expectTypeOf(root).toMatchTypeOf<StyleSheet>()
146+
expectTypeOf(root).toExtend<StyleSheet>()
147147
}
148148
})
149149

150150
test('is_rule narrows prelude and block to specific subtypes', () => {
151151
const root = parse('a { color: red }')
152152
const first = root.first_child!
153153
if (is_rule(first)) {
154-
expectTypeOf(first).toMatchTypeOf<Rule>()
155-
expectTypeOf(first.prelude).toMatchTypeOf<SelectorList | Raw | null>()
156-
expectTypeOf(first.block).toMatchTypeOf<BlockNodeAlias | null>()
154+
expectTypeOf(first).toExtend<Rule>()
155+
expectTypeOf(first.prelude).toExtend<SelectorList | Raw | null>()
156+
expectTypeOf(first.block).toExtend<BlockNodeAlias | null>()
157157
}
158158
})
159159

160160
test('is_atrule narrows name to string and prelude/block to specific subtypes', () => {
161161
const root = parse('@media screen {}')
162162
const first = root.first_child!
163163
if (is_atrule(first)) {
164-
expectTypeOf(first).toMatchTypeOf<Atrule>()
164+
expectTypeOf(first).toExtend<Atrule>()
165165
expectTypeOf(first.name).toEqualTypeOf<string>()
166-
expectTypeOf(first.prelude).toMatchTypeOf<AtrulePrelude | Raw | null>()
167-
expectTypeOf(first.block).toMatchTypeOf<BlockNodeAlias | null>()
166+
expectTypeOf(first.prelude).toExtend<AtrulePrelude | Raw | null>()
167+
expectTypeOf(first.block).toExtend<BlockNodeAlias | null>()
168168
}
169169
})
170170

171171
test('is_declaration narrows property, is_important, is_browserhack; omits inapplicable props', () => {
172172
const decl = parse_declaration('color: red !important')
173173
if (is_declaration(decl)) {
174-
expectTypeOf(decl).toMatchTypeOf<Declaration>()
174+
expectTypeOf(decl).toExtend<Declaration>()
175175
expectTypeOf(decl.property).toEqualTypeOf<string>()
176176
expectTypeOf(decl.is_important).toEqualTypeOf<boolean>()
177177
expectTypeOf(decl.is_browserhack).toEqualTypeOf<boolean>()
@@ -184,7 +184,7 @@ describe('type narrowing — compile-time', () => {
184184
const rule = root.first_child! as Rule
185185
const block = rule.block!
186186
if (is_block(block)) {
187-
expectTypeOf(block).toMatchTypeOf<Block>()
187+
expectTypeOf(block).toExtend<Block>()
188188
expectTypeOf(block.is_empty).toEqualTypeOf<boolean>()
189189
}
190190
})
@@ -193,26 +193,26 @@ describe('type narrowing — compile-time', () => {
193193
const decl = parse_declaration('width: 100px')
194194
const dim = decl.first_child!.first_child!
195195
if (is_dimension(dim)) {
196-
expectTypeOf(dim).toMatchTypeOf<Dimension>()
197-
expectTypeOf(dim.value).toMatchTypeOf<number>()
198-
expectTypeOf(dim.unit).toMatchTypeOf<string>()
196+
expectTypeOf(dim).toExtend<Dimension>()
197+
expectTypeOf(dim.value).toExtend<number>()
198+
expectTypeOf(dim.unit).toExtend<string>()
199199
}
200200
})
201201

202202
test('is_number narrows value to number', () => {
203203
const decl = parse_declaration('z-index: 42')
204204
const num = decl.first_child!.first_child!
205205
if (is_number(num)) {
206-
expectTypeOf(num).toMatchTypeOf<Number>()
207-
expectTypeOf(num.value).toMatchTypeOf<number>()
206+
expectTypeOf(num).toExtend<Number>()
207+
expectTypeOf(num.value).toExtend<number>()
208208
}
209209
})
210210

211211
test('is_function narrows name to string', () => {
212212
const decl = parse_declaration('color: rgb(0,0,0)')
213213
const fn = decl.first_child!.first_child!
214214
if (is_function(fn)) {
215-
expectTypeOf(fn).toMatchTypeOf<Function>()
215+
expectTypeOf(fn).toExtend<Function>()
216216
expectTypeOf(fn.name).toEqualTypeOf<string>()
217217
}
218218
})
@@ -221,7 +221,7 @@ describe('type narrowing — compile-time', () => {
221221
const root = parse_selector('[href]')
222222
const attr = root.first_child!.first_child!
223223
if (is_attribute_selector(attr)) {
224-
expectTypeOf(attr).toMatchTypeOf<AttributeSelector>()
224+
expectTypeOf(attr).toExtend<AttributeSelector>()
225225
expectTypeOf(attr.attr_operator).toEqualTypeOf<string | null>()
226226
expectTypeOf(attr.attr_flags).toEqualTypeOf<string | null>()
227227
}
@@ -231,7 +231,7 @@ describe('type narrowing — compile-time', () => {
231231
const root = parse('@media (min-width: 768px) {}')
232232
const mediaFeature = (root.first_child! as Atrule).prelude!.first_child!.first_child!
233233
if (is_media_feature(mediaFeature)) {
234-
expectTypeOf(mediaFeature).toMatchTypeOf<MediaFeature>()
234+
expectTypeOf(mediaFeature).toExtend<MediaFeature>()
235235
expectTypeOf(mediaFeature.property).toEqualTypeOf<string>()
236236
// `name` is absent on MediaFeature — verified by tsc
237237
}
@@ -241,7 +241,7 @@ describe('type narrowing — compile-time', () => {
241241
const root = parse('@layer utilities;')
242242
const layer = (root.first_child! as Atrule).prelude!.first_child!
243243
if (is_layer_name(layer)) {
244-
expectTypeOf(layer).toMatchTypeOf<LayerName>()
244+
expectTypeOf(layer).toExtend<LayerName>()
245245
expectTypeOf(layer.name).toEqualTypeOf<string>()
246246
}
247247
})
@@ -252,15 +252,15 @@ describe('type narrowing — compile-time', () => {
252252
const block = rule.block!
253253
// first_child on Block returns BlockChild, not the generic CSSNode
254254
const child = block.first_child
255-
expectTypeOf(child).toMatchTypeOf<BlockChild>()
255+
expectTypeOf(child).toExtend<BlockChild>()
256256
// next_sibling is narrowed to Raw | Declaration | Atrule | Rule, not CSSNode
257257
if (child.has_next) {
258-
expectTypeOf(child.next_sibling).toMatchTypeOf<Raw | Declaration | Atrule | Rule>()
258+
expectTypeOf(child.next_sibling).toExtend<Raw | Declaration | Atrule | Rule>()
259259
}
260260
// children[] and for-of also yield BlockChild
261-
expectTypeOf(block.children[0]).toMatchTypeOf<BlockChild>()
261+
expectTypeOf(block.children[0]).toExtend<BlockChild>()
262262
for (const c of block) {
263-
expectTypeOf(c).toMatchTypeOf<BlockChild>()
263+
expectTypeOf(c).toExtend<BlockChild>()
264264
}
265265
})
266266

0 commit comments

Comments
 (0)