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

Added type annotation to helpers, added ts declaration files for angu… #2459

Merged
merged 17 commits into from
Dec 22, 2017

Conversation

ralzinov
Copy link
Contributor

Issue:

Modules "storybook/angular" and "storybook/anguar/demo" has no type declaration files and
angular helpers has no proper typings. ts-loader throws many errors with "noExplicitAny" flag enabled. Issue

What I did

Added type declaration fles for "storybook/angular" and "storybook/anguar/demo" modules. Annotated angular helpers functions

How to test

Set "noExplicitAny": true in tsconfig.json

Is this testable with jest or storyshots?
no

Does this need a new example in the kitchen sink apps?
no

Does this need an update to the documentation?
no

@codecov
Copy link

codecov bot commented Dec 11, 2017

Codecov Report

Merging #2459 into release/3.3 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           release/3.3    #2459   +/-   ##
============================================
  Coverage        20.18%   20.18%           
============================================
  Files              398      398           
  Lines             8838     8838           
  Branches           940      952   +12     
============================================
  Hits              1784     1784           
+ Misses            6358     6324   -34     
- Partials           696      730   +34
Impacted Files Coverage Δ
app/vue/src/server/utils.js 0% <0%> (-53.58%) ⬇️
...ents/stories_panel/stories_tree/tree_decorators.js 34.37% <0%> (ø) ⬆️
lib/ui/src/modules/ui/configs/handle_routing.js 24.21% <0%> (ø) ⬆️
addons/knobs/src/components/types/Color.js 8.21% <0%> (ø) ⬆️
addons/actions/src/lib/types/function/index.js 33.33% <0%> (ø) ⬆️
addons/knobs/src/components/types/Array.js 34.14% <0%> (ø) ⬆️
addons/actions/src/lib/util/canConfigureName.js 30% <0%> (ø) ⬆️
addons/actions/src/lib/decycle.js 36.61% <0%> (ø) ⬆️
...react-native/src/manager/components/PreviewHelp.js 0% <0%> (ø) ⬆️
addons/a11y/src/components/Report/Info.js 0% <0%> (ø) ⬆️
... and 49 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b41f04a...0df588b. Read the comment docs.

@danielduan
Copy link
Member

Not sure if this is you or on master but it looks like the tests are broken:

WARNING in /tmp/storybook/node_modules/@angular/platform-browser-dynamic/node_modules/@angular/common/esm5/common.js
122:24-38 "export 'InjectionToken' was not found in '@angular/core'
 @ /tmp/storybook/node_modules/@angular/platform-browser-dynamic/node_modules/@angular/common/esm5/common.js
 @ /tmp/storybook/node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js
 @ /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
 @ /tmp/storybook/app/angular/dist/client/preview/render.js
 @ /tmp/storybook/app/angular/dist/client/preview/index.js
 @ /tmp/storybook/app/angular/dist/client/index.js
 @ ./.storybook/config.js
 @ multi /tmp/storybook/app/angular/dist/server/config/polyfills.js /tmp/storybook/app/angular/dist/server/config/globals.js /tmp/storybook/app/angular/node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js

WARNING in /tmp/storybook/node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js
123:57-89 "export 'ɵCodegenComponentFactoryResolver' was not found in '@angular/core'
 @ /tmp/storybook/node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js
 @ /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
 @ /tmp/storybook/app/angular/dist/client/preview/render.js
 @ /tmp/storybook/app/angular/dist/client/preview/index.js
 @ /tmp/storybook/app/angular/dist/client/index.js
 @ ./.storybook/config.js
 @ multi /tmp/storybook/app/angular/dist/server/config/polyfills.js /tmp/storybook/app/angular/dist/server/config/globals.js /tmp/storybook/app/angular/node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js

WARNING in /tmp/storybook/node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js
128:45-49 "export 'ɵcmf' was not found in '@angular/core'
 @ /tmp/storybook/node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js
 @ /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
 @ /tmp/storybook/app/angular/dist/client/preview/render.js
 @ /tmp/storybook/app/angular/dist/client/preview/index.js
 @ /tmp/storybook/app/angular/dist/client/index.js
 @ ./.storybook/config.js
 @ multi /tmp/storybook/app/angular/dist/server/config/polyfills.js /tmp/storybook/app/angular/dist/server/config/globals.js /tmp/storybook/app/angular/node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js

@ndelangen who can review these angular PRs? there's a few of these just sitting around now

@ralzinov
Copy link
Contributor Author

@danielduan I think it is some npm packages conflict in parent branch: https://stackoverflow.com/questions/44656265/export-%C9%B5cmf-was-not-found-in-angular-core

@Hypnosphi
Copy link
Member

FYI: test passes on upstream branch: https://circleci.com/gh/storybooks/storybook/24979

@Hypnosphi
Copy link
Member

Here it fails because of errors not warnings:

ERROR in /tmp/storybook/app/angular/src/client/preview/angular/helpers.ts
(52,5): error TS2322: Type 'Timer' is not assignable to type 'number'.

ERROR in /tmp/storybook/app/angular/src/client/preview/angular/helpers.ts
(151,5): error TS90010: Type 'PlatformRef' is not assignable to type 'PlatformRef'. Two different types with this name exist, but they are unrelated.

ERROR in /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
(52,5): error TS2322: Type 'Timer' is not assignable to type 'number'.

ERROR in /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
(151,5): error TS90010: Type 'PlatformRef' is not assignable to type 'PlatformRef'. Two different types with this name exist, but they are unrelated.
  Property '_injector' is missing in type 'PlatformRef'.

@@ -0,0 +1,28 @@
export interface IStorybookStory {
Copy link
Member

Choose a reason for hiding this comment

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

I think we also have type definitions in the @types/... npm organisation.

Should we move these here? Or add them there also?
Are these even the same type of definitions?

👍

Copy link
Contributor Author

@ralzinov ralzinov Dec 16, 2017

Choose a reason for hiding this comment

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

I didn't find any typings for apps at https://microsoft.github.io/TypeSearch/, only for addons.
I think app and type definitioins for it should be in same package, at least written with typescript like angular. It's not the same typings.

@ndelangen
Copy link
Member

@alterx do you want to approve and merge this?

@alterx
Copy link
Member

alterx commented Dec 20, 2017

@ndelangen lets wait until we approve and merge #2467

@ndelangen
Copy link
Member

Seems like the CLI tests are breaking over this:

ERROR in /tmp/storybook/app/angular/src/client/preview/angular/helpers.ts
(139,5): error TS2345: Argument of type '(PipeTransform | IComponent | typeof AppComponent)[]' is not assignable to parameter of type '(any[] | Type<any>)[]'.
  Type 'PipeTransform | IComponent | typeof AppComponent' is not assignable to type 'any[] | Type<any>'.
    Type 'PipeTransform' is not assignable to type 'any[] | Type<any>'.
      Type 'PipeTransform' is not assignable to type 'Type<any>'.

ERROR in /tmp/storybook/app/angular/src/client/preview/angular/helpers.ts
(179,68): error TS2345: Argument of type '{ component: any; props: { message: string; stack: string; }; propsMeta: {}; }' is not assignable to parameter of type 'Data'.
  Property 'pipes' is missing in type '{ component: any; props: { message: string; stack: string; }; propsMeta: {}; }'.

ERROR in /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
(139,5): error TS2345: Argument of type '(IComponent | PipeTransform | typeof AppComponent)[]' is not assignable to parameter of type '(any[] | Type<any>)[]'.
  Type 'IComponent | PipeTransform | typeof AppComponent' is not assignable to type 'any[] | Type<any>'.
    Type 'PipeTransform' is not assignable to type 'any[] | Type<any>'.
      Type 'PipeTransform' is not assignable to type 'Type<any>'.
        Property 'apply' is missing in type 'PipeTransform'.

ERROR in /tmp/storybook/app/angular/dist/client/preview/angular/helpers.ts
(179,68): error TS2345: Argument of type '{ component: any; props: { message: string; stack: string; }; propsMeta: {}; }' is not assignable to parameter of type 'Data'.
  Property 'pipes' is missing in type '{ component: any; props: { message: string; stack: string; }; propsMeta: {}; }'.
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks  Chunk Names
    index.html  569 kB       0  
       [0] /tmp/storybook/node_modules/html-webpack-plugin/lib/loader.js!/tmp/storybook/app/angular/dist/server/index.html.ejs 1.7 kB {0} [built]
       [1] /tmp/storybook/node_modules/lodash/lodash.js 540 kB {0} [built]
       [2] (webpack)/buildin/global.js 509 bytes {0} [built]
       [3] (webpack)/buildin/module.js 517 bytes {0} [built]
Child html-webpack-plugin for "iframe.html":
          Asset    Size  Chunks  Chunk Names
    iframe.html  568 kB       0  
       [0] /tmp/storybook/node_modules/html-webpack-plugin/lib/loader.js!/tmp/storybook/app/angular/dist/server/iframe.html.ejs 886 bytes {0} [built]
       [1] /tmp/storybook/node_modules/lodash/lodash.js 540 kB {0} [built]
       [2] (webpack)/buildin/global.js 509 bytes {0} [built]
       [3] (webpack)/buildin/module.js 517 bytes {0} [built]
error Command failed with exit code 1.

@ralzinov
Copy link
Contributor Author

@ndelangen @alterx I fixed conflicts, but i think we should enable "noImplicitAny" flag in tsconfig, because without it typescript is useless, and we will get broken typings after each merge.

@ndelangen
Copy link
Member

What do you think @alterx @igor-dv ?

@alterx
Copy link
Member

alterx commented Dec 22, 2017

Yeah, I agree. If we're going to have type definitions we need to enforce its use.
On a non-related note, I think we need to fix IGetStory to include the new moduleMetadata
@ralzinov

@alterx alterx merged commit 2e77342 into storybookjs:release/3.3 Dec 22, 2017
@ralzinov ralzinov deleted the fix-angular-typings branch December 22, 2017 18:59
@ndelangen
Copy link
Member

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants