tsconfig.json
{
"compilerOptions": {
"target": "ES3",
"module": "ESNext",
"strict": true,
"jsx": "react",
"allowJs": true,
"importHelpers": true,
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"experimentalDecorators": true,
"baseUrl": "./",
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/*/**"
]
}
src/test.ts
const a = window.client.a()
src/type.d.ts
export {}
interface Client{
a: ()=>string
}
declare global {
interface Window { client: Client; }
}
既然发现了Client的定义,为啥又说找不到
或许
.d.ts
没引入?你试着把declare
直接写进.ts
,如果能行就是没引入