Skip to content

it works , when i use alias in my project.But it occurs an error in ts file. #240

Description

@Jax97
// gulpfile.js

gulp
    .src(entry)
    .pipe(alias({ configuration: tsProject.config }))
    .pipe(tsProject())
    .pipe(gulp.dest('./dist'));
// src/server/controllers/index.ts

import IndexController from '@/controllers/IndexController'; // cannot find module “@/controllers/IndexController” or other type declarations
//  src/server/controllers/IndexController.ts

import Koa from 'koa';

export default class IndexController {
  constructor() {}
  async actionIndex(ctx: Koa.Context, next: Koa.Next) {
    const books = new Books();
    const res = await books.getData();
    ctx.body = res;
  }
}

// tsconfig.json

{
  "compilerOptions": {
    "target": "es5" ,
    "module": "commonjs",
    "paths": {
      "@/controllers": ["./src/server/controllers"],
      "@/models": ["./src/server/models"]
    } ,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

Although the app run normally, I want to resolve the errors in index.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions