Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-3370] Fix harmony types #6694

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"rollup": "2.76.0",
"rollup-plugin-dts": "4.2.2",
"rollup-plugin-typescript2": "0.32.1",
"ttypescript": "^1.5.15",
"typescript-transform-paths": "^3.4.4"
"ttypescript": "1.5.15",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is always going to look like a typo to me

"typescript-transform-paths": "3.4.4"
},
"peerDependencies": {
"@reduxjs/toolkit": "1.6.1",
Expand Down
14 changes: 2 additions & 12 deletions packages/common/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import image from '@rollup/plugin-image'
import rollupTypescript from 'rollup-plugin-typescript2'
import ttypescript from 'ttypescript'

import pkg from './package.json'

Expand All @@ -22,18 +23,7 @@ export default [
],
plugins: [
rollupTypescript({
typescript: require('ttypescript'),
tsconfigDefaults: {
compilerOptions: {
plugins: [
{ transform: 'typescript-transform-paths' },
{
transform: 'typescript-transform-paths',
afterDeclarations: true
}
]
}
}
typescript: ttypescript
}),
image()
],
Expand Down
4 changes: 4 additions & 0 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"utils/*": ["src/utils/*"],
"utils": ["src/utils"]
},
"plugins": [
{ "transform": "typescript-transform-paths" },
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
],
"module": "esnext",
"target": "es6",
"moduleResolution": "node",
Expand Down
3 changes: 2 additions & 1 deletion packages/harmony/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@
"storybook-addon-smart-knobs": "6.0.2",
"storybook-dark-mode": "3.0.1",
"tsconfig-paths-webpack-plugin": "3.5.2",
"typescript": "4.9.4",
"ttypescript": "1.5.15",
"typescript-plugin-css-modules": "3.4.0",
"typescript-transform-paths": "3.4.4",
"webpack": "4.46.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/harmony/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import svgr from '@svgr/rollup'
import json from 'rollup-plugin-json'
import postcss from 'rollup-plugin-postcss'
import rollupTypescript from 'rollup-plugin-typescript2'
import typescript from 'typescript'
import ttypescript from 'ttypescript'

import pkg from './package.json' assert { type: 'json' }

Expand Down Expand Up @@ -34,8 +34,8 @@ export default {
}),
svgr(),
rollupTypescript({
clean: true,
typescript
typescript: ttypescript,
clean: true
})
],
external
Expand Down
2 changes: 1 addition & 1 deletion packages/harmony/src/components/avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { Meta, StoryObj } from '@storybook/react'
import { Box } from 'components/layout/Box'
import { Flex } from 'components/layout/Flex'
import { Paper } from 'components/layout/Paper'
// TODO: Get final image assets from Sammie
import shadowBackground from 'storybook/assets/shadowBackground.jpeg'
// TODO: Get final image assets from Sammie

import { Avatar } from './Avatar'

Expand Down
8 changes: 5 additions & 3 deletions packages/harmony/src/components/icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export const iconSizes = {

type IconSize = keyof typeof iconSizes

type IconProps = {
type BaseIconProps = SVGProps<SVGSVGElement>

type IconProps = BaseIconProps & {
color?: IconColors
size?: IconSize
} & SVGProps<SVGSVGElement>
}

export type IconComponent = ComponentType<IconProps>
export type IconComponent = ComponentType<BaseIconProps | IconProps>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm no ts wizard but do we need the | BaseIconProps if IconProps is already intersection'd (&) with BaseIconProps and the extra fields of IconProps are optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird, but its for stems icons passed into harmony components. This is either the icon with some extra props (harmony icons) or just the base props (stems). Ideally this just goes away when we migrate all the icons


/**
* Renders a harmony Icon component
Expand Down
20 changes: 18 additions & 2 deletions packages/harmony/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "esnext",
"sourceMap": true,
"checkJs": false,
"plugins": [{ "name": "typescript-plugin-css-modules" }],
"allowJs": false,
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",
Expand All @@ -14,7 +13,24 @@
"exactOptionalPropertyTypes": false,
"declaration": true,
"declarationMap": true,
"baseUrl": "./src",
"baseUrl": "./",
"paths": {
"foundations": ["src/foundations/index.ts"],
"foundations/*": ["src/foundations/*"],
"components": ["src/components/index.ts"],
"components/*": ["src/components/*"],
"icons": ["src/icons/index.ts"],
"icons/*": ["src/icons/*"],
"assets": ["src/assets/index.ts"],
"assets/*": ["src/assets/*"],
"storybook": ["src/storybook/index.ts"],
"storybook/*": ["src/storybook/*"]
},
"plugins": [
{ "name": "typescript-plugin-css-modules" },
{ "transform": "typescript-transform-paths" },
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
],
"outDir": "build",
"declarationDir": "./",
"noPropertyAccessFromIndexSignature": false,
Expand Down