JamesHenry / typescript-estree

:sparkles: A parser that converts TypeScript source code into an ESTree-compatible form
https://jameshenry.blog
Other
84 stars 13 forks source link

Handle non-existent files and custom file extensions #53

Closed uniqueiniquity closed 5 years ago

uniqueiniquity commented 5 years ago

This PR addresses two main issues brought up in #50 when using the --project flag.

For the former issue, we allow for a non-existent file to be used by parsing the compiler options out of a single tsconfig and building a program with that single, non-existent file and those compiler options. My intent was that this should be primarily used for test cases, which may provide code to be parsed instead of the contents of an actual file.

For the latter, we allow for a new string array option extraFileExtensions. This is then passed to the TypeScript API so that it will additionally include files with the provided file extensions when resolving the root files of a given program from a tsconfig. Unfortunately, this implementation uses an undocumented extension point in the TS API, so I will be making a change to TypeScript so this behavior is officially supported moving forward.

uniqueiniquity commented 5 years ago

@JamesHenry @armano2

uniqueiniquity commented 5 years ago

Also addresses concerns mentioned in https://github.com/eslint/typescript-eslint-parser/pull/568

armano2 commented 5 years ago

@uniqueiniquity i tested it and seems to work, but can you add test scenario when you do not read file at all, but provide it as code with not existing filename?

uniqueiniquity commented 5 years ago

@armano2 thanks for taking a look. I intended 'non-existent file tests' to test that scenario, since the filename I provided is <input>. Would you like me to add one with a not existing filename that looks more like a real filename?

armano2 commented 5 years ago

.... i'm gettin blind i didn't see this test xd

JamesHenry commented 5 years ago

:tada: This PR is included in version 7.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: