Skip to content

Commit

Permalink
feat: add types for Nuxt options (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Jun 4, 2021
1 parent 3c60d1a commit d8e355e
Show file tree
Hide file tree
Showing 9 changed files with 390 additions and 31 deletions.
13 changes: 0 additions & 13 deletions index.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const glob = require('glob-all')
const consola = require('consola')
const logger = consola.withScope('nuxt-style-resources')

/** @type {import('@nuxt/types').Module<import('../types').Options>} */
export default function nuxtStyledResources(moduleOptions) {
const resolver = (this.nuxt.resolver || this.nuxt)

Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
"commitlint": "commitlint -e $GIT_PARAMS",
"coverage": "codecov"
},
"types": "types/index.d.ts",
"eslintIgnore": [
"lib/templates/*.*"
],
"files": [
"lib"
"lib",
"types"
],
"keywords": [
"nuxtjs",
Expand Down Expand Up @@ -64,7 +66,9 @@
"devDependencies": {
"@commitlint/cli": "^7.5.0",
"@commitlint/config-conventional": "^7.5.0",
"@nuxt/types": "^2.15.6",
"@nuxtjs/eslint-config": "^0.0.1",
"@types/jest": "^26.0.23",
"babel-eslint": "^10.0.1",
"codecov": "^3.1.0",
"eslint": "^5.13.0",
Expand All @@ -87,7 +91,8 @@
"sass-loader": "^7.1.0",
"standard-version": "^4.4.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
"stylus-loader": "^3.0.2",
"typescript": "^4.3.2"
},
"husky": {
"hooks": {
Expand Down
5 changes: 4 additions & 1 deletion test/fixture/less/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { resolve } = require('path')

module.exports = {
/** @type {import('@nuxt/types').NuxtConfig} */
const config = {
rootDir: resolve(__dirname, '../../../'),
srcDir: resolve(__dirname),
css: ['~assets/a.less'],
Expand All @@ -20,3 +21,5 @@ module.exports = {
}
}
}

module.exports = config
5 changes: 4 additions & 1 deletion test/fixture/sass/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { resolve } = require('path')

module.exports = {
/** @type {import('@nuxt/types').NuxtConfig} */
const config = {
rootDir: resolve(__dirname, '../../../'),
srcDir: resolve(__dirname),
css: ['@/assets/a.scss', '@/assets/a.sass'],
Expand All @@ -22,3 +23,5 @@ module.exports = {
}
}
}

module.exports = config
5 changes: 4 additions & 1 deletion test/fixture/stylus/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { resolve } = require('path')

module.exports = {
/** @type {import('@nuxt/types').NuxtConfig} */
const config = {
rootDir: resolve(__dirname, '../../../'),
srcDir: resolve(__dirname),
css: ['~assets/a.styl'],
Expand All @@ -20,3 +21,5 @@ module.exports = {
}
}
}

module.exports = config
30 changes: 30 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"baseUrl": ".",
"noEmit": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom",
],
"esModuleInterop": true,
"allowJs": true,
// "checkJs": true,
"strict": true,
"paths": {
"~/*": [
"./*",
],
"@/*": [
"./*",
],
},
"resolveJsonModule": true,
"types": [
"@nuxt/types",
],
},
}
15 changes: 15 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import '@nuxt/types'

interface Options {
sass?: string[] | string
scss?: string[] | string
less?: string[] | string
stylus?: string[] | string
hoistUseStatements?: boolean
}

declare module '@nuxt/types' {
interface NuxtConfig {
styleResources?: Options
}
}
Loading

0 comments on commit d8e355e

Please sign in to comment.