我的文件app.spec.ts中有此导入:
import app from './app';
这导致了这个类型脚本错误
2:17 error Unable to resolve path to module './app' import/no-unresolved
./app.ts是存在的,但我还没有汇编.ts文件转换成一个文件.js文件.一旦我编译了.ts文件到一个.js,错误消失了.
然而,由于eslint应该与typescript一起工作,所以它应该使用.而不是那个.js.
我还在我的eslint
配置文件中添加了typescript信息:
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
我如何配置eslint,使其try 使用解析模块.而不是那个.js?
干杯
EDIT #1
内容app.ts
:
import bodyParser from 'body-parser';
import express from 'express';
import graphqlHTTP from 'express-graphql';
import { buildSchema } from 'graphql';
const app = express();
const schema = buildSchema(`
type Query {
hello: String
}
`);
const root = { hello: () => 'Hello world!' };
app.use(bodyParser());
app.use('/graphql', graphqlHTTP({
schema,
rootValue: root,
graphiql: true,
}));
export default app;