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

"".isWellFormed() doesn't type-check #24238

Open
skybrian opened this issue Jun 18, 2024 · 3 comments
Open

"".isWellFormed() doesn't type-check #24238

skybrian opened this issue Jun 18, 2024 · 3 comments
Labels
bug Something isn't working correctly types Issues related to TypeScript types

Comments

@skybrian
Copy link

Version: Deno 1.44.2

The isWellFormed() method on strings works, but doesn't type-check.

% cat >> bug.ts
"".isWellFormed()

% deno check bug.ts 
Check [redacted]/bug.ts
error: TS2339 [ERROR]: Property 'isWellFormed' does not exist on type '""'.
"".isWellFormed()
   ~~~~~~~~~~~~
    at [redacted]/bug.ts:1:4

% deno
Deno 1.44.2
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> "".isWellFormed()
true
> 

Here is a workaround:

interface ExtraStringMethods {
  isWellFormed(): boolean;
}

function isWellFormed(str: string): boolean {
  return (str as unknown as ExtraStringMethods).isWellFormed();
}
@satyarohith satyarohith added the working as designed this is working as intended label Jun 18, 2024
@satyarohith
Copy link
Member

This is working as expected similar to tsc:

➜  ~ cat -p a.ts
"".isWellFormed();
➜  ~ deno check a.ts
Check file:///Users/sr/a.ts
error: TS2339 [ERROR]: Property 'isWellFormed' does not exist on type '""'.
"".isWellFormed();
   ~~~~~~~~~~~~
    at file:///Users/sr/a.ts:1:4
➜  ~ tsc a.ts
a.ts:1:4 - error TS2339: Property 'isWellFormed' does not exist on type '""'.

1 "".isWellFormed();
     ~~~~~~~~~~~~


Found 1 error in a.ts:1

@petamoriken
Copy link
Contributor

petamoriken commented Jun 18, 2024

I'll update types at tsc side

ref: microsoft/TypeScript#58573

@petamoriken
Copy link
Contributor

@satyarohith This issue is working in progress, not working as designed

@lucacasonato lucacasonato removed the working as designed this is working as intended label Jun 18, 2024
@lucacasonato lucacasonato reopened this Jun 18, 2024
@lucacasonato lucacasonato added bug Something isn't working correctly types Issues related to TypeScript types labels Jun 18, 2024
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 types Issues related to TypeScript types
Projects
None yet
Development

No branches or pull requests

4 participants