Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 88d063a

Browse files
committed
drop assertTypeChecked
This relied on internal TypeScript API that was removed in 2.4. It was only a debug assertion anyway.
1 parent 9336554 commit 88d063a

File tree

4 files changed

+1
-20
lines changed

4 files changed

+1
-20
lines changed

src/decorator-annotator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as ts from 'typescript';
1212
import {getDecoratorDeclarations} from './decorators';
1313
import {getIdentifierText, Rewriter} from './rewriter';
1414
import {SourceMapper} from './source_map_utils';
15-
import {assertTypeChecked, TypeTranslator} from './type-translator';
15+
import {TypeTranslator} from './type-translator';
1616
import {toArray} from './util';
1717

1818
// DecoratorClassVisitor rewrites a single "class Foo {...}" declaration.
@@ -361,6 +361,5 @@ export function visitClassContentIncludingDecorators(
361361
export function convertDecorators(
362362
typeChecker: ts.TypeChecker, sourceFile: ts.SourceFile,
363363
sourceMapper?: SourceMapper): {output: string, diagnostics: ts.Diagnostic[]} {
364-
assertTypeChecked(sourceFile);
365364
return new DecoratorRewriter(typeChecker, sourceFile, sourceMapper).process();
366365
}

src/tsickle.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,15 +1718,13 @@ export function annotate(
17181718
options: AnnotatorOptions = {}, tsHost?: ts.ModuleResolutionHost, tsOpts?: ts.CompilerOptions,
17191719
sourceMapper?: SourceMapper,
17201720
features = AnnotatorFeatures.Default): {output: string, diagnostics: ts.Diagnostic[]} {
1721-
typeTranslator.assertTypeChecked(file);
17221721
return new Annotator(typeChecker, file, host, options, tsHost, tsOpts, sourceMapper, features)
17231722
.annotate();
17241723
}
17251724

17261725
export function writeExterns(
17271726
typeChecker: ts.TypeChecker, file: ts.SourceFile, host: AnnotatorHost,
17281727
options: AnnotatorOptions = {}): {output: string, diagnostics: ts.Diagnostic[]} {
1729-
typeTranslator.assertTypeChecked(file);
17301728
return new ExternsWriter(typeChecker, file, host, options).process();
17311729
}
17321730

src/type-translator.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import * as path from 'path';
1010
import * as ts from 'typescript';
1111
import {toArray} from './util';
1212

13-
export function assertTypeChecked(sourceFile: ts.SourceFile) {
14-
if (!('resolvedModules' in sourceFile)) {
15-
throw new Error('must provide typechecked program');
16-
}
17-
}
18-
1913
/**
2014
* Determines if fileName refers to a builtin lib.d.ts file.
2115
* This is a terrible hack but it mirrors a similar thing done in Clutz.

test/decorator-annotator_test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ describe(
4949
expect(translate(sourceText).output).to.equal(sourceText);
5050
}
5151

52-
it('rejects non-typechecked inputs', () => {
53-
const sourceText = 'let x = 3;';
54-
const program = testSupport.createProgram(sources(sourceText));
55-
const goodSourceFile = program.getSourceFile(testCaseFileName);
56-
expect(() => convertDecorators(program.getTypeChecker(), goodSourceFile)).to.not.throw();
57-
const badSourceFile =
58-
ts.createSourceFile(testCaseFileName, sourceText, ts.ScriptTarget.ES2015, true);
59-
expect(() => convertDecorators(program.getTypeChecker(), badSourceFile)).to.throw();
60-
});
61-
6252
it('generates a source map', () => {
6353
const {output, sourceMap} = translate(`
6454
/** @Annotation */ let Test1: Function;

0 commit comments

Comments
 (0)