adevart
adevart

Reputation: 156

gulp-typescript error with readonly keyword in definitions file

I have a Typescript module that generates a d.ts file. In it, there are parts that use the readonly keyword like the following:

readonly type:string

When I use that d.ts file in another module, the compiler throws an error saying:

error TS1005: '=' expected.

I'm using gulp-typescript 5.0.1 and typescript 3.5.3.

Some other posts on Stackoverflow suggest increasing the versions of gulp-typescript and typescript but I'm using newer versions.

gulp-typescript compiler throws errors on readonly modifier

Is there a way to force Typescript to not write out readonly keywords in d.ts files such as targeting a lower version output for compatibility?

Is there a way to check what version of Typescript is being used for compiling? I removed older versions of Typescript from the global npm directory but I want to check if it's reading an older module somewhere.

Upvotes: 0

Views: 64

Answers (1)

adevart
adevart

Reputation: 156

My problem seems to have been caused by an older version of npm. I upgraded npm, cleaned out the modules folders and rebuilt and it worked ok. I'm not sure why the same version of the Typescript compiler would behave differently under different versions of npm. Maybe it installed an older version of the compiler somewhere.

What would have been useful to debug this problem is being able to print out the path or version of the Typescript compiler being used by the gulp-typescript process.

Upvotes: 0

Related Questions