W
Wasp3w ago
yj69

Upgrade wasp from 0.16.0 to 0.17.1

Currently I have wasp 0.17.1 on my local. (MacOS) Earlier in package.json, I was having typescript version as below "devDependencies": { "typescript": "^5.1.0", } Now since, I upgrade to wasp 0.17.1, the error is showing that I must have typescript version 5.8.2. So I upgraded to 5.8.2 then when running wasp start, I found these errors. [ Server ] src/queries/getF2Pflag.ts(3,34): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. [ Server ] src/routes/apis/index.ts(8,92): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. [ Server ] src/routes/apis/index.ts(9,92): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. [ Server ] src/routes/apis/index.ts(93,51): error TS2554: Expected 2 arguments, but got 3. [ Server ] src/routes/apis/index.ts(111,51): error TS2554: Expected 2 arguments, but got 3. [ Server ] src/routes/apis/index.ts(129,49): error TS2554: Expected 2 arguments, but got 3. I have followed migration guideline but currently out of idea...
3 Replies
kapa.ai
kapa.ai3w ago
Hi @yj69. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information in the provided knowledge sources, here’s what can be determined about your issue: TypeScript Version Requirement Wasp 0.17.1 requires TypeScript 5.8.2, which you have already upgraded to. This matches the expected setup. Error: "An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled." This error is related to how TypeScript and Node.js handle ES module imports. Specifically, with "type": "module" in your package.json, TypeScript does not allow import paths ending in .ts unless the allowImportingTsExtensions compiler option is enabled. However, the knowledge sources do not mention enabling this option or changing its default behavior in Wasp. From the migration and restructuring discussions, Wasp expects you to use .js extensions in your imports, even when importing TypeScript files. This is due to how TypeScript compiles .ts files to .js, and Node.js expects .js extensions at runtime. The TypeScript team intentionally does not rewrite import extensions, so you must write your imports as if you are importing .js files, not .ts files, even in your TypeScript source code. This is a known quirk and is discussed in detail in the Wasp issues and migration guides:
ESNext modules require us to set the "type": "module" field in package.json, which in turn expects all relative imports to include a valid extension (this applies to the target dist JS code). TypeScript does not want to transpile imports with no extensions or .ts extensions into imports with a .js extension.
...
This is a feature/quirk of the entire ecosystem and is not specific to Wasp...
Look at extension requirements when importing Jobs ...server requires extension, and there are even more considerations regarding if it is .js or .ts.
Fix inconsistent import extensions in both .wasp file and in JS files.
What You Should Do - Change all your import paths in server-side TypeScript files to use .js extensions, not .ts.
For example, change:
import { foo } from './bar.ts'

import { foo } from './bar.ts'

to:
import { foo } from './bar.js'

import { foo } from './bar.js'

- Do not use .ts extensions in import paths.
This is required for compatibility with ES modules and how TypeScript emits code. Additional Errors The errors about "Expected 2 arguments, but got 3" are unrelated to the import extension issue and likely stem from API changes in Wasp or your own code. You should check the function signatures and update your code accordingly. Summary - Update all server-side imports to use .js extensions, not .ts. - Do not use .ts extensions in import paths, as this is not supported unless you enable allowImportingTsExtensions, which is not mentioned or recommended in the Wasp documentation. - Review any other errors for possible API changes. If you continue to have issues after making these changes, please provide more details about the specific import statements or code causing the errors. If you need more details on the migration process, refer to the official migration guide: Migrating Your Project to the New Structure. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @yj69, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
yj69
yj69OP3w ago
Fixed the issue. Thanks
miho
miho3w ago
I'm glad you got it figured out 🙂

Did you find this page helpful?