Skip to content
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

Merged
merged 8 commits into from
Jun 14, 2017
Merged

Conversation

tbosch
Copy link
Contributor

@tbosch tbosch commented Jun 13, 2017

No description provided.

Copy link
Contributor

@evmar evmar left a 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)


export const NOOP_SOURCE_MAPPER: SourceMapper = {
// tslint:disable-next-line:no-empty
addMapping: () => {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addMapping() {}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

export interface Options extends Es5ProcessorOptions, tsickle.AnnotatorOptions {
// This method is here for backwards compatibility.
// Use the method in TsickleHost instead.
logWarning?: TsickleHost['logWarning'];
Copy link
Contributor

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?

Copy link
Contributor Author

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.

}
}

maybeProcessDecorator(node: ts.Node, start?: number): boolean {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@@ -27,7 +27,8 @@ import {isDtsFileName} from './tsickle';
export enum Pass {
NONE,
DECORATOR_DOWNLEVEL,
CLOSURIZE
CLOSURIZE,
DECORATOR_DOWNLEVEL_AND_CLOSURIZE,
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

sourceFile, this.runConfiguration.oldProgram, fileName, languageVersion, false);
case Pass.DECORATOR_DOWNLEVEL_AND_CLOSURIZE:
return this.closurize(
sourceFile, this.runConfiguration.oldProgram, fileName, languageVersion, true);
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@tbosch tbosch force-pushed the prefactor branch 2 times, most recently from c83d1f8 to 7c586b6 Compare June 14, 2017 00:07
@tbosch
Copy link
Contributor Author

tbosch commented Jun 14, 2017

Attention: This breaks G3, probably a mistake in the enum changes. Need to investigate...

@tbosch
Copy link
Contributor Author

tbosch commented Jun 14, 2017

Deleted the commit that changed enums as the following reports the error "Property 'p' of exported interface has or is using private name 'MyEnum'

export interface I {
  p: MyEnum;
}


const MyEnum = {};
type MyEnum = number;
export {MyEnum}

Note that if the variable / type MyEnum is declared before the interface this works!

tbosch added 3 commits June 14, 2017 09:00
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.
tbosch added 4 commits June 14, 2017 09:25
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.
@tbosch tbosch merged commit 5ac90e8 into angular:master Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants