Skip to content

Commit bbed364

Browse files
committed
chore(tsc-wrapped): update to newest tsickle
1 parent 3aca5ff commit bbed364

8 files changed

Lines changed: 25 additions & 26 deletions

File tree

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ tmp
2121
*.js.deps
2222
*.js.map
2323

24-
# Files created by the template compiler
25-
**/*.ngfactory.ts
26-
**/*.css.ts
27-
**/*.css.shim.ts
28-
2924
# Include when developing application packages.
3025
pubspec.lock
3126
.c9

npm-shrinkwrap.clean.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5203,7 +5203,7 @@
52035203
}
52045204
},
52055205
"tsickle": {
5206-
"version": "0.1.2",
5206+
"version": "0.1.4",
52075207
"dependencies": {
52085208
"source-map": {
52095209
"version": "0.4.4"

npm-shrinkwrap.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"through2": "^0.6.5",
108108
"ts-api-guardian": "0.0.3",
109109
"ts2dart": "^0.9.10",
110-
"tsickle": "0.1.2",
110+
"tsickle": "^0.1.4",
111111
"tslint": "^3.10.0-dev.2",
112112
"typescript": "^1.9.0-dev.20160409",
113113
"universal-analytics": "^0.3.9",

tools/@angular/tsc-wrapped/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "MIT",
1212
"repository": {"type":"git","url":"https://github.com/angular/angular.git"},
1313
"dependencies": {
14-
"tsickle": "0.1.2"
14+
"tsickle": "0.1.4"
1515
},
1616
"peerDependencies": {
1717
"typescript": "^1.9.0-dev"

tools/@angular/tsc-wrapped/src/compiler_host.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,24 @@ interface DecoratorInvocation {
3939
args?: any[];
4040
}
4141
`;
42-
constructor(delegate: ts.CompilerHost) { super(delegate); }
42+
constructor(delegate: ts.CompilerHost, private program: ts.Program) { super(delegate); }
4343

4444
getSourceFile =
4545
(fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => {
4646
const originalContent = this.delegate.readFile(fileName);
4747
let newContent = originalContent;
4848
if (!/\.d\.ts$/.test(fileName)) {
49-
const converted = convertDecorators(fileName, originalContent);
50-
if (converted.diagnostics) {
51-
this.diagnostics.push(...converted.diagnostics);
49+
try {
50+
const converted = convertDecorators(
51+
this.program.getTypeChecker(), this.program.getSourceFile(fileName));
52+
if (converted.diagnostics) {
53+
this.diagnostics.push(...converted.diagnostics);
54+
}
55+
newContent = converted.output + this.TSICKLE_SUPPORT;
56+
} catch (e) {
57+
console.error('Cannot convertDecorators on file', fileName);
58+
throw e;
5259
}
53-
newContent = converted.output + this.TSICKLE_SUPPORT;
5460
}
5561
return ts.createSourceFile(fileName, newContent, languageVersion, true);
5662
};

tools/@angular/tsc-wrapped/src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import NgOptions from './options';
88
import {MetadataWriterHost, TsickleHost} from './compiler_host';
99

1010
export type CodegenExtension = (ngOptions: NgOptions, program: ts.Program, host: ts.CompilerHost) =>
11-
Promise<any>;
11+
Promise<void>;
1212

1313
export function main(project: string, basePath?: string, codegen?: CodegenExtension): Promise<any> {
1414
try {
@@ -32,20 +32,22 @@ export function main(project: string, basePath?: string, codegen?: CodegenExtens
3232
codegen = () => Promise.resolve(null);
3333
}
3434
return codegen(ngOptions, program, host).then(() => {
35-
tsc.typeCheck(host, program);
35+
// Create a new program since codegen files were created after making the old program
36+
const newProgram = ts.createProgram(parsed.fileNames, parsed.options, host, program);
37+
tsc.typeCheck(host, newProgram);
3638

3739
// Emit *.js with Decorators lowered to Annotations, and also *.js.map
38-
const tsicklePreProcessor = new TsickleHost(host);
39-
tsc.emit(tsicklePreProcessor, program);
40+
const tsicklePreProcessor = new TsickleHost(host, newProgram);
41+
tsc.emit(tsicklePreProcessor, newProgram);
4042

4143
if (!ngOptions.skipMetadataEmit) {
4244
// Emit *.metadata.json and *.d.ts
4345
// Not in the same emit pass with above, because tsickle erases
4446
// decorators which we want to read or document.
4547
// Do this emit second since TypeScript will create missing directories for us
4648
// in the standard emit.
47-
const metadataWriter = new MetadataWriterHost(host, program);
48-
tsc.emit(metadataWriter, program);
49+
const metadataWriter = new MetadataWriterHost(host, newProgram);
50+
tsc.emit(metadataWriter, newProgram);
4951
}
5052
});
5153
} catch (e) {

tools/@angular/tsc-wrapped/src/tsc.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ export class Tsc implements CompilerInterface {
7979
return {parsed: this.parsed, ngOptions: this.ngOptions};
8080
}
8181

82-
typeCheck(compilerHost: ts.CompilerHost, oldProgram: ts.Program): void {
83-
// Create a new program since codegen files were created after making the old program
84-
const program =
85-
ts.createProgram(this.parsed.fileNames, this.parsed.options, compilerHost, oldProgram);
82+
typeCheck(compilerHost: ts.CompilerHost, program: ts.Program): void {
8683
debug('Checking global diagnostics...');
8784
check(program.getGlobalDiagnostics());
8885

0 commit comments

Comments
 (0)