Skip to content

Cannot find module 'ember-simple-auth/mixins/application-route-mixin' #41

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

Closed
theseyi opened this issue Jun 7, 2017 · 3 comments
Closed

Comments

@theseyi
Copy link

theseyi commented Jun 7, 2017

I have a tsconfig.json file similar to the following, but

{
  "compilerOptions": {
    "target": "ES6",
    "allowJs": true,
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noEmit": true,
    "baseUrl": ".",
    "sourceMap": true,
    "paths": {
      "ember-simple-auth/mixins/application-route-mixin": [
        "node_modules/ember-simple-auth/addon/mixins/application-route-mixin"
      ]
    }
  },
  "include": [
    "app/**/*"
  ]
}

and in routes/application.ts:

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

However, when i run ember serve, I get the following error in the build process:


/my-app/routes/application.ts(7,35): Cannot find module 'ember-simple-auth/mixins/application-route-mixin'.
/my-app/routes/application.ts(7,35): Cannot find module 'ember-simple-auth/mixins/application-route-mixin'.

How do I get ember-cli-typescript to correctly pick up this file?

  • I should note that manually running tsc works as expected and
  • I have stopped ember serve and restarted after making the edits
@theseyi
Copy link
Author

theseyi commented Jun 8, 2017

Resolved this with ambient module declaration.
http://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
microsoft/TypeScript#13348 (comment)

@theseyi theseyi closed this as completed Jun 8, 2017
@chriskrycho
Copy link
Member

Thanks, @theseyi! Next time I get ten minutes, I'll try to add this to the README.

Can you share what your actual module declaration looked like and where you put it? That'll help me (a) document it clearly for users today and (b) think about how to recommend people start building/submitting typings for other libraries as we go.

@theseyi
Copy link
Author

theseyi commented Jun 9, 2017

Hey @chriskrycho, sure. In .d.ts file.

// typings/ember-simple-auth/mixins/application-route-mixin.d.ts
declare module '*';

and included a reference path directive in the file where I had the import

import Ember from 'ember';
/// <reference path="../typings/ember-simple-auth/mixins/application-route-mixin.d.ts" /> 
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

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

No branches or pull requests

2 participants