Skip to content

Commit

Permalink
chore: Enable Typescript strict mode (#26950)
Browse files Browse the repository at this point in the history
* chore: Enable Typescript strict mode

* change file

* revert unnecessary change

* update api-report after rebase
  • Loading branch information
miroslavstastny authored and radium-v committed May 6, 2024
1 parent db2cc99 commit 5134e81
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: Enable Typescript strict mode",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "none"
}
47 changes: 31 additions & 16 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export class AccordionItem extends FASTAccordionItem {
// @public
block: boolean;
// @public
expandIconPosition: AccordionItemExpandIconPosition;
expandIconPosition?: AccordionItemExpandIconPosition;
// @public
size: AccordionItemSize;
size?: AccordionItemSize;
}

// Warning: (ae-incompatible-release-tags) The symbol "definition" is marked as @public, but its signature references "AccordionItem" which is marked as @internal
Expand Down Expand Up @@ -239,8 +239,8 @@ export const AvatarTemplate: ElementViewTemplate<Avatar>;
export class Badge extends FASTElement {
appearance: BadgeAppearance;
color: BadgeColor;
shape: BadgeShape;
size: BadgeSize;
shape?: BadgeShape;
size?: BadgeSize;
}

// @internal
Expand Down Expand Up @@ -648,9 +648,15 @@ export const colorNeutralShadowKeyLighter: CSSDesignToken<string>;
// @public (undocumented)
export const colorNeutralStencil1: CSSDesignToken<string>;

// @public (undocumented)
export const colorNeutralStencil1Alpha: CSSDesignToken<string>;

// @public (undocumented)
export const colorNeutralStencil2: CSSDesignToken<string>;

// @public (undocumented)
export const colorNeutralStencil2Alpha: CSSDesignToken<string>;

// @public (undocumented)
export const colorNeutralStroke1: CSSDesignToken<string>;

Expand Down Expand Up @@ -891,6 +897,9 @@ export const colorPaletteGreenForeground2: CSSDesignToken<string>;
// @public (undocumented)
export const colorPaletteGreenForeground3: CSSDesignToken<string>;

// @public (undocumented)
export const colorPaletteGreenForegroundInverted: CSSDesignToken<string>;

// @public (undocumented)
export const colorPaletteLavenderBackground2: CSSDesignToken<string>;

Expand Down Expand Up @@ -1080,6 +1089,9 @@ export const colorPaletteRedForeground2: CSSDesignToken<string>;
// @public (undocumented)
export const colorPaletteRedForeground3: CSSDesignToken<string>;

// @public (undocumented)
export const colorPaletteRedForegroundInverted: CSSDesignToken<string>;

// @public (undocumented)
export const colorPaletteRoyalBlueBackground2: CSSDesignToken<string>;

Expand Down Expand Up @@ -1143,6 +1155,9 @@ export const colorPaletteYellowForeground2: CSSDesignToken<string>;
// @public (undocumented)
export const colorPaletteYellowForeground3: CSSDesignToken<string>;

// @public (undocumented)
export const colorPaletteYellowForegroundInverted: CSSDesignToken<string>;

// @public (undocumented)
export const colorScrollbarOverlay: CSSDesignToken<string>;

Expand Down Expand Up @@ -1210,8 +1225,8 @@ export const colorTransparentStrokeInteractive: CSSDesignToken<string>;
//
// @public
export class CounterBadge extends FASTElement {
appearance: CounterBadgeAppearance;
color: CounterBadgeColor;
appearance?: CounterBadgeAppearance;
color?: CounterBadgeColor;
count: number;
// (undocumented)
protected countChanged(): void;
Expand All @@ -1221,9 +1236,9 @@ export class CounterBadge extends FASTElement {
protected overflowCountChanged(): void;
// @internal
setCount(): string | void;
shape: CounterBadgeShape;
shape?: CounterBadgeShape;
showZero: boolean;
size: CounterBadgeSize;
size?: CounterBadgeSize;
}

// @internal
Expand Down Expand Up @@ -1506,8 +1521,8 @@ export const lineHeightHero900: CSSDesignToken<string>;

// @public
class ProgressBar_2 extends FASTProgress {
shape: ProgressBarShape;
thickness: ProgressBarThickness;
shape?: ProgressBarShape;
thickness?: ProgressBarThickness;
validationState: ProgressBarValidationState | null;
}
export { ProgressBar_2 as ProgressBar }
Expand Down Expand Up @@ -1656,8 +1671,8 @@ export const spacingVerticalXXXL: CSSDesignToken<string>;

// @public
export class Spinner extends FASTProgressRing {
appearance: SpinnerAppearance;
size: SpinnerSize;
appearance?: SpinnerAppearance;
size?: SpinnerSize;
}

// @public
Expand Down Expand Up @@ -1727,16 +1742,16 @@ export const switchTemplate: ElementViewTemplate<Switch>;

// @public
class Text_2 extends FASTElement {
align: TextAlign;
align?: TextAlign;
block: boolean;
font: TextFont;
font?: TextFont;
italic: boolean;
nowrap: boolean;
size: TextSize;
size?: TextSize;
strikethrough: boolean;
truncate: boolean;
underline: boolean;
weight: TextWeight;
weight?: TextWeight;
}
export { Text_2 as Text }

Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/accordion-item/accordion-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AccordionItem extends FASTAccordionItem {
* HTML Attribute: size
*/
@attr
public size: AccordionItemSize;
public size?: AccordionItemSize;

/**
* Sets the width of the focus state.
Expand All @@ -36,5 +36,5 @@ export class AccordionItem extends FASTAccordionItem {
* HTML Attribute: expandIconPosition
*/
@attr({ attribute: 'expand-icon-position' })
public expandIconPosition: AccordionItemExpandIconPosition;
public expandIconPosition?: AccordionItemExpandIconPosition;
}
4 changes: 2 additions & 2 deletions packages/web-components/src/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Badge extends FASTElement {
* HTML Attribute: shape
*/
@attr
public shape: BadgeShape;
public shape?: BadgeShape;

/**
* The size the badge should have.
Expand All @@ -44,7 +44,7 @@ export class Badge extends FASTElement {
* HTML Attribute: size
*/
@attr
public size: BadgeSize;
public size?: BadgeSize;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ElementViewTemplate, html } from '@microsoft/fast-element';
import { badgeTemplate } from '../badge/badge.template.js';
import { Badge } from '../badge/badge.js';
import { CounterBadge } from './counter-badge.js';
import { CounterBadgeOptions } from './counter-badge.options.js';

function composeTemplate<T extends CounterBadge>(options: CounterBadgeOptions = {}): ElementViewTemplate<T> {
return badgeTemplate({
function composeTemplate<T extends CounterBadge & Badge>(options: CounterBadgeOptions = {}): ElementViewTemplate<T> {
return badgeTemplate<T>({
defaultContent: html<T>`${x => x.setCount()}`,
});
}
Expand All @@ -13,4 +14,4 @@ function composeTemplate<T extends CounterBadge>(options: CounterBadgeOptions =
* The template for the Counter Badge component.
* @public
*/
export const template: ElementViewTemplate<CounterBadge> = composeTemplate<CounterBadge>();
export const template: ElementViewTemplate<CounterBadge> = composeTemplate<CounterBadge & Badge>();
8 changes: 4 additions & 4 deletions packages/web-components/src/counter-badge/counter-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CounterBadge extends FASTElement {
* HTML Attribute: appearance
*/
@attr
public appearance: CounterBadgeAppearance;
public appearance?: CounterBadgeAppearance;

/**
* The color the badge should have.
Expand All @@ -30,7 +30,7 @@ export class CounterBadge extends FASTElement {
* HTML Attribute: color
*/
@attr
public color: CounterBadgeColor;
public color?: CounterBadgeColor;
/**
* The shape the badge should have.
*
Expand All @@ -39,7 +39,7 @@ export class CounterBadge extends FASTElement {
* HTML Attribute: shape
*/
@attr
public shape: CounterBadgeShape;
public shape?: CounterBadgeShape;

/**
* The size the badge should have.
Expand All @@ -49,7 +49,7 @@ export class CounterBadge extends FASTElement {
* HTML Attribute: size
*/
@attr
public size: CounterBadgeSize;
public size?: CounterBadgeSize;

/**
* The count the badge should have.
Expand Down
6 changes: 3 additions & 3 deletions packages/web-components/src/progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ProgressBar extends FASTProgress {
* HTML Attribute: thickness
*/
@attr
public thickness: ProgressBarThickness;
public thickness?: ProgressBarThickness;

/**
* The shape of the progress bar
Expand All @@ -24,7 +24,7 @@ export class ProgressBar extends FASTProgress {
* HTML Attribute: shape
*/
@attr
public shape: ProgressBarShape;
public shape?: ProgressBarShape;

/**
* The validation state of the progress bar
Expand All @@ -33,5 +33,5 @@ export class ProgressBar extends FASTProgress {
* HTML Attribute: validation-state
*/
@attr({ attribute: 'validation-state' })
public validationState: ProgressBarValidationState | null;
public validationState: ProgressBarValidationState | null = null;
}
4 changes: 2 additions & 2 deletions packages/web-components/src/spinner/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Spinner extends FASTProgressRing {
* HTML Attribute: size
*/
@attr
public size: SpinnerSize;
public size?: SpinnerSize;

/**
* The appearance of the spinner
Expand All @@ -26,5 +26,5 @@ export class Spinner extends FASTProgressRing {
* HTML Attribute: appearance
*/
@attr
public appearance: SpinnerAppearance;
public appearance?: SpinnerAppearance;
}
8 changes: 4 additions & 4 deletions packages/web-components/src/text/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Text extends FASTElement {
*
*/
@attr
size: TextSize;
size?: TextSize;

/**
* THe Text font
Expand All @@ -87,7 +87,7 @@ export class Text extends FASTElement {
* HTML Attribute: font
*/
@attr
font: TextFont;
font?: TextFont;

/**
* THe Text weight
Expand All @@ -97,7 +97,7 @@ export class Text extends FASTElement {
* HTML Attribute: weight
*/
@attr
weight: TextWeight;
weight?: TextWeight;

/**
* THe Text align
Expand All @@ -107,5 +107,5 @@ export class Text extends FASTElement {
* HTML Attribute: align
*/
@attr
align: TextAlign;
align?: TextAlign;
}
5 changes: 5 additions & 0 deletions packages/web-components/src/theme/design-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export const colorNeutralBackgroundDisabled = create<string>('colorNeutralBackgr
export const colorNeutralBackgroundInvertedDisabled = create<string>('colorNeutralBackgroundInvertedDisabled');
export const colorNeutralStencil1 = create<string>('colorNeutralStencil1');
export const colorNeutralStencil2 = create<string>('colorNeutralStencil2');
export const colorNeutralStencil1Alpha = create<string>('colorNeutralStencil1Alpha');
export const colorNeutralStencil2Alpha = create<string>('colorNeutralStencil2Alpha');
export const colorBackgroundOverlay = create<string>('colorBackgroundOverlay');
export const colorScrollbarOverlay = create<string>('colorScrollbarOverlay');
export const colorBrandBackground = create<string>('colorBrandBackground');
Expand Down Expand Up @@ -369,6 +371,9 @@ export const colorPalettePlatinumBorderActive = create<string>('colorPalettePlat
export const colorPaletteAnchorBackground2 = create<string>('colorPaletteAnchorBackground2');
export const colorPaletteAnchorForeground2 = create<string>('colorPaletteAnchorForeground2');
export const colorPaletteAnchorBorderActive = create<string>('colorPaletteAnchorBorderActive');
export const colorPaletteRedForegroundInverted = create<string>('colorPaletteRedForegroundInverted');
export const colorPaletteGreenForegroundInverted = create<string>('colorPaletteGreenForegroundInverted');
export const colorPaletteYellowForegroundInverted = create<string>('colorPaletteYellowForegroundInverted');
export const shadow2 = create<string>('shadow2');
export const shadow4 = create<string>('shadow4');
export const shadow8 = create<string>('shadow8');
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/theme/set-theme.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Theme } from '@fluentui/tokens';
import * as tokens from './design-tokens.js';

const tokenNames = Object.keys(tokens);
const tokenNames = Object.keys(tokens) as (keyof Theme)[];

/**
* Sets the theme tokens on defaultNode.
* @param theme Flat object of theme token values.
*/
export const setTheme = (theme: Theme) => {
for (const t of tokenNames) {
tokens[t].withDefault(theme[t]);
tokens[t].withDefault(theme[t] as string);
}
};
2 changes: 1 addition & 1 deletion tsconfig.base.wc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"moduleResolution": "Node16",
"esModuleInterop": true,
"sourceMap": true,
"strictNullChecks": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"pretty": true,
Expand Down

0 comments on commit 5134e81

Please sign in to comment.