Skip to content

Commit

Permalink
Use moduleNamespace instead of rootNamespace for externs type
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 565372825
  • Loading branch information
tsjs-language-eng authored and copybara-github committed Sep 14, 2023
1 parent b1bf86b commit 06f8d91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/externs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const EXTERNS_HEADER = `/**
* to this root.
*/
export function getGeneratedExterns(
externs: {[fileName: string]: {output: string, rootNamespace: string}},
externs: {[fileName: string]: {output: string, moduleNamespace: string}},
rootDir: string): string {
let allExterns = EXTERNS_HEADER;
for (const fileName of Object.keys(externs)) {
Expand Down Expand Up @@ -159,7 +159,7 @@ function isInGlobalAugmentation(declaration: ts.Declaration): boolean {
export function generateExterns(
typeChecker: ts.TypeChecker, sourceFile: ts.SourceFile,
host: AnnotatorHost&GoogModuleProcessorHost):
{output: string, diagnostics: ts.Diagnostic[], rootNamespace: string} {
{output: string, diagnostics: ts.Diagnostic[], moduleNamespace: string} {
let output = '';
const diagnostics: ts.Diagnostic[] = [];
const isDts = isDtsFileName(sourceFile.fileName);
Expand Down Expand Up @@ -282,7 +282,7 @@ export function generateExterns(
}
}

return {output, diagnostics, rootNamespace};
return {output, diagnostics, moduleNamespace};

function emit(str: string) {
output += str;
Expand Down
10 changes: 5 additions & 5 deletions src/tsickle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function mergeEmitResults(emitResults: EmitResult[]): EmitResult {
let emitSkipped = true;
const emittedFiles: string[] = [];
const externs:
{[fileName: string]: {output: string, rootNamespace: string}} = {};
{[fileName: string]: {output: string, moduleNamespace: string}} = {};
const modulesManifest = new ModulesManifest();
const tsMigrationExportsShimFiles = new Map<string, string>();
for (const er of emitResults) {
Expand Down Expand Up @@ -120,7 +120,7 @@ export interface EmitResult extends ts.EmitResult {
* externs.js files produced by tsickle, if any. module IDs are relative paths
* from fileNameToModuleId.
*/
externs: {[moduleId: string]: {output: string, rootNamespace: string}};
externs: {[moduleId: string]: {output: string, moduleNamespace: string}};

/**
* Content for the generated files, keyed by their intended filename.
Expand Down Expand Up @@ -247,7 +247,7 @@ export function emit(
tsTransformers);

const externs:
{[fileName: string]: {output: string, rootNamespace: string}} = {};
{[fileName: string]: {output: string, moduleNamespace: string}} = {};
if (host.transformTypesToClosure) {
const sourceFiles =
targetSourceFile ? [targetSourceFile] : program.getSourceFiles();
Expand All @@ -256,10 +256,10 @@ export function emit(
if (isDts && host.shouldSkipTsickleProcessing(sourceFile.fileName)) {
continue;
}
const {output, diagnostics, rootNamespace} =
const {output, diagnostics, moduleNamespace} =
generateExterns(typeChecker, sourceFile, host);
if (output) {
externs[sourceFile.fileName] = {output, rootNamespace};
externs[sourceFile.fileName] = {output, moduleNamespace};
}
if (diagnostics) {
tsickleDiagnostics.push(...diagnostics);
Expand Down
2 changes: 1 addition & 1 deletion test/golden_tsickle_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ testFn('golden tests', () => {
if (!test.name.endsWith('.no_externs')) {
// Concatenate externs for the files that are in this tests sources (but
// not other, shared .d.ts files).
const filteredExterns: {[k: string]: { output: string; rootNamespace: string; }} = {};
const filteredExterns: {[k: string]: { output: string; moduleNamespace: string; }} = {};
let anyExternsGenerated = false;
for (const fileName of tsSources.keys()) {
if (externs[fileName]) {
Expand Down

0 comments on commit 06f8d91

Please sign in to comment.