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

fix(path/glob): Fixed array type error in glob.ts #977

Merged
merged 1 commit into from
Jun 28, 2021
Merged

fix(path/glob): Fixed array type error in glob.ts #977

merged 1 commit into from
Jun 28, 2021

Conversation

PatrickShaw
Copy link
Contributor

@PatrickShaw PatrickShaw commented Jun 17, 2021

Description

Hi!

This PR fixes the following error that I've been experiencing with glob.ts:

Error log
error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("+");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:219:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("@");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:226:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
          groupStack.push("?");
                          ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:234:27

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("!");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:244:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("BRACE");
                        ~~~~~~~
    at https://deno.land/std@0.99.0/path/glob.ts:250:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
          groupStack.push("*");
                          ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:269:27

Found 6 errors.

Minimal replicability
tsconfig.json:

{
  "compilerOptions": {
    "noImplicitAny": false
  }
}

example.ts:

import "https://deno.land/std@0.99.0/path/glob.ts";

Running deno run --config ./tsconfig.json ./example.ts will result in the error log above:

Reason
I believe this is caused by const groupStack = []; which is being inferred as never[].

Fix
I added string[] to groupStack.

Tried compiling the file directly with this change and it seems to fix the problem. Happy to do a full run of deno_std tests locally if need be (as per https://github.com/denoland/deno_std#contributing) but I'm assuming this change is pretty safe :)

**Minimal replicability**
tsconfig.json:
```json
{
  "compilerOptions": {
    "noImplicitAny": false
  }
}
```

example.ts:
```typescript
import "https://deno.land/std@0.99.0/path/glob.ts";
```

Running `deno run --config ./tsconfig.json ./example.ts` will result in the following errors:

<details>
  <summary>Error log</summary>
  
```error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("+");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:219:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("@");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:226:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
          groupStack.push("?");
                          ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:234:27

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("!");
                        ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:244:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
        groupStack.push("BRACE");
                        ~~~~~~~
    at https://deno.land/std@0.99.0/path/glob.ts:250:25

TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'never'.
          groupStack.push("*");
                          ~~~
    at https://deno.land/std@0.99.0/path/glob.ts:269:27

Found 6 errors.
``` 
</details>

**Reason**
I believe this is caused by `const groupStack = [];` which is being inferred as `never[]`.

**Fix**
I added `string[]` to `groupStack`.

**Note:** Just started using Deno so possibly I've misconfigured Deno.
@CLAassistant
Copy link

CLAassistant commented Jun 17, 2021

CLA assistant check
All committers have signed the CLA.

@PatrickShaw PatrickShaw changed the title Fixed array type error in glob.ts fix(path/glob) array type error in glob.ts Jun 17, 2021
@PatrickShaw PatrickShaw changed the title fix(path/glob) array type error in glob.ts fix(path/glob): Fixed array type error in glob.ts Jun 17, 2021
PatrickShaw added a commit to the-monorepo/nexus that referenced this pull request Jun 23, 2021
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Harmless to most users, and useful for some users with noImplicitAny: false configuration.

@kt3k kt3k merged commit 8ef538a into denoland:main Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants