Skip to content
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

deno publish: Incorrect error for symbol as a property #22544

Closed
MarkTiedemann opened this issue Feb 22, 2024 · 4 comments · Fixed by denoland/deno_graph#402
Closed

deno publish: Incorrect error for symbol as a property #22544

MarkTiedemann opened this issue Feb 22, 2024 · 4 comments · Fixed by denoland/deno_graph#402
Assignees
Labels
bug Something isn't working correctly

Comments

@MarkTiedemann
Copy link
Contributor

Version: Deno 1.40.0

C:\dev\html>deno publish
Checking fast check type graph for errors...
Ensuring type checks...
Check file:///C:/dev/html/html.ts
error: TS1169 [ERROR]: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.
  [rawString]: string;
  ~~~~~~~~~~~
    at file:///C:/dev/html/html.ts:4:18

TS2552 [ERROR]: Cannot find name 'rawString'. Did you mean 'String'?
  [rawString]: string;
   ~~~~~~~~~
    at file:///C:/dev/html/html.ts:5:3

    'String' is declared here.
    declare var String: StringConstructor;
                ~~~~~~
        at asset:///lib.es5.d.ts:544:13

Found 2 errors.

You may have discovered a bug in Deno's fast check implementation. Fast check is still early days and we would appreciate if you log a bug if you believe this is one: https://github.com/denoland/deno/issues/

The code is as follows:

const rawString = Symbol();

/** A string that will not be escaped. */
export interface RawString {
	[rawString]: string;
}

/** Create a raw string that will not be escaped. */
export function raw(str: string): RawString {
	return { [rawString]: str };
}

The code works fine, compiles fine, and deno check does not detect any errors. Not sure why deno publish is not accepting it.

@dsherret dsherret added the bug Something isn't working correctly label Feb 22, 2024
@dsherret dsherret self-assigned this Feb 22, 2024
@dsherret
Copy link
Member

I'd recommend upgrading to 1.41.0. 1.40 is ages ago in deno publish's life.

In this case, the no-slow-types lint rule wasn't properly analyzing interface members with a computed key. I opened denoland/deno_graph#402 to fix it.

For the time being, after upgrading to 1.41.0 you can run deno publish with the --allow-slow-types flag.

@MarkTiedemann
Copy link
Contributor Author

Oh, sorry, I mistyped, I'm on Deno 1.40.4. That's the latest version which is published on winget... Wish that winget would always have the actual latest Deno version, but that's another issue...

Thank you for your work, @dsherret!

If I publish with --allow-slow-types now, can I later republish the same version with fast check? The package I want to publish is done (there will not be any future updates) so I want to avoid publishing two versions.

@dsherret
Copy link
Member

dsherret commented Feb 23, 2024

If you want to ensure it's not using slow types, it might be best to wait for the next release. Sorry! This will slowly get better over time.

@MarkTiedemann
Copy link
Contributor Author

No worries, it's not urgent, plus I am patient. :) Again, thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
2 participants