@@ -40,16 +40,6 @@ console.log(`Bundling ${entrypoint} to ${output} and ${internalOutput}`);
4040const newLineKind = ts . NewLineKind . LineFeed ;
4141const newLine = newLineKind === ts . NewLineKind . LineFeed ? "\n" : "\r\n" ;
4242
43- /** @type {(node: ts.Node) => node is ts.DeclarationStatement } */
44- function isDeclarationStatement ( node ) {
45- return /** @type {any } */ ( ts ) . isDeclarationStatement ( node ) ;
46- }
47-
48- /** @type {(node: ts.Node) => boolean } */
49- function isInternalDeclaration ( node ) {
50- return /** @type {any } */ ( ts ) . isInternalDeclaration ( node , node . getSourceFile ( ) ) ;
51- }
52-
5343/**
5444 * @param {ts.VariableDeclaration } node
5545 * @returns {ts.VariableStatement }
@@ -71,15 +61,12 @@ function getDeclarationStatement(node) {
7161 if ( ts . isVariableDeclaration ( node ) ) {
7262 return getParentVariableStatement ( node ) ;
7363 }
74- else if ( isDeclarationStatement ( node ) ) {
64+ else if ( ts . isDeclarationStatement ( node ) ) {
7565 return node ;
7666 }
7767 return undefined ;
7868}
7969
80- /** @type {ts.TransformationContext } */
81- const nullTransformationContext = /** @type {any } */ ( ts ) . nullTransformationContext ;
82-
8370const program = ts . createProgram ( [ entrypoint ] , { target : ts . ScriptTarget . ES5 } ) ;
8471
8572const typeChecker = program . getTypeChecker ( ) ;
@@ -207,7 +194,7 @@ function containsPublicAPI(symbol) {
207194
208195 for ( const decl of symbol . declarations ) {
209196 const statement = getDeclarationStatement ( decl ) ;
210- if ( statement && ! isInternalDeclaration ( statement ) ) {
197+ if ( statement && ! ts . isInternalDeclaration ( statement ) ) {
211198 return true ;
212199 }
213200 }
@@ -262,27 +249,20 @@ function isNonLocalAlias(symbol, excludes = ts.SymbolFlags.Value | ts.SymbolFlag
262249 return ( symbol . flags & ( ts . SymbolFlags . Alias | excludes ) ) === ts . SymbolFlags . Alias || ! ! ( symbol . flags & ts . SymbolFlags . Alias && symbol . flags & ts . SymbolFlags . Assignment ) ;
263250}
264251
265- /**
266- * @param {ts.Symbol } symbol
267- */
268- function resolveAlias ( symbol ) {
269- return typeChecker . getAliasedSymbol ( symbol ) ;
270- }
271-
272252/**
273253 * @param {ts.Symbol } symbol
274254 * @param {boolean | undefined } [dontResolveAlias]
275255 */
276256function resolveSymbol ( symbol , dontResolveAlias = undefined ) {
277- return ! dontResolveAlias && isNonLocalAlias ( symbol ) ? resolveAlias ( symbol ) : symbol ;
257+ return ! dontResolveAlias && isNonLocalAlias ( symbol ) ? typeChecker . getAliasedSymbol ( symbol ) : symbol ;
278258}
279259
280260/**
281261 * @param {ts.Symbol } symbol
282262 * @returns {ts.Symbol }
283263 */
284264function getMergedSymbol ( symbol ) {
285- return /** @type { any } */ ( typeChecker ) . getMergedSymbol ( symbol ) ;
265+ return typeChecker . getMergedSymbol ( symbol ) ;
286266}
287267
288268/**
@@ -308,20 +288,12 @@ function symbolsConflict(s1, s2) {
308288 return true ;
309289}
310290
311- /**
312- * @param {ts.Node } node
313- * @returns {boolean }
314- */
315- function isPartOfTypeNode ( node ) {
316- return /** @type {any } */ ( ts ) . isPartOfTypeNode ( node ) ;
317- }
318-
319291/**
320292 * @param {ts.Statement } decl
321293 */
322294function verifyMatchingSymbols ( decl ) {
323295 ts . visitEachChild ( decl , /** @type {(node: ts.Node) => ts.Node } */ function visit ( node ) {
324- if ( ts . isIdentifier ( node ) && isPartOfTypeNode ( node ) ) {
296+ if ( ts . isIdentifier ( node ) && ts . isPartOfTypeNode ( node ) ) {
325297 if ( ts . isQualifiedName ( node . parent ) && node !== node . parent . left ) {
326298 return node ;
327299 }
@@ -347,8 +319,8 @@ function verifyMatchingSymbols(decl) {
347319 }
348320 }
349321
350- return ts . visitEachChild ( node , visit , nullTransformationContext ) ;
351- } , nullTransformationContext ) ;
322+ return ts . visitEachChild ( node , visit , /*context*/ undefined ) ;
323+ } , /*context*/ undefined ) ;
352324}
353325
354326/**
@@ -397,20 +369,20 @@ function emitAsNamespace(name, moduleSymbol) {
397369
398370 verifyMatchingSymbols ( statement ) ;
399371
400- const isInternal = isInternalDeclaration ( statement ) ;
372+ const isInternal = ts . isInternalDeclaration ( statement ) ;
401373 if ( ! isInternal ) {
402374 const publicStatement = ts . visitEachChild ( statement , node => {
403375 // No @internal comments in the public API.
404- if ( isInternalDeclaration ( node ) ) {
376+ if ( ts . isInternalDeclaration ( node ) ) {
405377 return undefined ;
406378 }
407379 return removeDeclareConstExport ( node ) ;
408- } , nullTransformationContext ) ;
380+ } , /*context*/ undefined ) ;
409381
410382 writeNode ( publicStatement , sourceFile , WriteTarget . Public ) ;
411383 }
412384
413- const internalStatement = ts . visitEachChild ( statement , removeDeclareConstExport , nullTransformationContext ) ;
385+ const internalStatement = ts . visitEachChild ( statement , removeDeclareConstExport , /*context*/ undefined ) ;
414386
415387 writeNode ( internalStatement , sourceFile , WriteTarget . Internal ) ;
416388 }
0 commit comments