Skip to content

Commit

Permalink
Convert docs-utilities to JS + .d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Dec 1, 2022
1 parent 44a23d4 commit 78564f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/docs-utilities/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getLineFeed(source: string): string;

export function fixBabelGeneratorIssues(source: string): string;

export function fixLineEndings(source: string, target: string): string;

export function getUnstyledFilename(filename: string, definitionFile: boolean = false): string;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EOL } from 'os';
const { EOL } = require('os');

/**
* @param {string} source
*/
function getLineFeed(source: string) {
function getLineFeed(source) {
const match = source.match(/\r?\n/);
return match === null ? EOL : match[0];
}
Expand All @@ -12,23 +12,23 @@ const fixBabelIssuesRegExp = /(?<=(\/>)|,)(\r?\n){2}/g;
/**
* @param {string} source
*/
function fixBabelGeneratorIssues(source: string) {
function fixBabelGeneratorIssues(source) {
return source.replace(fixBabelIssuesRegExp, '\n');
}

/**
* @param {string} source
* @param {string} target
*/
function fixLineEndings(source: string, target: string) {
function fixLineEndings(source, target) {
return target.replace(/\r?\n/g, getLineFeed(source));
}

/**
* Converts styled or regular component d.ts file to unstyled d.ts
* @param {string} filename - the file of the styled or regular mui component
*/
function getUnstyledFilename(filename: string, definitionFile = false) {
function getUnstyledFilename(filename, definitionFile = false) {
if (filename.indexOf('Unstyled') > -1) {
return filename;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "@mui-internal/docs-utilities",
"version": "1.0.0",
"private": "true",
"main": "index.ts"
"main": "index.js"
}

0 comments on commit 78564f4

Please sign in to comment.