-
Notifications
You must be signed in to change notification settings - Fork 25.9k
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
feat(tsc-wrapped): Support of vinyl like config file was added #13987
Conversation
@@ -23,11 +23,16 @@ export type CodegenExtension = | |||
Promise<void>; | |||
|
|||
export function main( | |||
project: string, cliOptions: CliOptions, codegen?: CodegenExtension, | |||
project: any, cliOptions: CliOptions, codegen?: CodegenExtension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of any, can it be string|{path:string}
, or can you introduce an interface that structurally matches like VinylFile
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
@@ -97,7 +97,7 @@ export class Tsc implements CompilerInterface { | |||
|
|||
constructor(private readFile = ts.sys.readFile, private readDirectory = ts.sys.readDirectory) {} | |||
|
|||
readConfiguration(project: string, basePath: string, existingOptions?: ts.CompilerOptions) { | |||
readConfiguration(project: any, basePath: string, existingOptions?: ts.CompilerOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, can you avoid any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, agree
.then(() => { | ||
const out = readOut('js'); | ||
// No helpers since decorators were lowered | ||
expect(out).not.toContain('__decorate'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should repeat all the assertions here - you just need to assert enough to be sure the vinyl file path and contents were used. Just check that some of your config was used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -7,12 +7,11 @@ | |||
*/ | |||
|
|||
import * as ts from 'typescript'; | |||
import {Tsc} from '../src/tsc'; | |||
import {Tsc, tsc} from '../src/tsc'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this import is now shadowed by the variable on line 25, can you avoid that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks looking close
if (fs.lstatSync(project).isFile()) { | ||
projectDir = path.dirname(project); | ||
// project is vinyl like file object | ||
if ((project as VinylFile).path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add isVinylFile to ./vinyl that returns project is VinylFile
See User-Defined Type Guards on https://www.typescriptlang.org/docs/handbook/advanced-types.html
Then just call isVinylFile instead of casting here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, type guard - nice. Sure will add.
this.basePath = basePath; | ||
|
||
// Allow a directory containing tsconfig.json as the project value | ||
// Note, TS@next returns an empty array, while earlier versions throw | ||
try { | ||
if (this.readDirectory(project).length > 0) { | ||
project = path.join(project, 'tsconfig.json'); | ||
if (this.readDirectory(project as string).length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use !isVinylFile
to narrow the type instead of casting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
projectDir = path.dirname(project.path); | ||
} | ||
// project is path to project file | ||
else if (fs.lstatSync(project as string).isFile()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't need a cast here anymore - the project type will have the VinylFile narrowed out since isVinylFile is known to be false in this else clause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, very tricky, but now I know it :)
this.basePath = basePath; | ||
|
||
// Allow a directory containing tsconfig.json as the project value | ||
// Note, TS@next returns an empty array, while earlier versions throw | ||
try { | ||
if (this.readDirectory(project).length > 0) { | ||
project = path.join(project, 'tsconfig.json'); | ||
if (!isVinylFile(project) && this.readDirectory(project as string).length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
// project is path to project file | ||
else { | ||
return ts.readConfigFile(project as string, this.readFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I'm getting conflicts when rebasing this on |
This feature was implemented in order to provide easier way of use in gulp
Test case config was fixed.
Code was corrected according to the remarks
Code formatting was corrected
Type guard was introduced for VinylFile
5d47856
to
0f1a713
Compare
@alxhub, Rebasing and resolving conflicts are done. |
…ar#13987) This feature was implemented in order to provide easier way of use in gulp
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This feature was implemented in order to provide easier way of use in gulp
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
What is the new behavior?
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: