keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
394 stars 110 forks source link

bug(common): xml2js import in comment/web/types is not building when called as a part of common/web/keyboard-processor #11716

Closed mcdurdin closed 4 months ago

mcdurdin commented 4 months ago
10:26:35   ../types/build/src/deps/xml2js/xml2js.d.ts(10,25): error TS7016: Could not find a declaration file for module './parser.js'. '/var/lib/TeamCity/work/30ffb35c1b6c4089/keyman/common/web/types/src/deps/xml2js/parser.js' implicitly has an 'any' type.
10:26:35   ../types/build/src/deps/xml2js/xml2js.d.ts(11,26): error TS7016: Could not find a declaration file for module './builder.js'. '/var/lib/TeamCity/work/30ffb35c1b6c4089/keyman/common/web/types/src/deps/xml2js/builder.js' implicitly has an 'any' type.
10:26:35   ../types/build/src/main.d.ts(34,25): error TS7016: Could not find a declaration file for module './deps/xml2js/xml2js.js'. '/var/lib/TeamCity/work/30ffb35c1b6c4089/keyman/common/web/types/src/deps/xml2js/xml2js.js' implicitly has an 'any' type.
10:26:35   ../types/build/src/main.d.ts(34,25): error TS7016: Could not find a declaration file for module './deps/xml2js/xml2js.js'. '/var/lib/TeamCity/work/30ffb35c1b6c4089/keyman/common/web/types/src/deps/xml2js/xml2js.js' implicitly has an 'any' type.

Regression arising from #11660. Causing builds to fail on master, which suggests a potential confict with #11424?

mcdurdin commented 4 months ago

This is happening due to inconsistency in the tsconfig.json compilerOptions between web and common/web/types. Specifically, in this instance, allowJs diverges from the global default:

https://github.com/keymanapp/keyman/blob/3530314cbd69e64fb9433d20d1c241d400a50ee4/web/tsconfig.base.json#L14

The problem seems to be that tsc --build in common/web/keyboard-processor will attempt to build common/web/types using the settings from common/web/keyboard-processor/tsconfig.json.

How best to resolve this? I can see various strategies we could use:

  1. Eliminate all compilerOptions overrides across all tsconfig.json files. This is a good long-term solution, as it simplifies our build environment, but it may be difficult to pull off.
  2. Side-step the dependency problem by moving the remaining modules which depend on xml2js to the developer source tree (#9665): kpj-file, kvks-file, ldml-keyboard-xml, kps-file. We will be doing this anyway, and have started in #11531 with kpj-file, but this work was not on the plan for this sprint.
  3. Patch this specific issue. I am not sure of the most reliable approach to doing this at present; I patched out the allowJs property from web/tsconfig.base.json and the build then succeeded, but it may cause other problems?
jahorton commented 4 months ago

If memory serves, the allowJs was originally in place due to its interaction with emitting .d.ts files; there was a point where TS would refuse to emit declaration files if allowJS were true. We're past that point now, and it appears that no build errors resulted - that would be the only potential complication I'd worry about here.