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

Propagate @modName to .tsmes files #1523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading