-
Notifications
You must be signed in to change notification settings - Fork 109
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
Prefactorings for introducing transformers #514
Conversation
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 looks fantastic, thanks a ton for splitting it up! I have only minor comments. I'm not sure if it's worth having someone like Martin also take a look (I think he's on vacation but I don't know when it ends)
src/source_map_utils.ts
Outdated
|
||
export const NOOP_SOURCE_MAPPER: SourceMapper = { | ||
// tslint:disable-next-line:no-empty | ||
addMapping: () => {} |
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.
addMapping() {}
?
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.
Sounds good.
src/tsickle_compiler_host.ts
Outdated
export interface Options extends Es5ProcessorOptions, tsickle.AnnotatorOptions { | ||
// This method is here for backwards compatibility. | ||
// Use the method in TsickleHost instead. | ||
logWarning?: TsickleHost['logWarning']; |
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 think quoted accesses like this can break optimization. Why not TsickleHost.logWarning?
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 is for reusing the type, not the value.
src/decorator-annotator.ts
Outdated
} | ||
} | ||
|
||
maybeProcessDecorator(node: ts.Node, start?: number): boolean { |
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.
Shouldn't this take a ts.Decorator? And then drop the "as ts.Decorator" below?
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.
Sounds good.
src/tsickle_compiler_host.ts
Outdated
@@ -27,7 +27,8 @@ import {isDtsFileName} from './tsickle'; | |||
export enum Pass { | |||
NONE, | |||
DECORATOR_DOWNLEVEL, | |||
CLOSURIZE | |||
CLOSURIZE, | |||
DECORATOR_DOWNLEVEL_AND_CLOSURIZE, |
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 a comment here about how you do both in a single pass, and also that we want to drop the other ones?
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.
Sounds good.
src/tsickle_compiler_host.ts
Outdated
sourceFile, this.runConfiguration.oldProgram, fileName, languageVersion, false); | ||
case Pass.DECORATOR_DOWNLEVEL_AND_CLOSURIZE: | ||
return this.closurize( | ||
sourceFile, this.runConfiguration.oldProgram, fileName, languageVersion, true); |
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 stick in some comment like
..., languageVersion, /* also downlevel */ true)
and also above in the false case?
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.
Sounds good.
This is a prefactoring for using transformers.
c83d1f8
to
7c586b6
Compare
Attention: This breaks G3, probably a mistake in the enum changes. Need to investigate... |
Deleted the commit that changed enums as the following reports the error "Property 'p' of exported interface has or is using private name 'MyEnum'
Note that if the variable / type |
One part for the annotator itself, and one part for the es5processor. This is a prefactoring for using transformers.
This is a prefactoring for using transformers.
This is a prefactoring for using transformers, as e.g. `.d.ts` files don't run through the transformation pipeline, so we need to generate generate externs for them explicitly.
This is a prefactoring for using transformers, as using multiple Node -> String -> Node transformations would loose too much type information.
This is a prefactoring for using transformers. Typescript always uses double quotes for synthetic string literals.
This is a prefactoring for using transformers, as this is the default way in which typescript emits synthetic code.
These test cases were reproductions of cases where the upcoming transformer version of tsickle failed in G3.
No description provided.