normalizeSeparators (src/util.ts)

angular · packages/compiler-cli/src/ngtsc/file_system/src/util.ts · typescript · MIT
dev-tools, tag:knn-classified

Utility to normalize file path separators and strip extensions for TypeScript source files.

// Source: https://github.com/angular/angular | License: MIT | Copyright 2010-2026 Google LLC. https://angular.dev/license
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.dev/license
 */
import ts from 'typescript';
import {AbsoluteFsPath, PathString} from './types';

const TS_DTS_TSX_JS_EXTENSION = /(?:\.d)?\.ts$|\.tsx$|\.js$/;

/**
 * Convert Windows-style separators to POSIX separators.
 */
export function normalizeSeparators(path: string): string {
  // TODO: normalize path only for OS that need it.
  return path.replace(/\\/g, '/');
}

/**
 * Remove a .ts, .d.ts, .tsx, or .js extensio

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key