Skip to content

Commit

Permalink
Propagate @modName to .tsmes files
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 632315251
  • Loading branch information
lauraharker authored and copybara-github committed May 13, 2024
1 parent d5c2921 commit 4410626
Show file tree
Hide file tree
Showing 243 changed files with 5,786 additions and 3,133 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"minimist": "^1.2.3",
"tsickle": "file:../",
"typescript": "5.2.2"
"typescript": "5.4.2"
},
"devDependencies": {
"@types/minimist": "1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"out/src/*"
],
"peerDependencies": {
"typescript": "~5.1.5"
"typescript": "~5.4.2"
},
"devDependencies": {
"@types/diff-match-patch": "^1.0.32",
Expand All @@ -28,7 +28,7 @@
"source-map-support": "^0.5.19",
"tslib": "^2.2.0",
"tslint": "^6.1.3",
"typescript": "5.2.2"
"typescript": "5.4.2"
},
"scripts": {
"build": "tsc",
Expand Down
5 changes: 4 additions & 1 deletion src/annotator_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export interface AnnotatorHost {
* prefix to scope symbols in externs file (see externs.ts).
*/
export function moduleNameAsIdentifier(
host: AnnotatorHost, fileName: string, context = ''): string {
host: AnnotatorHost,
fileName: string,
context = '',
): string {
return host.pathToModuleName(context, fileName).replace(/\./g, '$');
}
15 changes: 11 additions & 4 deletions src/cli_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function assertAbsolute(fileName: string) {
* import and generates a googmodule module name for the imported module.
*/
export function pathToModuleName(
rootModulePath: string, context: string, fileName: string): string {
rootModulePath: string,
context: string,
fileName: string,
): string {
fileName = fileName.replace(/(\.d)?\.[tj]s$/, '');

if (fileName[0] === '.') {
Expand All @@ -37,7 +40,9 @@ export function pathToModuleName(
// TODO(evanm): various tests assume they can import relative paths like
// 'foo/bar' and have them interpreted as root-relative; preserve that here.
// Fix this by removing the next line.
if (!path.isAbsolute(fileName)) fileName = path.join(rootModulePath, fileName);
if (!path.isAbsolute(fileName)) {
fileName = path.join(rootModulePath, fileName);
}

// TODO(evanm): various tests assume they can pass in a 'fileName' like
// 'goog:foo.bar' and have this function do something reasonable.
Expand All @@ -50,8 +55,10 @@ export function pathToModuleName(
}

// Replace characters not supported by goog.module.
const moduleName =
fileName.replace(/\/|\\/g, '.').replace(/^[^a-zA-Z_$]/, '_').replace(/[^a-zA-Z0-9._$]/g, '_');
const moduleName = fileName
.replace(/\/|\\/g, '.')
.replace(/^[^a-zA-Z_$]/, '_')
.replace(/[^a-zA-Z0-9._$]/g, '_');

return moduleName;
}
4 changes: 2 additions & 2 deletions src/closure_externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var ReadonlySet;
* @template T
* @extends {IThenable<T>}
*/
function PromiseLike() {};
function PromiseLike() {}

/** @typedef {function(new:Promise)} */
var PromiseConstructor;
Expand Down Expand Up @@ -94,7 +94,7 @@ var TemplateStringsArray;
var RegExpMatchArray;

/** @record */
function ImportMeta() {};
function ImportMeta() {}

// Representations for TS' EventMap objects.
// These are types that contain a mapping from event names to event object
Expand Down
Loading

0 comments on commit 4410626

Please sign in to comment.