I'm currently working on a gnome shell extension using typescript, but I've encountered issues when trying to import .ts files. The Gnome shell documentation suggests configuring the tsconfig file as outlined in this Gnome typescript docs:
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"sourceMap": false,
"strict": true,
"target"": "ES2022",
"lib": [
"ES2022"
]
},
"include": [
"ambient.d.ts"
],
"files": [
"extension.ts",
"prefs.ts"
]
}
When attempting to import without an extension, I receive the following error :
1. tsserver: Relative import paths require explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './constants.js'? [2835]
If I import with the extension like
import { SOME_CONSTANT } from './constansts.ts
, I encounter the following error:
1. tsserver: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. [5097]
Enabling this rule leads to a compile error:
tsconfig.json:5:35 - error TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.
5 "allowImportingTsExtensions": true,
~~~~
While it compiles, the .ts
extension remains in the import statement rendering the compiled file unfindable. I can't configure 'noEmit' or 'emitDeclarationOnly' settings since Gnome shell requires emitting javascript files with es import modules. I've experimented with changing the moduleResolution
to ESNext
and other options, but then I run into issues importing Gnome's library. I'm at a loss at this point. Any assistance would be greatly appreciated. Additionally, if anyone has insights into which modules need to be enabled based on the documentation, kindly provide that information in the comments.