Skip to content

Commit

Permalink
fix: avoid handling keys as str literals
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Dec 23, 2022
1 parent 6b3597f commit 63ca69d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fns/formatStringLiterals.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const getReducer = (options) => {
* @param {string} type The type that will be used to find the string literals.
* @returns {string[]}
*/
const extractLiterals = (type) => R.match(/['"][\w\|\-\s'"]+['"](?: +)?/g, type);
const extractLiterals = (type) => R.match(/['"][\w\|\-\s'"]+['"](?: +)?(?:$|\|)/g, type);
/**
* Formats the styling of string literals inside a type. If the type doesn't use string
* literals, it will be returned without modification.
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/fixtures/random-02.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,28 @@ module.exports = {
* @description don't transform this into a sentence
*/

/**
* @typedef {{
* 'Sr No': number;
* 'Program name': string;
* Seniority: number | null;
* "Speaker's name": string;
* }} MemoriesRow
*/

//# output

/**
* don't transform this into a sentence
*
* @type {Object} Something
*/

/**
* @typedef {{
* 'Sr No': number;
* 'Program name': string;
* Seniority: number | null;
* "Speaker's name": string;
* }} MemoriesRow
*/

0 comments on commit 63ca69d

Please sign in to comment.