Skip to content

Commit bfcca94

Browse files
committed
fix: change defineConfig signature from const to a function
1 parent dcb59f6 commit bfcca94

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎.changeset/silly-places-worry.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'lint-staged': patch
3+
---
4+
5+
Fix TypeScript issue `TS1254` from `defineConfig()` by changing the signature from `const` to a `function`:
6+
7+
> A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

‎lib/config.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ export type Configuration =
6666
* "*.js": ["prettier --check", "eslint"]
6767
* })
6868
*/
69-
export const defineConfig = (config: Configuration) => config
69+
export function defineConfig(config: Configuration): Configuration

‎lib/config.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
export const defineConfig = (configuration) => configuration
1+
/**
2+
* TypeScript helper to define `lint-staged` configuration.
3+
* Use as the default export in a configuration file like `lint-staged.config.js`.
4+
*
5+
* @param {import('./config.d.ts').Configuration} configuration
6+
*
7+
* @example
8+
* export default defineConfig({
9+
* "*.js": ["prettier --check", "eslint"]
10+
* })
11+
*/
12+
export function defineConfig(configuration) {
13+
return configuration
14+
}

0 commit comments

Comments
 (0)