package.json. Quick one : npm init -ynpm install typescript --save-dev)node.d.ts (npm install @types/node --save-dev)tsconfig.json for TypeScript options with a few key options in your tsconfig.json (npx tsc --init --rootDir src --outDir lib --esModuleInterop --resolveJsonModule --lib es6,dom --module commonjs) File 'C:/Users/ack47evii18es/Desktop/disqus-proxy/serverV2/src/config.ts' is not a module.
check the code:
index.ts :
import {config} from './config';
config.ts :
interface Config {
port: number;
api_key: string;
}
const globalConfig: Config = {
port: 5050,
api_key: '',
};
// module.exports = globalConfig; // delete this row
export const config = globalConfig;
import {a} from 'something'; // you will get exported 'a'
import a from 'something'; // you will get exported DEFAULT 'a'
Try
npm install @types/react-router-domif it exists or add a new declaration (.d.ts) file containingdeclare module 'react-router-dom';TS7016
.d.ts是一个包含 declaration 的文件.
npm i {package} -s.d.ts , 不需要任何后续的操作..d.ts , 那么需要提供 @types
2. https://www.npmjs.com/ 先到这里搜索一下看看能不能找到名为 @types/{packageName} 的 包
3. 如果可以找到安装 @types: npm i @types/{packageName} -D
npm install github:user project -D| 文章标题 | Typescript: Getting Started |
| 发布日期 | 2020-01-20 |
| 文章分类 | Tech |
| 相关标签 | #Typescript #NodeJS #TS |