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

Use moduleNamespace instead of rootNamespace for externs type #1477

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading