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

WIP: [ts-migration] lib/core #9870

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
1 change: 1 addition & 0 deletions lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"license": "MIT",
"main": "dist/client/index.js",
"types": "dist/client/index.d.ts",
"files": [
"dist/**/*",
"dll/**/*",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ export const importPolyfills = () => {
if (!window.fetch) {
// manually patch window.fetch;
// see issue: <https://github.com/developit/unfetch/issues/101#issuecomment-454451035>
const patch = ({ default: fetch }) => {
window.fetch = fetch;
};

polyfills.push(import('unfetch/dist/unfetch').then(patch));
// todo needs review
polyfills.push(
import('unfetch').then(res => {
window.fetch = res.default;
})
);
}

return Promise.all(polyfills);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Provider } from '@storybook/ui';
import addons from '@storybook/addons';
import addons, { AddonStore } from '@storybook/addons';
import createChannel from '@storybook/channel-postmessage';
import Events from '@storybook/core-events';
import Channel from '@storybook/channels';

export default class ReactProvider extends Provider {
addons: AddonStore;

channel: Channel;

constructor() {
super();

Expand All @@ -16,15 +21,15 @@ export default class ReactProvider extends Provider {
this.channel = channel;
}

getElements(type) {
getElements(type: string) {
return this.addons.getElements(type);
}

getConfig() {
return this.addons.getConfig();
}

handleAPI(api) {
handleAPI(api: any) {
this.addons.loadAddons(api);
}
}
File renamed without changes.
Empty file added lib/core/src/public_api.ts
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export function getMiddleware(configDir) {
const middlewarePath = path.resolve(configDir, 'middleware.js');
if (fs.existsSync(middlewarePath)) {
let middlewareModule = require(middlewarePath); // eslint-disable-line
if (middlewareModule.__esModule) { // eslint-disable-line
if (middlewareModule.__esModule) {
// eslint-disable-line
middlewareModule = middlewareModule.default;
}
return middlewareModule;
Expand Down
1 change: 1 addition & 0 deletions lib/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export default class Provider {
getElements() {
getElements(type: string) {
Copy link
Member Author

Choose a reason for hiding this comment

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

fyi @ndelangen I had to modify the signature of getElements and handleAPI because every class that has extended this base class had these arguments implemented

I hope that's ok?

throw new Error('Provider.getElements() is not implemented!');
}

handleAPI() {
handleAPI(api: any) {
throw new Error('Provider.handleAPI() is not implemented!');
}

Expand Down