Skip to content

"A 'declare' modifier cannot be used in an already ambient context" after upgrading to version 0.27.35 #2915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
haykam821 opened this issue Apr 18, 2025 · 3 comments
Labels

Comments

@haykam821
Copy link

Bug description

When upgrading to version 0.27.35, I am getting a new error in my builds:

> tsc

../../node_modules/assemblyscript/std/assembly/index.d.ts:2698:3 - error TS1038: A 'declare' modifier cannot be used in an already ambient context.

2698   declare function always<T>(value: T): T;
       ~~~~~~~


Found 1 error in ../../node_modules/assemblyscript/std/assembly/index.d.ts:2698

The changelog for the release does not indicate any particular change that would cause this breakage. The corresponding lines of code appear to be:

export namespace inline {
// @ts-ignore: decorator
@unsafe @builtin
export declare function always<T>(expr: T): T;
}

Steps to reproduce

The particular package that fails to build uses the following TypeScript configuration with tsc:

{
	"compilerOptions": {
		"outDir": "./dist",
		"rootDir": "./src"
	},
	"extends": "assemblyscript/std/assembly.json",
	"include": [
		"./src"
	]
}

AssemblyScript version

v0.27.35

@haykam821 haykam821 added the bug label Apr 18, 2025
@mattjohnsonpint
Copy link
Contributor

Well, the changelog for 0.27.35 does indeed reference #2895 which is where the new function that came from.

I see you're using tsc not asc, so I presume your code using AssemblyScript's portability features. @CountBleck - perhaps this is a portability issue?

CountBleck added a commit to CountBleck/assemblyscript that referenced this issue Apr 18, 2025
It was supposed to be `export`. Silly me.
Fixes AssemblyScript#2915.
@CountBleck
Copy link
Member

I suppose that's what I get for writing that part on my phone, without IntelliSense...
In any case, the next release (around 12 AM UTC) should fix this.

@haykam821
Copy link
Author

Thank you! Version 0.27.36 resolved the build issue on my end.

Regarding the tsc mention, right now I have a setup like so:

flowchart TD
    A[Backend app] --> B[Common TypeScript library]
    C[Common AssemblyScript library for managing WASM memory] --> B
    D[AssemblyScript module] --> C
    E[Another AssemblyScript module] --> C
Loading

I'm using tsc to compile the common library while using AssemblyScript's types, then compiling the library into each module. From what I understand, I don't need portability in this case. The editor integration features seem to work a little oddly, but I'm assuming that's from my project structure as opposed to a difference with AssemblyScript, and the issues aren't major enough to be worth debugging anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants