Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e894de2

Browse files
rchldanielroe
andauthored
chore: dep updates and minor internal type fixes (#748)
Co-authored-by: Daniel Roe <[email protected]>
1 parent 1571863 commit e894de2

File tree

19 files changed

+566
-444
lines changed

19 files changed

+566
-444
lines changed

example/components/Author.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
ref,
1919
} from '@nuxtjs/composition-api'
2020
21+
/** @typedef {{ name: number }} User */
22+
2123
export default defineComponent({
2224
props: {
2325
userId: {
@@ -26,10 +28,10 @@ export default defineComponent({
2628
},
2729
},
2830
setup(props) {
29-
const user = ref({})
31+
const user = ref(/** @type {User} */({}))
3032
3133
const { $http } = useContext()
32-
34+
3335
useFetch(async () => {
3436
user.value = await $http.$get(
3537
`https://jsonplaceholder.typicode.com/users/${props.userId}`

example/nuxt.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const fetch = require('node-fetch')
1+
import fetch from 'node-fetch'
22
const serverlessEnvironment = !!process.env.NOW_BUILD
33

4+
/** @type {import('@nuxt/types').NuxtConfig} */
45
export default {
56
server: {
67
port: process.env.PORT || 8000,
@@ -20,13 +21,14 @@ export default {
2021
generate: {
2122
interval: 2000,
2223
async routes() {
24+
/** @type {{ userId: number, id: number, title: string, body: string }[]} */
2325
const posts = await fetch('https://jsonplaceholder.typicode.com/posts')
2426
.then(res => res.json())
2527
.then(d => d.slice(0, 20))
2628
const routes = posts.map(post => `/posts/${post.id}`)
2729

2830
return ['/'].concat(routes)
2931
},
30-
exclude: ['/posts/23']
32+
exclude: [RegExp('/posts/23')]
3133
},
3234
}

example/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"vue-content-placeholders": "^0.2.1"
77
},
88
"devDependencies": {
9-
"nuxt": "latest"
9+
"@nuxt/types": "^2.16.3",
10+
"@types/node-fetch": "^2.6.3",
11+
"nuxt": "^2.16.3"
1012
},
1113
"scripts": {
1214
"dev": "nuxt",

example/pages/index.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ import {
3434
ref,
3535
} from '@nuxtjs/composition-api'
3636
37+
/** @typedef {{ userId: number, id: number, title: string, body: string }} Post */
38+
3739
export default defineComponent({
3840
setup() {
39-
const posts = ref(null)
41+
const posts = ref(/** @type {Post[]} */([]))
4042
4143
const { $http } = useContext()
42-
44+
4345
useFetch(async () => {
44-
posts.value = await $http
45-
.$get('https://jsonplaceholder.typicode.com/posts')
46-
.then(posts => posts.slice(0, 20))
46+
/** @type {Post[]} */
47+
const data = await $http.$get('https://jsonplaceholder.typicode.com/posts')
48+
posts.value = data.slice(0, 20)
4749
})
4850
4951
return { posts }

example/pages/posts/_id.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineComponent({
5353
post.value = await $http.$get(
5454
`https://jsonplaceholder.typicode.com/posts/${params.value.id}`
5555
)
56-
})
56+
})
5757
5858
return { post }
5959
},

example/plugins/vue-placeholders.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue from 'vue'
2+
// @ts-ignore
23
import VueContentPlaceholders from 'vue-content-placeholders'
34

45
Vue.use(VueContentPlaceholders)

example/tsconfig.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"rootDir": ".",
5+
"strict": true,
6+
"sourceMap": true,
7+
"allowJs": true,
8+
"checkJs": true,
9+
"noEmit": true,
10+
"target": "ESNext",
11+
"module": "CommonJS",
12+
"moduleResolution": "Node",
13+
"lib": [
14+
"ESNext",
15+
"DOM"
16+
],
17+
"esModuleInterop": true,
18+
"resolveJsonModule": true,
19+
"allowSyntheticDefaultImports": true,
20+
"types": [
21+
"node",
22+
"@nuxt/http",
23+
"@nuxt/types",
24+
]
25+
},
26+
}

example/types/vue.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.vue' {
2+
import { DefineComponent } from 'vue'
3+
const component: DefineComponent<{}, {}, any>
4+
export default component
5+
}

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,40 +67,42 @@
6767
"ufo": "^1.0.1"
6868
},
6969
"devDependencies": {
70-
"@babel/traverse": "^7.20.13",
71-
"@babel/types": "^7.20.7",
70+
"@babel/traverse": "^7.21.4",
71+
"@babel/types": "^7.21.4",
7272
"@nuxt/test-utils": "^0.2.2",
73-
"@nuxt/types": "^2.15.8",
73+
"@nuxt/types": "^2.16.3",
7474
"@nuxt/typescript-build": "^3.0.1",
7575
"@nuxtjs/module-test-utils": "^1.6.3",
7676
"@nuxtjs/pwa": "^3.3.5",
7777
"@release-it/conventional-changelog": "^5.1.1",
7878
"@types/fs-extra": "^9.0.13",
79+
"@types/node": "^16.18.23",
7980
"@types/normalize-path": "^3.0.0",
80-
"@typescript-eslint/eslint-plugin": "^5.50.0",
81-
"@typescript-eslint/parser": "^5.50.0",
82-
"c8": "^7.12.0",
81+
"@typescript-eslint/eslint-plugin": "^5.57.0",
82+
"@typescript-eslint/parser": "^5.57.0",
83+
"c8": "^7.13.0",
8384
"codecov": "^3.8.3",
8485
"core-js": "3.29.1",
8586
"cross-env": "^7.0.3",
86-
"eslint": "^8.33.0",
87-
"eslint-config-prettier": "^8.6.0",
87+
"eslint": "^8.37.0",
88+
"eslint-config-prettier": "^8.8.0",
8889
"eslint-plugin-prettier": "^4.2.1",
8990
"eslint-plugin-promise": "^6.1.1",
9091
"happy-dom": "^8.9.0",
9192
"http-server": "^14.1.1",
92-
"lint-staged": "^13.1.0",
93+
"lint-staged": "^13.2.0",
9394
"npm-run-all": "^4.1.5",
94-
"nuxt": "^2.15.8",
95-
"prettier": "^2.8.3",
95+
"nuxt": "^2.16.3",
96+
"prettier": "^2.8.7",
9697
"release-it": "15.9.3",
97-
"rimraf": "^4.1.2",
98+
"rimraf": "^4.4.1",
9899
"siroc": "0.16.0",
99100
"start-server-and-test": "^2.0.0",
100101
"testcafe": "2.4.0",
101102
"ts-loader": "^8.4.0",
102103
"tsd": "^0.28.1",
103104
"typescript": "5.0.3",
105+
"vite": "^4.2.1",
104106
"vitest": "^0.29.8",
105107
"yorkie": "^2.0.0"
106108
},

test/fixture/api/posts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
/** @type {import('@nuxt/types').ServerMiddleware} */
12
module.exports = (req, res) => {
23
res.setHeader('Content-Type', 'application/json')
3-
return res.end(JSON.stringify({ id: req.url.split('/').slice(-1)[0] }))
4+
res.end(JSON.stringify({ id: req.url?.split('/').slice(-1)[0] }))
45
}

0 commit comments

Comments
 (0)