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

Marionette: migrate to TS #13448

Merged
merged 1 commit into from
Jan 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/marionette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"regenerator-runtime": "^0.13.7"
},
"devDependencies": {
"@types/backbone.marionette": "^3.3.12",
"@types/common-tags": "^1.8.0",
"backbone.marionette": "*"
},
"peerDependencies": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const allMarionetteViewConstructors = [
];
const viewConstructorsSupportedByMarionette = allMarionetteViewConstructors
.filter((constructorName) => constructorName in Marionette)
.map((constructorName) => Marionette[constructorName]);
.map((constructorName) => (Marionette as any)[constructorName]);
Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to find the correct type but it's too 🤯 for a non-marionette user.


// accepts an element and return true if renderable else return false
const isMarionetteRenderable = (element) => {
const isMarionetteRenderable = (element: any) => {
return viewConstructorsSupportedByMarionette.find(
(Constructor) => element instanceof Constructor
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export const {
} = clientApi;

const framework = 'marionette';
export const storiesOf = (...args) => clientApi.storiesOf(...args).addParameters({ framework });
export const load = (...args) => coreLoad(...args, framework);
export const storiesOf = (...args: any) =>
clientApi.storiesOf(...args).addParameters({ framework });
export const load = (...args: any) => coreLoad(...args, framework);
Comment on lines +18 to +20
Copy link
Member Author

Choose a reason for hiding this comment

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

Will be properly type as soon as I will rework some @storybook/core types


export const { configure } = configApi;
export { forceReRender };
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import { document } from 'global';
import { stripIndents } from 'common-tags';
import Marionette from 'backbone.marionette';
import Marionette, { View } from 'backbone.marionette';
import isMarionetteRenderable from './element_check';

const rootEl = document.getElementById('root');
const rootRegion = new Marionette.Region({ el: rootEl });

function render(view) {
function render(view: View<any>) {
rootRegion.show(view);
}

export default function renderMain({ storyFn, kind, name, showMain, showError }) {
export default function renderMain({
storyFn,
kind,
name,
showMain,
showError,
}: {
storyFn: any;
kind: string;
name: string;
showMain: () => any;
showError: (options: { title: string; description: string }) => void;
}) {
const element = storyFn();

if (!element) {
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions app/marionette/src/server/framework-preset-marionette.js

This file was deleted.

6 changes: 6 additions & 0 deletions app/marionette/src/server/framework-preset-marionette.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { Configuration } from 'webpack';

export function webpack(config: Configuration) {
return config;
}
Comment on lines +4 to +6
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure we need this but I didn't want to make changes to production code other than a simple TS migration.

File renamed without changes.
2 changes: 2 additions & 0 deletions app/marionette/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '@storybook/core/*';
declare module 'global';
7 changes: 7 additions & 0 deletions app/marionette/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"types": ["webpack-env"]
}
}
44 changes: 43 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4438,6 +4438,31 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/backbone.marionette@^3.3.12":
version "3.3.12"
resolved "https://registry.yarnpkg.com/@types/backbone.marionette/-/backbone.marionette-3.3.12.tgz#f9fca0039c8d4ecc2e252c5074c0c148fd549191"
integrity sha512-+jJtbRQKRPoBFwsltIPNqyKXPwSQN0rDl2ZYry+ma6H4l5W+XccEOcBp9S64DqagLdJ29OTEyU/+b9o0lR0BrA==
dependencies:
"@types/backbone" "*"
"@types/backbone.radio" "*"
"@types/jquery" "*"
"@types/underscore" "*"

"@types/backbone.radio@*":
version "0.8.37"
resolved "https://registry.yarnpkg.com/@types/backbone.radio/-/backbone.radio-0.8.37.tgz#c049db3f29dc5bb55a4b3cffcfd3ec7d9d985ec5"
integrity sha512-N0+9bvV/NfXBO772lsPPFtxrHNYOqm8ctwfF8eJAqbjQ/wKqzZfh/uMLCv6CBkenSWro3W1GIpRntMFSQvHQRA==
dependencies:
"@types/backbone" "*"

"@types/backbone@*":
version "1.4.5"
resolved "https://registry.yarnpkg.com/@types/backbone/-/backbone-1.4.5.tgz#057d89987fb672a20b896b1df5cc802f7b87c624"
integrity sha512-pSqM0eryp6V3G0srBtndUd9IJmiG2BAwYLQGPDcEPMjbfbgitlrN40+Lc1rrMjNMbV5QWywe6WPmNjdqyNTyIw==
dependencies:
"@types/jquery" "*"
"@types/underscore" "*"

"@types/body-parser@*":
version "1.19.0"
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.0.tgz#0685b3c47eb3006ffed117cdd55164b61f80538f"
Expand Down Expand Up @@ -4489,6 +4514,11 @@
dependencies:
"@types/node" "*"

"@types/common-tags@^1.8.0":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@types/common-tags/-/common-tags-1.8.0.tgz#79d55e748d730b997be5b7fce4b74488d8b26a6b"
integrity sha512-htRqZr5qn8EzMelhX/Xmx142z218lLyGaeZ3YR8jlze4TATRU9huKKvuBmAJEW4LCC4pnY1N6JAm6p85fMHjhg==

"@types/connect-history-api-fallback@*":
version "1.3.3"
resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.3.tgz#4772b79b8b53185f0f4c9deab09236baf76ee3b4"
Expand Down Expand Up @@ -4790,6 +4820,13 @@
jest-diff "^25.2.1"
pretty-format "^25.2.1"

"@types/jquery@*":
version "3.5.5"
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.5.5.tgz#2c63f47c9c8d96693d272f5453602afd8338c903"
integrity sha512-6RXU9Xzpc6vxNrS6FPPapN1SxSHgQ336WC6Jj/N8q30OiaBZ00l1GBgeP7usjVZPivSkGUfL1z/WW6TX989M+w==
dependencies:
"@types/sizzle" "*"

"@types/js-yaml@^3.12.4":
version "3.12.5"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.5.tgz#136d5e6a57a931e1cce6f9d8126aa98a9c92a6bb"
Expand Down Expand Up @@ -5153,7 +5190,7 @@
resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz#681df970358c82836b42f989188d133e218c458e"
integrity sha512-yYezQwGWty8ziyYLdZjwxyMb0CZR49h8JALHGrxjQHWlqGgc8kLdHEgWrgL0uZ29DMvEVBDnHU2Wg36zKSIUtA==

"@types/sizzle@2.3.2":
"@types/sizzle@*", "@types/sizzle@2.3.2":
version "2.3.2"
resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
integrity sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==
Expand Down Expand Up @@ -5217,6 +5254,11 @@
dependencies:
source-map "^0.6.1"

"@types/underscore@*":
version "1.10.24"
resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.10.24.tgz#dede004deed3b3f99c4db0bdb9ee21cae25befdd"
integrity sha512-T3NQD8hXNW2sRsSbLNjF/aBo18MyJlbw0lSpQHB/eZZtScPdexN4HSa8cByYwTw9Wy7KuOFr81mlDQcQQaZ79w==

"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
Expand Down