{"action":"created","issue":{"url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/68","repository_url":"https://api.github.com/repos/typed-ember/ember-cli-typescript","labels_url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/68/comments","events_url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/68/events","html_url":"https://github.com/typed-ember/ember-cli-typescript/issues/68","id":256908001,"number":68,"title":"Converting ember-api-docs to typescript","user":{"login":"dwickern","id":752885,"avatar_url":"https://avatars2.githubusercontent.com/u/752885?v=4","gravatar_id":"","url":"https://api.github.com/users/dwickern","html_url":"https://github.com/dwickern","followers_url":"https://api.github.com/users/dwickern/followers","following_url":"https://api.github.com/users/dwickern/following{/other_user}","gists_url":"https://api.github.com/users/dwickern/gists{/gist_id}","starred_url":"https://api.github.com/users/dwickern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwickern/subscriptions","organizations_url":"https://api.github.com/users/dwickern/orgs","repos_url":"https://api.github.com/users/dwickern/repos","events_url":"https://api.github.com/users/dwickern/events{/privacy}","received_events_url":"https://api.github.com/users/dwickern/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-12T03:37:46Z","updated_at":"2017-09-13T03:31:51Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I wanted to check the progress of all the work we've been doing, so I decided to convert an open source ember app to typescript and document the results.\r\n\r\nFirst I tried converting the travis-ci app, but they're doing non-compliant decorator things. I settled on ember-api-docs: a small but non-trivial app that shows up on a google search for \"ember app list\".\r\n\r\nAll I've done is install e-c-ts and rename `.js` to `.ts`. I'm building against my local custom build of ember-typings which has some outstanding PRs merged.\r\n\r\nIt went surprisingly well! I went through the error log and categorized the errors. We already know about many of these problems and there are some new ones. I'll open new issues for some of them.\r\n\r\n---\r\n\r\n1.\r\n\r\n> app/initializers/scroll-parent-shim.ts(1,8): error TS1192: Module ''jquery'' has no default export.\r\n> app/mixins/scroll-tracker.ts(3,8): error TS1192: Module ''jquery'' has no default export.\r\n\r\n```ts\r\nimport $ from 'jquery';\r\n```\r\n\r\nIs this a shim for `window.jQuery`? Who exports it?\r\n\r\n---\r\n\r\n2.\r\n\r\n> app/initializers/scroll-parent-shim.ts(5,14): error TS2304: Cannot find name 'FastBoot'.\r\napp/mixins/scroll-tracker.ts(17,19): error TS2304: Cannot find name 'FastBoot'.\r\n\r\n```ts\r\nif (typeof FastBoot !== 'undefined') {\r\n  return\r\n}\r\n```\r\n\r\nMissing typings for fastboot\r\n\r\n---\r\n  \r\n3.\r\n\r\n> app/mixins/scroll-tracker.ts(21,20): error TS2339: Property 'APP' does not exist on type 'typeof config'.\r\n> ember-api-docs/adapters/application.ts(11,13): error TS2339: Property 'API_HOST' does not exist on type 'typeof config'.\r\n> ember-api-docs/router.ts(11,19): error TS2339: Property 'routerRootURL' does not exist on type 'typeof config'.\r\n\r\n```ts\r\nimport config from 'ember-api-docs/config/environment';\r\n\r\n$(config.APP.scrollContainerSelector).scrollTop(offset - 10);\r\n```\r\n\r\nIt's not possible to define the environment config in typescript. Work around by adding to `app/config/environment.d.ts`\r\n\r\n\r\n---\r\n\r\n4.\r\n\r\n> app/utils/get-last-version.ts(1,27): error TS2307: Cannot find module 'npm:semver-compare'.\r\n> ember-api-docs/components/api-index-filter.ts(3,18): error TS2307: Cannot find module 'npm:lodash.uniq'.\r\n> ember-api-docs/components/api-index-filter.ts(4,20): error TS2307: Cannot find module 'npm:lodash.sortby'.\r\n\r\n```ts\r\nimport semverCompare from 'npm:semver-compare';\r\n```\r\n\r\nMissing typings for `ember-browserify`\r\n\r\n---\r\n\r\n5.\r\n\r\n> app/utils/request-idle-callback.ts(1,8): error TS1192: Module '\"/users/dwickern/code/ember-api-docs/node_modules/@types/rsvp/index\"' has no default export.\r\n> ember-api-docs/components/search-input.ts(2,10): error TS2305: Module '\"/users/dwickern/code/ember-typings/node_modules/@types/rsvp/index\"' has no exported member 'denodeify'.\r\n> ember-api-docs/routes/class.ts(1,10): error TS2305: Module '\"/users/dwickern/code/ember-typings/node_modules/@types/rsvp/index\"' has no exported member 'hash'.\r\n> ember-api-docs/routes/class.ts(1,16): error TS2305: Module '\"/users/dwickern/code/ember-typings/node_modules/@types/rsvp/index\"' has no exported member 'resolve'.\r\n\r\n```ts\r\nimport RSVP from 'rsvp';\r\nimport { hash, resolve } from 'rsvp';\r\n```\r\n\r\nThe RSVP typings only declare typings for `require('rsvp')`. Is this \"rsvp\" module actually a shim added by ember?\r\n\r\n---\r\n\r\n6.\r\n\r\n> app/utils/request-idle-callback.ts(8,12): error TS2555: Expected at least 3 arguments, but got 2.\r\n\r\n```ts\r\nimport { run } from '@ember/runloop';\r\nreturn run.scheduleOnce('afterRender', cb);\r\n```\r\n\r\nIncomplete typings for `scheduleOnce`\r\n\r\n---\r\n\r\n7.\r\n\r\n> ember-api-docs/tests/acceptance/analytics-page-tracking-test.ts(13,33): error TS2339: Property 'application' does not exist on type 'TestContext'.\r\n\r\n```ts\r\ntest('checking that trackPage gets called on transitions', async function(assert) {\r\n  const analyticsService = this.application.__container__.lookup('service:analytics');\r\n})\r\n```\r\n\r\nThe `application` property is added by a custom test helper `module-for-acceptance`. You can fix this error with a merged declaration.\r\n\r\n```ts\r\n// tests/helpers/module-for-acceptance.ts\r\nimport Application from '@ember/application';\r\n\r\ndeclare module \"qunit\" {\r\n  interface TestContext {\r\n    application: Ember.Application;\r\n  }\r\n}\r\n```\r\n(you'll now have an error on `__container__` though because there aren't typings for it, but that's a separate problem)\r\n\r\nI think this `module-for-acceptance` is a blueprint added to all projects by default? Maybe we should have an updated blueprint to fix this common issue.\r\n\r\n---\r\n\r\n8.\r\n\r\n> ember-api-docs/tests/acceptance/analytics-page-tracking-test.ts(29,29): error TS2345: Argument of type '2000' is not assignable to parameter of type '{ timeout: any; }'.\r\n\r\n```ts\r\nexport function requestIdlePromise({timeout}) {\r\n  ...\r\n}\r\nreturn requestIdlePromise(2000);\r\n```\r\n\r\nTypescript caught a bug! :tada:\r\n\r\n---\r\n\r\n9.\r\n\r\n> ember-api-docs/tests/acceptance/app-layout-test.ts(10,9): error TS2304: Cannot find name 'selectSearch'.\r\n> ember-api-docs/tests/acceptance/switch-versions-test.ts(14,9): error TS2304: Cannot find name 'selectChoose'.\r\n\r\n```ts\r\nawait selectSearch('.select-container', '2');\r\n```\r\n\r\nMissing typings for `ember-power-select`\r\n\r\n---\r\n\r\n10.\r\n\r\n> ember-api-docs/tests/helpers/resolver.ts(1,22): error TS2307: Cannot find module '../../resolver'.\r\n> ember-api-docs/tests/helpers/start-app.ts(3,25): error TS2307: Cannot find module '../../app'.\r\n> ember-api-docs/tests/helpers/start-app.ts(4,20): error TS2307: Cannot find module '../../config/environment'.\r\n\r\n```ts\r\nimport Resolver from '../../resolver';\r\nimport config from '../../config/environment';\r\nimport Application from '../../app';\r\n```\r\n\r\nAt least I'm not the only one confused by this.\r\n\r\n---\r\n\r\n11.\r\n\r\n> ember-api-docs/tests/test-helper.ts(3,27): error TS2307: Cannot find module 'ember-exam/test-support/load'.\r\n\r\n```ts\r\nimport loadEmberExam from 'ember-exam/test-support/load';\r\nloadEmberExam();\r\n```\r\n\r\nMissing typings for `ember-exam`\r\n\r\n---\r\n\r\n12.\r\n\r\n> ember-api-docs/tests/unit/initializers/scroll-parent-shim-test.ts(21,3): error TS2554: Expected 0 arguments, but got 1.\r\n\r\n```ts\r\nimport { initialize } from 'ember-api-docs/initializers/scroll-parent-shim';\r\ninitialize(this.application);\r\n\r\nexport function initialize() {\r\n}\r\n```\r\n\r\nGood.\r\n\r\n---\r\n\r\n13.\r\n\r\n> ember-api-docs/adapters/application.ts(3,19): error TS2307: Cannot find module 'fetch'.\r\n\r\n```ts\r\nimport fetch from 'fetch';\r\n```\r\n\r\nember-cli/ember-fetch#72\r\n\r\n---\r\n\r\n14.\r\n\r\n> ember-api-docs/components/ember-anchor.ts(3,29): error TS2307: Cannot find module 'ember-anchor/components/ember-anchor'.\r\n> ember-api-docs/controllers/events.ts(3,37): error TS2307: Cannot find module 'ember-anchor/mixins/controller-support'.\r\n\r\n```ts\r\nimport AnchorComponent from 'ember-anchor/components/ember-anchor';\r\n```\r\n\r\nMissing typings for `ember-anchor`\r\n\r\n---\r\n\r\n15.\r\n\r\n> ember-api-docs/components/search-input.ts(7,17): error TS2307: Cannot find module 'ember-metal/get'.\r\n> ember-api-docs/components/search-input.ts(8,17): error TS2307: Cannot find module 'ember-metal/set'.\r\n\r\n```ts\r\nimport get from 'ember-metal/get';\r\nimport set from 'ember-metal/set';\r\n```\r\n\r\nMissing typings for `ember-metal`. Is this public API?\r\n\r\n---\r\n\r\n16.\r\n\r\n> ember-api-docs/components/search-input/dropdown.ts(28,20): error TS2345: Argument of type '\"results.length\"' is not assignable to parameter of type 'never'.\r\n> ember-api-docs/components/ember-anchor.ts(11,36): error TS2345: Argument of type '\"attrs.a\"' is not assignable to parameter of type 'never'.\r\n> ember-api-docs/components/search-input/dropdown.ts(28,20): error TS2345: Argument of type '\"results.length\"' is not assignable to parameter of type 'never'.\r\n> ember-api-docs/components/search-input/dropdown.ts(55,41): error TS2345: Argument of type '\"hierarchy.lvl1\"' is not assignable to parameter of type 'never'.\r\n\r\n```ts\r\nif (!get(this, 'results.length')) {\r\n  return {};\r\n}\r\nlet filterValue = get(this, `filterData.show${capitalize(filter)}`) ? filter : null;\r\nlet lvl0 = capitalize(get(current, 'hierarchy.lvl0'));\r\n```\r\n\r\nEmber typings don't support paths\r\n\r\n---\r\n\r\n17.\r\n\r\n> ember-api-docs/controllers/project-version.ts(53,37): error TS2339: Property 'sort' does not exist on type 'NativeArray<{}>'.\r\n> ember-api-docs/mixins/filter-params.ts(22,19): error TS2339: Property 'push' does not exist on type 'NativeArray<{}>'.\r\n> ember-api-docs/mixins/filter-params.ts(35,33): error TS2339: Property 'includes' does not exist on type 'NativeArray<{}>'.\r\n\r\n```ts\r\nlet filters = A(value.split(','));\r\nlet enabled = filters.includes(filter);\r\n```\r\n\r\nThis seems to be a bug in ember typings.\r\n\r\n---\r\n\r\n18.\r\n\r\n> ember-api-docs/models/missing.ts(1,19): error TS2307: Cannot find module 'ember-data/model'.\r\n\r\n```ts\r\nimport Model from 'ember-data/model';\r\n```\r\n\r\nMissing typings for ember-data shims\r\n\r\n---\r\n\r\n19.\r\n\r\n> ember-api-docs/router.ts(22,11): error TS2339: Property 'map' does not exist on type 'Readonly<typeof Router> & (new () => { analytics: ComputedProperty<Service>; location: string; ro...'.\r\n\r\n```ts\r\nconst AppRouter = Router.extend({\r\n  ...\r\n});\r\n\r\nAppRouter.map(function() {\r\n  this.route('404');\r\n  ...\r\n});\r\n```\r\n\r\nIncomplete typings for `Ember.Router`\r\n\r\n---\r\n\r\n20.\r\n\r\n> ember-api-docs/services/analytics.ts(21,5): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.\r\n\r\n```ts\r\nawait requestIdlePromise({timeout: 1000});\r\n\r\nexport function requestIdlePromise({timeout}) {\r\n  return new RSVP.Promise(resolve => {\r\n    requestIdleCb(resolve, {timeout});\r\n  });\r\n}\r\n```\r\n\r\nIncomplete typings for `RSVP`"},"comment":{"url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/comments/329048966","html_url":"https://github.com/typed-ember/ember-cli-typescript/issues/68#issuecomment-329048966","issue_url":"https://api.github.com/repos/typed-ember/ember-cli-typescript/issues/68","id":329048966,"user":{"login":"dwickern","id":752885,"avatar_url":"https://avatars2.githubusercontent.com/u/752885?v=4","gravatar_id":"","url":"https://api.github.com/users/dwickern","html_url":"https://github.com/dwickern","followers_url":"https://api.github.com/users/dwickern/followers","following_url":"https://api.github.com/users/dwickern/following{/other_user}","gists_url":"https://api.github.com/users/dwickern/gists{/gist_id}","starred_url":"https://api.github.com/users/dwickern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwickern/subscriptions","organizations_url":"https://api.github.com/users/dwickern/orgs","repos_url":"https://api.github.com/users/dwickern/repos","events_url":"https://api.github.com/users/dwickern/events{/privacy}","received_events_url":"https://api.github.com/users/dwickern/received_events","type":"User","site_admin":false},"created_at":"2017-09-13T03:31:51Z","updated_at":"2017-09-13T03:31:51Z","author_association":"CONTRIBUTOR","body":"1. jQuery uses `export =` instead of `export default` in their typings. I think this can be fixed using the `allowSyntheticDefaultImports` compiler option"}}
{"actor":{"display_login":"dwickern"}}