-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Issues related to packages in monorepo #2218
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
Comments
Could you please provide more information? This statement doesn't tell us anything about the problem. If you've got a lint result, could you also show the code that generated the lint result? The more information you can provide, the easier it is to diagnose and help you debug. Right now I can give you no help at all. Help me to help you. https://github.com/typescript-eslint/typescript-eslint/blob/master/CONTRIBUTING.md#raising-issues
|
@bradzacher I can give you access to the repo if you have time to take a look. the errors as I said stem from what I believe typescript-eslint not having the right information to see the source code of other packages in the monorepo. So for example:
and the source code for that lint error: import React from 'react';
import { circle } from '@lifetime/icons';
interface Props {
fill: string;
name: keyof typeof circle;
size?: number;
}
export function UIIconCircle(props: Props): JSX.Element {
return (
<svg
className="UIIconCircle"
fill={props.fill}
shapeRendering="geometricPrecision"
style={{ fontSize: props.size }}
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path d={circle[props.name]} />
<style jsx>{`
.UIIconCircle {
width: 1em;
height: 1em;
}
`}</style>
</svg>
);
}
UIIconCircle.defaultProps = {
fill: 'currentColor',
}; typescript-eslint is saying |
Sure, if that's easiest. |
@bradzacher I've added you as a collaborator, check out the branch |
@bradzacher any updates? |
Steps taken:
The second build error is the issue which is causing the lint errors. Our tooling doesn't show any typescript errors - this is done on purpose, because we don't want to replicate TS at all for various reasons I won't get into. This means that if, for some reason, your config is wrong and TS can't find imports, it doesn't error your lint run - instead it just treats the type as If you fix the build error, it should fix the lint error as well. [1]
[2]
[3]It's a special type of
|
@bradzacher sorry, I thought I'd updated the build steps, I just pushed a fix. So are you saying I should build my project before running eslint so the typedefs come through? |
@bradzacher the things typescript-eslint is casting to any are things that VSCode sees as the correct types which is why I'm confused. import { regular } from '@lifetime/icons';
// typescript-eslint says regular is any here, but VSCode evaluates to the right type. |
After you've pulled my latest commit, You should see what I'm seeing if you follow the same steps:
|
I don't think you have to do a build based on your config - unsure though. Your repo is setup a little weird, because you use If it's anything like using VSCode doesn't error because of how it is designed. In a nutshell, VSCode does some unique things to automagically make TS work smoothly in the IDE with zero config - i.e. it automatically figures out the tsconfig for any given file by traversing the file tree. IIRC it works something along the lines of this: We don't have the same logic, and we don't (and can't) use the same APIs as VSCode, so we're more limited in this space, unfortunately. |
Note - I pulled the latest |
@bradzacher shoot, you're right I completely forgot to push. I'm not familiar with lerna link. and tbh, I only setup those references because I thought that was how it was supposed to be, I'm kinda fumbling around with this config, so any guidance you can share would be greatly appreciated. ideally, I'd like eslint to run before a build because it'll give me quicker insight in CI if a build has issues. I've updated the repo, give it another go and let me know what you think. |
I just pulled and tried again.
So it looks like your workspace is working exactly as I mentioned before. Our repo here is a good example of setting up a multi-package monorepo.
And that's really it. When you initialise lerna, it will scan the yarn workspace, find all of the This means that node (and typescript) will automatically be able to resolve the path to the files without any special config at all. |
I'm going to close this as resolved - you need to do the build first. |
Repro
It's a private repo I can give one of the maintainers access.
// your repro code case
Expected Result
no errors
Actual Result
20:16 error Unsafe assignment of an any value @typescript-eslint/no-unsafe-assignment
Additional Info
@typescript-eslint/parser
doesn't seem to be seeing my source code for some of my packages in the monorepo.Versions
@typescript-eslint/parser
3.3.0
TypeScript
3.9.5
ESLint
7.2.0
node
12.8.1
npm
6.14.5
The text was updated successfully, but these errors were encountered: