-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
parser.createProgram is not being exported #3514
Comments
It's not getting stripped. It hasn't been released yet. If you want to play with this new api - use our |
@rdsedmundo please comment back once you've tested and let us know how it goes! Worth noting that @JamesHenry is working to make this the default for CLI runs in #3512. |
I wasn't focused on performance improvements (although that will be good in the future!), my use case was writing a custom module resolution (#2771) that enables absolute paths within cross-package imports in a monorepo. Actually, I ended up using I also had to duplicate the logic into a custom tsc CLI for running the type checking with the awareness of the absolute paths + a language service for VSCode. It's unfortunate that TypeScript doesn't support a global hook for this in the |
oh shit - I didn't even think about that. I know the original usecase Ben was thinking of was for a large project to reuse a project for both linting and typechecking. |
One difficulty that I'm facing is that the eslint server grows fast in memory usage because it creates a new program almost every time I edit the file in the IDE (because it reads the I proceeded to cache the program using the I'd need to do something similar as this, but the module.exports = {
parserOptions: {
programs: [
(code, filePathIn) => {
const program = getCachedProgram();
// here I mimic the same logic from the createWatchProgram.ts#L278
},
]
}
} A similar problem arises for a new file being created in the disk which won't be inside the Ultimately, I'll end up having to implement a lot of things that you've already done (and better, with tests and edge cases) in the Do you have any thoughts? Thanks. |
I gave up reinventing the wheel and added support for a |
Repro
mkdir typescript-eslint-bug-no-createprogram
yarn init -y
yarn add eslint @typescript-eslint/parser
node_modules/@typescript-eslint/parser
exports contents.Attached screenshots at the bottom.
Expected Result
Should be exported.
Actual Result
I tried to use inside
eslintrc.js
and it threw saying thatparser.createProgram
is not defined.Additional Info
I tried to import from
@typescript-eslint/typescript-estree
as well and got the same result.Versions
@typescript-eslint/parser
4.26.1
TypeScript
4.3.2
ESLint
7.28.0
node
14.17.0
Notice on this file above how it's missing a third import but still has a trailing comma, for some reason
createProgram
is getting stripped from there.The text was updated successfully, but these errors were encountered: