Description
I've tried to compileing ts files with custom tsconfig.json that contains typeRoots since I'm using custom types.
But compiling only completed with tsc in manual, not with gulp-typescript...
this issue is literally same as issue #421, but I cannot find solution for year 2023.
I tried change gulp-typescript version(5.0.1), but didn't work either.
and added under code at tsconfig.json, also does not resolve it.
"paths": {
"*": ["@types/*"]
},
Expected behavior:
works fine as tsc
Actual behavior:
src/app.preload.ts(5,6): error TS2304: Cannot find name 'PreloadAPI'.
TypeScript: 1 semantic error
TypeScript: emit succeeded (with errors)
[02:52:39] 'node' errored after 1.24 s
[02:52:39] Error: TypeScript: Compilation failed
at Output.mightFinish (/Users/gwonhaesol/Desktop/keepgo-studio/twitch-electron/node_modules/gulp-typescript/release/output.js:130:43)
at /Users/gwonhaesol/Desktop/keepgo-studio/twitch-electron/node_modules/gulp-typescript/release/output.js:43:22
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[02:52:39] 'build' errored after 1.24 s
Your gulpfile:
Include your gulpfile, or only the related task (with ts.createProject
).
const gulp = require("gulp");
const ts = require("gulp-typescript");
const nodeProject = ts.createProject("./src/tsconfig.json");
const builds = {
node: () => gulp
.src(["src/*.ts"])
.pipe(nodeProject())
.pipe(gulp.dest("dist/"))
};
gulp.task("build", gulp.parallel([builds.node]));
tsconfig.json
Include your tsconfig, if related to this issue.
{
"extends": "./tsconfig.common.json",
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"outDir": "../dist",
"module": "CommonJS",
"typeRoots": [
"@types"
]
},
"include": [
"*.ts",
"@types/*.d.ts"
],
"exclude": [
"app/**/*.ts",
"public/**/*"
]
}
Code
Include your TypeScript code, if necessary.
import { contextBridge } from "electron";
contextBridge.exposeInMainWorld('api', {
version: process.versions.node
} as PreloadAPI);
I've made same example project at https://github.com/iougou03/tests/tree/gulp-typescript-issue