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

Support baseURL compiler option #167

Open
RomkeVdMeulen opened this issue Feb 17, 2017 · 4 comments
Open

Support baseURL compiler option #167

RomkeVdMeulen opened this issue Feb 17, 2017 · 4 comments

Comments

@RomkeVdMeulen
Copy link

RomkeVdMeulen commented Feb 17, 2017

resolution:

original:

Not very common, but sometimes I have something like:
src/components/my-widget.ts:

import {Toggle} from "src/components/toggle";

export class MyWidget extends Toggle {
  myProp = "Lorem Ipsum";
}

src/components/toggle.ts:

export class Toggle {
  toggled = false;

  toggle() {
    this.toggled = !this.toggled;
  }
}

src/components/my-widget.html:

<template>
  <button click.trigger="toggle()">Toggle me</button>
  <p if.bind="toggled">${myProp}</p>
</template>

In which case the linter should not report
WARNING: cannot find 'toggle' in type 'MyWidget' Ln 2 Col 3 my-widget.html
or
WARNING: cannot find 'toggled' in type 'MyWidget' Ln 3 Col 3 my-widget.html.

@MeirionHughes
Copy link
Contributor

MeirionHughes commented Feb 17, 2017

Its possible your import statement is the problem as inheritance should be supported: MeirionHughes@7f941b9

@RomkeVdMeulen
Copy link
Author

That could be it: I'm not importing with a relative path. I have updated my original post to show how I import Toggle.

@MeirionHughes
Copy link
Contributor

Yes, that's it. I think you'll need to use relative paths. Unless I'm mistaken "src/components/toggle" means /components/toggle from within src module. If this is what you're trying doing then support for modules at the moment is done via setting the typings path - not tested with node_modules/@types though.

@RomkeVdMeulen
Copy link
Author

RomkeVdMeulen commented Feb 17, 2017

Using relative paths isn't a good option for my project. src isn't an external module in my case, it refers to code under the src dir in my codebase. I'm using the TypeScript baseURL compiler option to make this work.

In this case the module path I'm importing from matches what I passed to reflectionOpts.sourceFileGlob. Which is:

config.reflectionOpts.sourceFileGlob = "src/**/*.ts";

I can understand that following complex module resolution logic is a bit out of scope for a template linter. But perhaps it might be a useful feature to try to resolve non-relative imports that match the sourceFileGlob?

@MeirionHughes MeirionHughes changed the title Support inheritance Support baseURL compiler option Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants