Skip to content

Commit c3bcf0a

Browse files
authored
chore(types): remove property on path normalization (#4327)
this commit removes an unused property, `params`, from the return value of `normalizeFsPathQuery`. this property does not ever appear to be used, and was causing a handful of strictNullChecks violations in the corresponding tests. rather than patch the tests, we remove the property wholesale. this commit also fixes an additional SNC violation for testing that `normalizePath` throws when a non-string is passed as an argument to the function
1 parent 4ab9083 commit c3bcf0a

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/utils/normalize-path.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ export const normalizeFsPathQuery = (importPath: string) => {
168168
return {
169169
filePath,
170170
ext,
171-
params,
172171
format,
173172
};
174173
};

src/utils/test/normalize-path.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ describe('normalizePath', () => {
9090

9191
it('throw error when invalid string', () => {
9292
expect(() => {
93-
const path = normalizePath(null);
93+
// this test deliberately uses a value whose type does not conform to the function signature's type definition to
94+
// ensure non-string's throw an error, requiring us to place a type assertion in the function call below
95+
const path = normalizePath(null as unknown as string);
9496
expect(path).toBe(`/Johnny/B/Goode.js`);
9597
}).toThrow();
9698
});
@@ -100,33 +102,27 @@ describe('normalizeFsPathQuery', () => {
100102
it('format query', () => {
101103
const p = normalizeFsPathQuery(`/Johnny/B/Goode.js?format=text`);
102104
expect(p.filePath).toBe(`/Johnny/B/Goode.js`);
103-
expect(p.params.get('format')).toBe('text');
104105
expect(p.format).toBe('text');
105106
expect(p.ext).toBe(`js`);
106107
});
107108

108109
it('any query', () => {
109110
const p = normalizeFsPathQuery(`/Johnny/B/Goode.svg?a=1&b=2&c=3`);
110111
expect(p.filePath).toBe(`/Johnny/B/Goode.svg`);
111-
expect(p.params.get('a')).toBe('1');
112-
expect(p.params.get('b')).toBe('2');
113-
expect(p.params.get('c')).toBe('3');
114112
expect(p.format).toBe(null);
115113
expect(p.ext).toBe(`svg`);
116114
});
117115

118116
it('no query', () => {
119117
const p = normalizeFsPathQuery(`/Johnny/B/Goode.js`);
120118
expect(p.filePath).toBe(`/Johnny/B/Goode.js`);
121-
expect(p.params).toBe(null);
122119
expect(p.format).toBe(null);
123120
expect(p.ext).toBe(`js`);
124121
});
125122

126123
it('no ext', () => {
127124
const p = normalizeFsPathQuery(`/Johnny/B/Goode`);
128125
expect(p.filePath).toBe(`/Johnny/B/Goode`);
129-
expect(p.params).toBe(null);
130126
expect(p.format).toBe(null);
131127
expect(p.ext).toBe(`/johnny/b/goode`);
132128
});

0 commit comments

Comments
 (0)