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

Typescript: Migrate @storybook/polymer #8102

Merged
merged 22 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f003cf9
wip: start typescript migration of polymer
kroeder Sep 17, 2019
bdeef27
remove exclusion of __tests__
kroeder Sep 17, 2019
862369d
add types for polymer/server
kroeder Sep 17, 2019
1c11681
wip: migrate polymer/client to typescript
kroeder Sep 17, 2019
8569339
Merge branch 'next' into ts-migration/polymer
ndelangen Nov 15, 2019
c11ee24
wip: proceed ts migration
kroeder Nov 19, 2019
a9afa17
Merge branch 'next' into ts-migration/polymer
kroeder Nov 19, 2019
7cc8043
trigger ci
kroeder Nov 19, 2019
2d70ce2
Merge branch 'next' into ts-migration/polymer
ndelangen Nov 21, 2019
13816cb
Merge branch 'next' into ts-migration/polymer
shilman Nov 26, 2019
c38000e
Merge branch 'next' into ts-migration/polymer
ndelangen Nov 28, 2019
754579a
Merge branch 'next-6.0.0' into ts-migration/polymer
ndelangen Dec 20, 2019
55b9876
Merge branch 'next-6.0.0' into ts-migration/polymer
ndelangen Jan 11, 2020
ad67e81
Merge branch 'next-6.0.0' into ts-migration/polymer
ndelangen Jan 14, 2020
9e7e2c7
Update 1-Button.stories.ts
devtronic Jan 19, 2020
36ee762
fix: clean usage of `@types/webpack-env` dep in all packages
gaetanmaisse Jan 19, 2020
3046a88
Merge branch 'next-6.0.0' into ts-migration/polymer
ndelangen Jan 20, 2020
5779f18
Clean usage of `@types/webpack-env` dep in all packages (#9536)
shilman Jan 20, 2020
3026db9
Next 6.0.0 (#9212)
ndelangen Jan 20, 2020
593ac5f
Fixed Angular button example story (#9540)
ndelangen Jan 20, 2020
3ab7e7a
6.0.0-alpha.0 changelog
shilman Jan 20, 2020
b8543b5
Merge branch 'next' into pr/kroeder/8102
ndelangen Jan 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## 6.0.0-alpha.0 (January 21, 2020)

### Features

* Addon-a11y: Support manual run ([#8883](https://github.com/storybookjs/storybook/pull/8883))
* Addon-cssresources: Disable SyntaxHighlighter for long code ([#9360](https://github.com/storybookjs/storybook/pull/9360))
* Core: Improve monorepo support ([#8822](https://github.com/storybookjs/storybook/pull/8822))

### Bug Fixes

* Fixed Angular button example story ([#9540](https://github.com/storybookjs/storybook/pull/9540))
* Core: Fix generated entry to import at top of file ([#9398](https://github.com/storybookjs/storybook/pull/9398))
* Preact: Fix story function typescript type ([#9123](https://github.com/storybookjs/storybook/pull/9123))
* UI: Make canvas link a link ([#9257](https://github.com/storybookjs/storybook/pull/9257))

### Maintenance

* Typescript: Migrate ember ([#9020](https://github.com/storybookjs/storybook/pull/9020))
* Next 6.0.0 ([#9212](https://github.com/storybookjs/storybook/pull/9212))
* Lock yarn version ([#9138](https://github.com/storybookjs/storybook/pull/9138))
* REMOVE subscription_store ([#9228](https://github.com/storybookjs/storybook/pull/9228))

### Dependency Upgrades

* Update husky to v4 ([#9509](https://github.com/storybookjs/storybook/pull/9509))

## 5.3.7 (January 20, 2020)

### Bug Fixes
Expand Down
3 changes: 2 additions & 1 deletion addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/react-redux": "^7.0.6"
"@types/react-redux": "^7.0.6",
"@types/webpack-env": "^1.15.0"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 4 additions & 1 deletion addons/a11y/src/components/Report/HighlightToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,7 @@ class HighlightToggle extends Component<ToggleProps> {
}
}

export default connect(mapStateToProps, mapDispatchToProps)(HighlightToggle);
export default connect(
mapStateToProps,
mapDispatchToProps
)(HighlightToggle);
3 changes: 2 additions & 1 deletion addons/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
},
"devDependencies": {
"@types/lodash": "^4.14.149",
"@types/uuid": "^3.4.4"
"@types/uuid": "^3.4.4",
"@types/webpack-env": "^1.15.0"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/util-deprecate": "^1.0.0"
"@types/util-deprecate": "^1.0.0",
"@types/webpack-env": "^1.15.0"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions addons/centered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"devDependencies": {
"@types/mithril": "^1.1.16",
"@types/webpack-env": "^1.15.0",
"mithril": "*",
"preact": "*",
"react": "*"
Expand Down
5 changes: 1 addition & 4 deletions addons/contexts/src/manager/components/ToolBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ describe('Tests on addon-contexts component: ToolBar', () => {
icon: 'box' as const,
nodeId: 'Some Context B',
options: { cancelable: true, deep: false, disable: false },
params: [
{ name: 'Some Param X', props: {} },
{ name: 'Some Param Y', props: {} },
],
params: [{ name: 'Some Param X', props: {} }, { name: 'Some Param Y', props: {} }],
title: 'Some Context B',
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ describe('Tests on addon-contexts component: ToolBarControl', () => {
icon: 'box' as const,
nodeId: 'Some Context',
options: { cancelable: true, deep: false, disable: false },
params: [
{ name: 'A', props: {} },
{ name: 'B', props: {} },
],
params: [{ name: 'A', props: {} }, { name: 'B', props: {} }],
title: 'Some Context',
selected: '',
setSelected: jest.fn,
Expand Down
3 changes: 3 additions & 0 deletions addons/cssresources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"global": "^4.3.2",
"react": "^16.8.3"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
},
Expand Down
1 change: 0 additions & 1 deletion addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"@types/jest": "^24.0.11",
"@types/prop-types": "^15.5.9",
"@types/util-deprecate": "^1.0.0",
"@types/webpack-env": "^1.14.0",
"jest-specific-snapshot": "^2.0.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion addons/essentials/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"types": ["webpack-env", "jest"]
"types": ["jest"]
},
"include": ["src/**/*"],
"exclude": ["src/**.test.ts"]
Expand Down
3 changes: 3 additions & 0 deletions addons/events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"react-textarea-autosize": "^7.0.4",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
},
Expand Down
3 changes: 3 additions & 0 deletions addons/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"upath": "^1.1.0",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
},
Expand Down
3 changes: 2 additions & 1 deletion addons/knobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"devDependencies": {
"@types/escape-html": "0.0.20",
"@types/react-lifecycles-compat": "^3.0.1",
"@types/react-select": "^2.0.19"
"@types/react-select": "^2.0.19",
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
Expand Down
3 changes: 3 additions & 0 deletions addons/links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"qs": "^6.6.0",
"ts-dedent": "^1.1.0"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion addons/notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"@types/prop-types": "^15.5.9",
"@types/util-deprecate": "^1.0.0",
"@types/webpack-env": "^1.14.0"
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
Expand Down
3 changes: 1 addition & 2 deletions addons/ondevice-backgrounds/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"types": ["webpack-env"]
"rootDir": "./src"
},
"include": [
"src/**/*"
Expand Down
25 changes: 12 additions & 13 deletions addons/ondevice-notes/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"types": ["webpack-env"]
},
"include": [
"src/**/*"
],
"exclude": [
"src/__tests__/**/*"
]
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
},
"include": [
"src/**/*"
],
"exclude": [
"src/__tests__/**/*"
]
}
3 changes: 3 additions & 0 deletions addons/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"core-js": "^3.0.1",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"peerDependencies": {
"react": "*"
},
Expand Down
3 changes: 3 additions & 0 deletions addons/queryparams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"react": "^16.8.3",
"ts-dedent": "^1.1.0"
},
"devDependencies": {
"@types/webpack-env": "^1.15.0"
},
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion app/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@storybook/addons": "5.3.7",
"@storybook/core": "5.3.7",
"@storybook/node-logger": "5.3.7",
"@types/webpack-env": "^1.15.0",
"core-js": "^3.0.1",
"fork-ts-checker-webpack-plugin": "^3.0.1",
"global": "^4.3.2",
Expand All @@ -47,7 +48,6 @@
},
"devDependencies": {
"@types/autoprefixer": "^9.4.0",
"@types/webpack-env": "^1.14.0",
"webpack": "^4.33.0"
},
"peerDependencies": {
Expand Down
2 changes: 0 additions & 2 deletions app/angular/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export {

export { moduleMetadata } from './preview/angular/decorators';

// tsc wants to use NodeModule instead of WebpackModule
declare const module: any;
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
2 changes: 1 addition & 1 deletion app/angular/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compileOnSave": false,
"compilerOptions": {
"outDir": "dist",
"types": [],
"types": ["webpack-env"],
"rootDir": "./src",
"resolveJsonModule": true
}
Expand Down
2 changes: 1 addition & 1 deletion app/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@storybook/addons": "5.3.7",
"@storybook/core": "5.3.7",
"@types/webpack-env": "^1.13.9",
"@types/webpack-env": "^1.15.0",
"core-js": "^3.0.1",
"global": "^4.3.2",
"html-loader": "^0.5.5",
Expand Down
1 change: 1 addition & 0 deletions app/mithril/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@storybook/addons": "5.3.7",
"@storybook/core": "5.3.7",
"@types/mithril": "^2.0.0",
"@types/webpack-env": "^1.15.0",
"core-js": "^3.0.1",
"global": "^4.3.2",
"regenerator-runtime": "^0.13.3",
Expand Down
2 changes: 2 additions & 0 deletions app/polymer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"*.d.ts"
],
"main": "dist/client/index.js",
"types": "dist/client/index.d.ts",
"bin": {
"build-storybook": "./bin/build.js",
"start-storybook": "./bin/index.js",
Expand All @@ -32,6 +33,7 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "5.3.7",
"@storybook/core": "5.3.7",
"@webcomponents/webcomponentsjs": "^1.2.0",
"core-js": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export {
raw,
} from './preview';

// tsc wants to use NodeModule instead of WebpackModule
declare const module: any;
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const {
} = clientApi;

const framework = 'polymer';
export const storiesOf = (...args) => clientApi.storiesOf(...args).addParameters({ framework });
export const configure = (...args) => coreConfigure(...args, framework);

export const storiesOf = (...args: any[]) =>
clientApi.storiesOf(...args).addParameters({ framework });
export const configure = (...args: any[]) => coreConfigure(...args, framework);

export { forceReRender };
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { document } from 'global';
import dedent from 'ts-dedent';
import { render, TemplateResult } from 'lit-html';
import { RenderMainArgs } from './types';

const rootElement = document.getElementById('root');

Expand All @@ -11,7 +12,7 @@ export default function renderMain({
showMain,
showError,
forceRender,
}) {
}: RenderMainArgs) {
const element = storyFn();

if (!element) {
Expand Down
28 changes: 28 additions & 0 deletions app/polymer/src/client/preview/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { TemplateResult } from 'lit-html';

export interface IStorybookSection {
kind: string;
stories: IStorybookStory[];
}

export interface IStorybookStory {
name: string;
render: () => any;
}

export type StoryFnPolymerReturnType = string | Node | TemplateResult;

export interface ShowErrorArgs {
title: string;
description: string;
}

export interface RenderMainArgs {
storyFn: (...args: any[]) => StoryFnPolymerReturnType;
selectedKind: string;
selectedStory: string;
showMain: () => void;
showError: (args: ShowErrorArgs) => void;
showException: (err: Error) => void;
forceRender: boolean;
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IgnorePlugin } from 'webpack';
import { Configuration, IgnorePlugin, RuleSetUseItem } from 'webpack';

export function webpack(config) {
export function webpack(config: Configuration) {
return {
...config,
module: {
Expand All @@ -10,7 +10,7 @@ export function webpack(config) {
{
test: /\.html$/,
use: [
...config.module.rules[0].use,
...(config.module.rules[0].use as RuleSetUseItem[]),
Copy link
Member Author

@kroeder kroeder Sep 17, 2019

Choose a reason for hiding this comment

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

tslint complained about the typing of use. I had to cast it but it might be a bug

rules[0].use can be

type RuleSetUse =
        | RuleSetUseItem
        | RuleSetUseItem[]
        | ((data: any) => RuleSetUseItem | RuleSetUseItem[]);

or are we 100% certain it is always RuleSetUseItem[]? Do we need to add a check here?

Copy link
Member

Choose a reason for hiding this comment

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

We can't be not sure, we should probably check

{
loader: require.resolve('polymer-webpack-loader'),
options: { processStyleLinks: true },
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import packageJson from '../../package.json';
const packageJson = require('../../package.json');

export default {
packageJson,
Expand Down
5 changes: 5 additions & 0 deletions app/polymer/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '@storybook/core/*';
declare module 'global';

// will be provided by the webpack define plugin
declare var NODE_ENV: string | undefined;