Skip to content

Commit 1cd6854

Browse files
committed
chore: typing fixes
1 parent 19ce9fc commit 1cd6854

6 files changed

Lines changed: 148 additions & 146 deletions

File tree

packages/core/__tests__/runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ moduleAlias.addAliases({
1616
'@nativescript/core/color': path.resolve(tnsCoreModules, 'color/color-common'),
1717
'@nativescript/core/ui/styling/font': path.resolve(tnsCoreModules, 'ui/styling/font-common'),
1818
'@nativescript/core/ui/styling/background': path.resolve(tnsCoreModules, 'ui/styling/background-common'),
19+
'@nativescript/core/ui/styling/css-shadow': path.resolve(tnsCoreModules, 'ui/styling/css-shadow'),
1920

2021
'@nativescript/core': tnsCoreModules,
2122
'~': __dirname,

packages/core/__tests__/ui/styling/css-shadow.ts

Lines changed: 140 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -2,144 +2,144 @@
22
// the imports don't work. We need to fully switch to jest & set up ts support
33
// todo: fix tests.
44

5-
// import { parseCSSShadow } from "@nativescript/core/ui/styling/css-shadow";
6-
// import { zeroLength } from "@nativescript/core";
5+
import { parseCSSShadow } from '@nativescript/core/ui/styling/css-shadow';
6+
import { zeroLength } from '@nativescript/core';
7+
import { assert } from 'chai';
78

8-
// describe('ui', () => {
9-
// describe('styling', () => {
10-
// describe('css-shadow', () => {
11-
//
12-
// it("empty", () => {
13-
// const shadow = parseCSSShadow("")
14-
// expect(shadow.inset).toBe(false)
15-
// expect(shadow.offsetX).toBe(zeroLength)
16-
// expect(shadow.offsetY).toBe(zeroLength)
17-
// expect(shadow.blurRadius).toBe(zeroLength)
18-
// expect(shadow.spreadRadius).toBe(zeroLength)
19-
// expect(shadow.color).toBe('black')
20-
// });
21-
//
22-
// it("1px 1px 2px black", () => {
23-
// const shadow = parseCSSShadow("1px 1px 2px black")
24-
// expect(shadow.inset).toBe(false)
25-
// expect(shadow.offsetX).toBe(1)
26-
// expect(shadow.offsetY).toBe(1)
27-
// expect(shadow.blurRadius).toBe(2)
28-
// expect(shadow.spreadRadius).toBe(zeroLength)
29-
// expect(shadow.color).toBe('black')
30-
// });
31-
//
32-
// it("#fc0 1px 0 10px", () => {
33-
// const shadow = parseCSSShadow("#fc0 1px 0 10px")
34-
// expect(shadow.inset).toBe(false)
35-
// expect(shadow.offsetX).toBe(1)
36-
// expect(shadow.offsetY).toBe(zeroLength)
37-
// expect(shadow.blurRadius).toBe(10)
38-
// expect(shadow.spreadRadius).toBe(zeroLength)
39-
// expect(shadow.color).toBe('#fc0')
40-
// });
41-
//
42-
// it("5px 5px #558abb", () => {
43-
// const shadow = parseCSSShadow("5px 5px #558abb")
44-
// expect(shadow.inset).toBe(false)
45-
// expect(shadow.offsetX).toBe(5)
46-
// expect(shadow.offsetY).toBe(5)
47-
// expect(shadow.blurRadius).toBe(zeroLength)
48-
// expect(shadow.spreadRadius).toBe(zeroLength)
49-
// expect(shadow.color).toBe('#558abb')
50-
// });
51-
//
52-
// it("white 2px 5px", () => {
53-
// const shadow = parseCSSShadow("white 2px 5px")
54-
// expect(shadow.inset).toBe(false)
55-
// expect(shadow.offsetX).toBe(2)
56-
// expect(shadow.offsetY).toBe(5)
57-
// expect(shadow.blurRadius).toBe(zeroLength)
58-
// expect(shadow.spreadRadius).toBe(zeroLength)
59-
// expect(shadow.color).toBe('white')
60-
// });
61-
//
62-
// it("5px 10px", () => {
63-
// const shadow = parseCSSShadow("5px 10px")
64-
// expect(shadow.inset).toBe(false)
65-
// expect(shadow.offsetX).toBe(5)
66-
// expect(shadow.offsetY).toBe(10)
67-
// expect(shadow.blurRadius).toBe(zeroLength)
68-
// expect(shadow.spreadRadius).toBe(zeroLength)
69-
// expect(shadow.color).toBe('black')
70-
// });
71-
//
72-
// // box
73-
// it("60px -16px teal", () => {
74-
// const shadow = parseCSSShadow("60px -16px teal")
75-
// expect(shadow.inset).toBe(false)
76-
// expect(shadow.offsetX).toBe(60)
77-
// expect(shadow.offsetY).toBe(-16)
78-
// expect(shadow.blurRadius).toBe(zeroLength)
79-
// expect(shadow.spreadRadius).toBe(zeroLength)
80-
// expect(shadow.color).toBe('teal')
81-
// });
82-
//
83-
// it("10px 5px 5px black", () => {
84-
// const shadow = parseCSSShadow("10px 5px 5px black")
85-
// expect(shadow.inset).toBe(false)
86-
// expect(shadow.offsetX).toBe(10)
87-
// expect(shadow.offsetY).toBe(5)
88-
// expect(shadow.blurRadius).toBe(zeroLength)
89-
// expect(shadow.spreadRadius).toBe(zeroLength)
90-
// expect(shadow.color).toBe('black')
91-
// });
92-
//
93-
// it("2px 2px 2px 1px rgba(0, 0, 0, 0.2)", () => {
94-
// const shadow = parseCSSShadow("2px 2px 2px 1px rgba(0, 0, 0, 0.2)")
95-
// expect(shadow.inset).toBe(false)
96-
// expect(shadow.offsetX).toBe(2)
97-
// expect(shadow.offsetY).toBe(2)
98-
// expect(shadow.blurRadius).toBe(2)
99-
// expect(shadow.spreadRadius).toBe(1)
100-
// expect(shadow.color).toBe('rgba(0, 0, 0, 0.2)')
101-
// });
102-
//
103-
// it("inset 5em 1em gold", () => {
104-
// const shadow = parseCSSShadow("inset 5em 1em gold")
105-
// expect(shadow.inset).toBe(true)
106-
// expect(shadow.offsetX).toBe(5)
107-
// expect(shadow.offsetY).toBe(1)
108-
// expect(shadow.blurRadius).toBe(zeroLength)
109-
// expect(shadow.spreadRadius).toBe(zeroLength)
110-
// expect(shadow.color).toBe('gold')
111-
// });
112-
//
113-
// it("5 10", () => {
114-
// const shadow = parseCSSShadow("5 10")
115-
// expect(shadow.inset).toBe(false)
116-
// expect(shadow.offsetX).toBe(5)
117-
// expect(shadow.offsetY).toBe(10)
118-
// expect(shadow.blurRadius).toBe(zeroLength)
119-
// expect(shadow.spreadRadius).toBe(zeroLength)
120-
// expect(shadow.color).toBe('black')
121-
// });
122-
//
123-
// it("2 2 2 #333", () => {
124-
// const shadow = parseCSSShadow("2 2 2 #333")
125-
// expect(shadow.inset).toBe(false)
126-
// expect(shadow.offsetX).toBe(2)
127-
// expect(shadow.offsetY).toBe(2)
128-
// expect(shadow.blurRadius).toBe(2)
129-
// expect(shadow.spreadRadius).toBe(zeroLength)
130-
// expect(shadow.color).toBe('#333')
131-
// });
132-
//
133-
// it("-1 -1 1 #333", () => {
134-
// const shadow = parseCSSShadow("-1 -1 1 #333")
135-
// expect(shadow.inset).toBe(false)
136-
// expect(shadow.offsetX).toBe(-1)
137-
// expect(shadow.offsetY).toBe(-1)
138-
// expect(shadow.blurRadius).toBe(1)
139-
// expect(shadow.spreadRadius).toBe(zeroLength)
140-
// expect(shadow.color).toBe('#333')
141-
// });
142-
// });
143-
// });
144-
// });
145-
//
9+
describe('ui', () => {
10+
describe('styling', () => {
11+
describe('css-shadow', () => {
12+
it('empty', () => {
13+
const shadow = parseCSSShadow('');
14+
// expect(shadow.inset).toBe(false)
15+
// expect(shadow.offsetX).toBe(zeroLength)
16+
// expect(shadow.offsetY).toBe(zeroLength)
17+
// expect(shadow.blurRadius).toBe(zeroLength)
18+
// expect(shadow.spreadRadius).toBe(zeroLength)
19+
// expect(shadow.color).toBe('black')
20+
assert.equal(shadow.inset, false);
21+
});
22+
23+
// it("1px 1px 2px black", () => {
24+
// const shadow = parseCSSShadow("1px 1px 2px black")
25+
// expect(shadow.inset).toBe(false)
26+
// expect(shadow.offsetX).toBe(1)
27+
// expect(shadow.offsetY).toBe(1)
28+
// expect(shadow.blurRadius).toBe(2)
29+
// expect(shadow.spreadRadius).toBe(zeroLength)
30+
// expect(shadow.color).toBe('black')
31+
// });
32+
33+
// it("#fc0 1px 0 10px", () => {
34+
// const shadow = parseCSSShadow("#fc0 1px 0 10px")
35+
// expect(shadow.inset).toBe(false)
36+
// expect(shadow.offsetX).toBe(1)
37+
// expect(shadow.offsetY).toBe(zeroLength)
38+
// expect(shadow.blurRadius).toBe(10)
39+
// expect(shadow.spreadRadius).toBe(zeroLength)
40+
// expect(shadow.color).toBe('#fc0')
41+
// });
42+
43+
// it("5px 5px #558abb", () => {
44+
// const shadow = parseCSSShadow("5px 5px #558abb")
45+
// expect(shadow.inset).toBe(false)
46+
// expect(shadow.offsetX).toBe(5)
47+
// expect(shadow.offsetY).toBe(5)
48+
// expect(shadow.blurRadius).toBe(zeroLength)
49+
// expect(shadow.spreadRadius).toBe(zeroLength)
50+
// expect(shadow.color).toBe('#558abb')
51+
// });
52+
53+
// it("white 2px 5px", () => {
54+
// const shadow = parseCSSShadow("white 2px 5px")
55+
// expect(shadow.inset).toBe(false)
56+
// expect(shadow.offsetX).toBe(2)
57+
// expect(shadow.offsetY).toBe(5)
58+
// expect(shadow.blurRadius).toBe(zeroLength)
59+
// expect(shadow.spreadRadius).toBe(zeroLength)
60+
// expect(shadow.color).toBe('white')
61+
// });
62+
63+
// it("5px 10px", () => {
64+
// const shadow = parseCSSShadow("5px 10px")
65+
// expect(shadow.inset).toBe(false)
66+
// expect(shadow.offsetX).toBe(5)
67+
// expect(shadow.offsetY).toBe(10)
68+
// expect(shadow.blurRadius).toBe(zeroLength)
69+
// expect(shadow.spreadRadius).toBe(zeroLength)
70+
// expect(shadow.color).toBe('black')
71+
// });
72+
73+
// // box
74+
// it("60px -16px teal", () => {
75+
// const shadow = parseCSSShadow("60px -16px teal")
76+
// expect(shadow.inset).toBe(false)
77+
// expect(shadow.offsetX).toBe(60)
78+
// expect(shadow.offsetY).toBe(-16)
79+
// expect(shadow.blurRadius).toBe(zeroLength)
80+
// expect(shadow.spreadRadius).toBe(zeroLength)
81+
// expect(shadow.color).toBe('teal')
82+
// });
83+
84+
// it("10px 5px 5px black", () => {
85+
// const shadow = parseCSSShadow("10px 5px 5px black")
86+
// expect(shadow.inset).toBe(false)
87+
// expect(shadow.offsetX).toBe(10)
88+
// expect(shadow.offsetY).toBe(5)
89+
// expect(shadow.blurRadius).toBe(zeroLength)
90+
// expect(shadow.spreadRadius).toBe(zeroLength)
91+
// expect(shadow.color).toBe('black')
92+
// });
93+
94+
// it("2px 2px 2px 1px rgba(0, 0, 0, 0.2)", () => {
95+
// const shadow = parseCSSShadow("2px 2px 2px 1px rgba(0, 0, 0, 0.2)")
96+
// expect(shadow.inset).toBe(false)
97+
// expect(shadow.offsetX).toBe(2)
98+
// expect(shadow.offsetY).toBe(2)
99+
// expect(shadow.blurRadius).toBe(2)
100+
// expect(shadow.spreadRadius).toBe(1)
101+
// expect(shadow.color).toBe('rgba(0, 0, 0, 0.2)')
102+
// });
103+
104+
// it("inset 5em 1em gold", () => {
105+
// const shadow = parseCSSShadow("inset 5em 1em gold")
106+
// expect(shadow.inset).toBe(true)
107+
// expect(shadow.offsetX).toBe(5)
108+
// expect(shadow.offsetY).toBe(1)
109+
// expect(shadow.blurRadius).toBe(zeroLength)
110+
// expect(shadow.spreadRadius).toBe(zeroLength)
111+
// expect(shadow.color).toBe('gold')
112+
// });
113+
114+
// it("5 10", () => {
115+
// const shadow = parseCSSShadow("5 10")
116+
// expect(shadow.inset).toBe(false)
117+
// expect(shadow.offsetX).toBe(5)
118+
// expect(shadow.offsetY).toBe(10)
119+
// expect(shadow.blurRadius).toBe(zeroLength)
120+
// expect(shadow.spreadRadius).toBe(zeroLength)
121+
// expect(shadow.color).toBe('black')
122+
// });
123+
124+
// it("2 2 2 #333", () => {
125+
// const shadow = parseCSSShadow("2 2 2 #333")
126+
// expect(shadow.inset).toBe(false)
127+
// expect(shadow.offsetX).toBe(2)
128+
// expect(shadow.offsetY).toBe(2)
129+
// expect(shadow.blurRadius).toBe(2)
130+
// expect(shadow.spreadRadius).toBe(zeroLength)
131+
// expect(shadow.color).toBe('#333')
132+
// });
133+
134+
// it("-1 -1 1 #333", () => {
135+
// const shadow = parseCSSShadow("-1 -1 1 #333")
136+
// expect(shadow.inset).toBe(false)
137+
// expect(shadow.offsetX).toBe(-1)
138+
// expect(shadow.offsetY).toBe(-1)
139+
// expect(shadow.blurRadius).toBe(1)
140+
// expect(shadow.spreadRadius).toBe(zeroLength)
141+
// expect(shadow.color).toBe('#333')
142+
// });
143+
});
144+
});
145+
});

packages/core/ui/page/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export declare class Page extends PageBase {
9696
/**
9797
* Should page changed be annnounced to the screen reader.
9898
*/
99-
public accessibilityAnnouncePageEnabled = true;
99+
public accessibilityAnnouncePageEnabled: boolean;
100100

101101
/**
102102
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).

packages/core/ui/slider/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { View } from '../core/view';
22
import { Property, CoercibleProperty } from '../core/properties';
33
import { EventData } from '../../data/observable';
4+
import type { SliderBase } from './slider-common';
45

56
/**
67
* Represents a slider component.

packages/core/ui/styling/background.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Color } from '../../color';
22
import { View } from '../core/view';
33
import { BackgroundRepeat } from '../../css/parser';
44
import { LinearGradient } from '../styling/linear-gradient';
5-
import { BoxShadow } from './box-shadow';
5+
import { CSSShadow } from './css-shadow';
66

77
export enum CacheMode {
88
none,
@@ -30,7 +30,7 @@ export declare class Background {
3030
public borderBottomRightRadius: number;
3131
public borderBottomLeftRadius: number;
3232
public clipPath: string;
33-
public boxShadow: string | BoxShadow;
33+
public boxShadow: string | CSSShadow;
3434

3535
public withColor(value: Color): Background;
3636
public withImage(value: string | LinearGradient): Background;
@@ -50,7 +50,7 @@ export declare class Background {
5050
public withBorderBottomRightRadius(value: number): Background;
5151
public withBorderBottomLeftRadius(value: number): Background;
5252
public withClipPath(value: string): Background;
53-
public withBoxShadow(value: BoxShadow): Background;
53+
public withBoxShadow(value: CSSShadow): Background;
5454

5555
public isEmpty(): boolean;
5656

@@ -67,7 +67,7 @@ export declare class Background {
6767
public getUniformBorderWidth(): number;
6868
public getUniformBorderRadius(): number;
6969
public hasBoxShadow(): boolean;
70-
public getBoxShadow(): BoxShadow;
70+
public getBoxShadow(): CSSShadow;
7171
}
7272

7373
export namespace ios {

packages/core/ui/text-base/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export type TextDecoration = 'none' | 'underline' | 'line-through' | 'underline
130130
export const textAlignmentProperty: InheritedCssProperty<Style, TextAlignment>;
131131
export const textDecorationProperty: CssProperty<Style, TextDecoration>;
132132
export const textTransformProperty: CssProperty<Style, TextTransform>;
133-
export const textShadowProperty: CssProperty<Style, TextShadow>;
133+
export const textShadowProperty: CssProperty<Style, CSSShadow>;
134134
export const whiteSpaceProperty: CssProperty<Style, WhiteSpace>;
135135
export const letterSpacingProperty: CssProperty<Style, number>;
136136
export const lineHeightProperty: CssProperty<Style, number>;

0 commit comments

Comments
 (0)