Commit 7fb76cde by Archer

feat: 类型声明

parent 38d49ea0
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
"sass": "^1.58.3", "sass": "^1.58.3",
"sharp": "^0.31.3", "sharp": "^0.31.3",
"tunnel": "^0.0.6", "tunnel": "^0.0.6",
"typescript": "4.9.5",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zustand": "^4.3.5" "zustand": "^4.3.5"
}, },
...@@ -63,7 +62,8 @@ ...@@ -63,7 +62,8 @@
"eslint-config-next": "13.1.6", "eslint-config-next": "13.1.6",
"husky": "^8.0.3", "husky": "^8.0.3",
"lint-staged": "^13.1.2", "lint-staged": "^13.1.2",
"prettier": "^2.8.4" "prettier": "^2.8.4",
"typescript": "4.9.5"
}, },
"lint-staged": { "lint-staged": {
"./src/**/*.{ts,tsx,scss}": "npm run format" "./src/**/*.{ts,tsx,scss}": "npm run format"
......
...@@ -25,7 +25,8 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean ...@@ -25,7 +25,8 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
pre: 'div', pre: 'div',
code({ node, inline, className, children, ...props }) { code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || ''); const match = /language-(\w+)/.exec(className || '');
const code = String(children).replace(/\n$/, ''); const code = String(children);
return !inline || match ? ( return !inline || match ? (
<Box my={3} borderRadius={'md'} overflow={'hidden'} backgroundColor={'#222'}> <Box my={3} borderRadius={'md'} overflow={'hidden'} backgroundColor={'#222'}>
<Flex <Flex
...@@ -53,7 +54,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean ...@@ -53,7 +54,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
</Box> </Box>
) : ( ) : (
<code className={className} {...props}> <code className={className} {...props}>
{children} {code}
</code> </code>
); );
} }
......
import mongoose, { Mongoose } from 'mongoose'; import mongoose from 'mongoose';
/** /**
* 连接 MongoDB 数据库 * 连接 MongoDB 数据库
......
import type { Mongoose } from 'mongoose'; import type { Mongoose } from 'mongoose';
declare global { declare global {
namespace NodeJS { var mongodb: Mongoose | string | null;
interface Global {
mongodb: Mongoose | string;
}
}
} }
export {};
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
"target": "es5", "target": "es5",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"noImplicitAny": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
...@@ -18,8 +17,9 @@ ...@@ -18,8 +17,9 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
} },
"declaration": true
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts"], "include": ["next-env.d.ts", "src/**/*"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment