gulp-typescript icon indicating copy to clipboard operation
gulp-typescript copied to clipboard

use gulp and gupl-typescript to compile but found error TS2724: '"react"' has no exported member named 'SFCElement'. Did you mean 'CElement'?

Open TinsFox opened this issue 3 years ago • 1 comments

Expected behavior: successfully compiled typescript Actual behavior: image

Your gulpfile:

var gulp = require('gulp');
var less = require('gulp-less');
var ts = require('gulp-typescript');
gulp.task('default', function () {
    return gulp.src('src/less/index.less')
        .pipe(less())    //编译成为css
        .pipe(gulp.dest('build/css'))    //输出到指定目录
});


gulp.task('ts', function () {
    return gulp.src('src/**/*.ts')
        .pipe(ts({
            noImplicitAny: true,
            outFile: 'output.js'
        }))
        .pipe(gulp.dest('built/local'));
});

Include your gulpfile, or only the related task (with ts.createProject).

gulp.task('ts', function () {
    return gulp.src('src/**/*.ts')
        .pipe(ts({
            noImplicitAny: true,
            outFile: 'output.js'
        }))
        .pipe(gulp.dest('built/local'));
});```

**tsconfig.json**

*Include your tsconfig, if related to this issue.*
```json
{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "ES2019",
    "lib": [
      "ES2019"
    ],
    "strict": true,
    "noEmitOnError": true,
    "declaration": true
  },
  "include": [
    "./src"
  ]
}

Minimal reproducible example Here is my example: https://github.com/TinsFox/proj

Thanks for answering my question.

TinsFox avatar Aug 28 '22 09:08 TinsFox

I solved the problem by deleting the /Users/tinsfox/node_modules directory, but why? Can anyone tell me why?

TinsFox avatar Aug 28 '22 09:08 TinsFox