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

Bug: [require-await] Crash with yield* + Omit #5458

Closed
4 tasks done
stevenwdv opened this issue Aug 10, 2022 · 5 comments
Closed
4 tasks done

Bug: [require-await] Crash with yield* + Omit #5458

stevenwdv opened this issue Aug 10, 2022 · 5 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Milestone

Comments

@stevenwdv
Copy link

stevenwdv commented Aug 10, 2022

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.7.2&sourceType=module&code=IYZwngdgxgBAZgV2gFwJYHsICp4AoCUMA3gLABQMMANgKbIwAeAhAFwwDyAtqsgDykVKMANoBlMJwBG6KgDpQkKAElkNAE7Bk6NQF0CbAILhoK9Zu29gEMAD4A3OUoBfADQwA5AC93NxzDCoNFQAJjgMDmROQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6aRAR1ko9oEMA7v0r50URNGgB7aJHBgAviEVA&tsconfig=N4XyA

(Unfortunately the playground does not show internal errors)

Repro Code

async function* f() {
	let x!: Omit<{
		[Symbol.asyncIterator](): AsyncIterator<any>;
	}, 'z'>
	yield* x;
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/require-await": ["error"],
  },
};

tsconfig

{}

Expected Result

I expected the linter to not crash and output nothing

Actual Result

Oops! Something went wrong! :(

ESLint: 8.21.0

TypeError: Cannot read properties of undefined (reading 'name')
Occurred while linting path\to\project\src\linttest.ts:5
Rule: "@typescript-eslint/require-await"
    at Object.getWellKnownSymbolPropertyOfType (path\to\project\node_modules\tsutils\util\type.js:181:102)
    at markAsHasDelegateGen (path\to\project\node_modules\@typescript-eslint\eslint-plugin\dist\rules\require-await.js:120:47)
    at ruleErrorHandler (path\to\project\node_modules\eslint\lib\linter\linter.js:1114:28)
    at path\to\project\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (path\to\project\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (path\to\project\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:795:23)

Additional Info

2022-08-10T13:49:11.180Z eslint:cli CLI args: [ '.\\src\\linttest.ts', '--debug' ]
2022-08-10T13:49:11.183Z eslint:cli Running on files
2022-08-10T13:49:11.204Z eslintrc:config-array-factory Loading .eslintignore file: path\to\project\.eslintignore
2022-08-10T13:49:11.205Z eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'path\\to\\project', loose: false } ]
2022-08-10T13:49:11.208Z eslintrc:ignore-pattern   processed: { basePath: 'path\\to\\project', patterns: [ '/**/node_modules/*' ] }
2022-08-10T13:49:11.208Z eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'path\\to\\project', loose: false } ]
2022-08-10T13:49:11.209Z eslintrc:ignore-pattern   processed: { basePath: 'path\\to\\project', patterns: [ '/**/node_modules/*' ] }
2022-08-10T13:49:11.209Z eslint:file-enumerator Start to iterate files: [ '.\\src\\linttest.ts' ]
2022-08-10T13:49:11.210Z eslint:file-enumerator File: path\to\project\src\linttest.ts
2022-08-10T13:49:11.210Z eslintrc:cascading-config-array-factory Load config files for path\to\project\src.
2022-08-10T13:49:11.211Z eslintrc:cascading-config-array-factory No cache found: path\to\project\src.
2022-08-10T13:49:11.212Z eslintrc:config-array-factory Config file not found on path\to\project\src
2022-08-10T13:49:11.212Z eslintrc:cascading-config-array-factory No cache found: path\to\project.
2022-08-10T13:49:11.213Z eslintrc:config-array-factory Loading YAML config file: path\to\project\.eslintrc.yml
2022-08-10T13:49:11.237Z eslintrc:config-array-factory Config file found: path\to\project\.eslintrc.yml
2022-08-10T13:49:11.239Z eslintrc:config-array-factory Loading parser "@typescript-eslint/parser" from path\to\project\.eslintrc.yml
2022-08-10T13:49:11.241Z eslintrc:config-array-factory Loaded: @typescript-eslint/parser@5.33.0 (path\to\project\node_modules\@typescript-eslint\parser\dist\index.js)
2022-08-10T13:49:11.595Z eslintrc:config-array-factory Loading plugin "@typescript-eslint" from path\to\project\.eslintrc.yml
2022-08-10T13:49:11.597Z eslintrc:config-array-factory Loaded: @typescript-eslint/eslint-plugin@5.33.0 (path\to\project\node_modules\@typescript-eslint\eslint-plugin\dist\index.js)
2022-08-10T13:49:11.713Z eslint:rules Loading rule 'brace-style' (remaining=286)
2022-08-10T13:49:11.722Z eslint:rules Loading rule 'comma-dangle' (remaining=285)
2022-08-10T13:49:11.731Z eslint:rules Loading rule 'dot-notation' (remaining=284)
2022-08-10T13:49:11.738Z eslint:rules Loading rule 'indent' (remaining=283)
2022-08-10T13:49:11.743Z eslint:rules Loading rule 'init-declarations' (remaining=282)
2022-08-10T13:49:11.744Z eslint:rules Loading rule 'keyword-spacing' (remaining=281)
2022-08-10T13:49:11.746Z eslint:rules Loading rule 'lines-between-class-members' (remaining=280)
2022-08-10T13:49:11.765Z eslint:rules Loading rule 'no-dupe-class-members' (remaining=279)
2022-08-10T13:49:11.768Z eslint:rules Loading rule 'no-duplicate-imports' (remaining=278)
2022-08-10T13:49:11.770Z eslint:rules Loading rule 'no-empty-function' (remaining=277)
2022-08-10T13:49:11.773Z eslint:rules Loading rule 'no-extra-parens' (remaining=276)
2022-08-10T13:49:11.775Z eslint:rules Loading rule 'no-extra-semi' (remaining=275)
2022-08-10T13:49:11.789Z eslint:rules Loading rule 'no-invalid-this' (remaining=274)
2022-08-10T13:49:11.791Z eslint:rules Loading rule 'no-loop-func' (remaining=273)
2022-08-10T13:49:11.792Z eslint:rules Loading rule 'no-loss-of-precision' (remaining=272)
2022-08-10T13:49:11.794Z eslint:rules Loading rule 'no-magic-numbers' (remaining=271)
2022-08-10T13:49:11.817Z eslint:rules Loading rule 'no-restricted-imports' (remaining=270)
2022-08-10T13:49:11.855Z eslint:rules Loading rule 'no-unused-expressions' (remaining=269)
2022-08-10T13:49:11.858Z eslint:rules Loading rule 'no-useless-constructor' (remaining=268)
2022-08-10T13:49:11.864Z eslint:rules Loading rule 'object-curly-spacing' (remaining=267)
2022-08-10T13:49:11.894Z eslint:rules Loading rule 'quotes' (remaining=266)
2022-08-10T13:49:11.911Z eslint:rules Loading rule 'semi' (remaining=265)
2022-08-10T13:49:11.913Z eslint:rules Loading rule 'space-before-blocks' (remaining=264)
2022-08-10T13:49:11.916Z eslint:rules Loading rule 'space-infix-ops' (remaining=263)
2022-08-10T13:49:11.932Z eslintrc:config-array-factory Plugin path\to\project\node_modules\@typescript-eslint\eslint-plugin\dist\index.js loaded in: 335ms
2022-08-10T13:49:11.933Z eslintrc:cascading-config-array-factory Stop traversing because of 'root:true'.
2022-08-10T13:49:11.936Z eslintrc:cascading-config-array-factory Configuration was determined: ConfigArray(4) [ { type: 'config', name: 'DefaultIgnorePattern', filePath: '', criteria: null, env: undefined, globals: undefined, ignorePattern: IgnorePattern { patterns: [Array], basePath: 'path\\to\\project', loose: false }, noInlineConfig: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined }, { type: 'config', name: '.eslintrc.yml', filePath: 'path\\to\\project\\.eslintrc.yml', criteria: null, env: undefined, globals: undefined, ignorePattern: undefined, noInlineConfig: undefined, parser: { error: null, filePath: 'path\\to\\project\\node_modules\\@typescript-eslint\\parser\\dist\\index.js', id: '@typescript-eslint/parser', importerName: '.eslintrc.yml', importerPath: 'path\\to\\project\\.eslintrc.yml' }, parserOptions: undefined, plugins: { '@typescript-eslint': [Object] }, processor: undefined, reportUnusedDisableDirectives: undefined, root: true, rules: undefined, settings: undefined }, { type: 'config', name: '.eslintrc.yml#overrides[0]', filePath: 'path\\to\\project\\.eslintrc.yml', criteria: { includes: [Array], excludes: [Array], basePath: 'path\\to\\project' }, env: undefined, globals: undefined, ignorePattern: undefined, noInlineConfig: undefined, parser: undefined, parserOptions: { project: './tsconfig.json' }, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: { '@typescript-eslint/require-await': 'error' }, settings: undefined }, { type: 'ignore', name: '.eslintignore', filePath: 'path\\to\\project\\.eslintignore', criteria: null, env: undefined, globals: undefined, ignorePattern: IgnorePattern { patterns: [Array], basePath: 'path\\to\\project', loose: true }, noInlineConfig: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined } ] on path\to\project\src
2022-08-10T13:49:11.937Z eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'path\\to\\project', loose: false }, IgnorePattern { patterns: [ '/test/' ], basePath: 'path\\to\\project', loose: true } ]
2022-08-10T13:49:11.938Z eslintrc:ignore-pattern   processed: { basePath: 'path\\to\\project', patterns: [ '/**/node_modules/*', '/test/' ] }
2022-08-10T13:49:11.939Z eslintrc:ignore-pattern Check {
  filePath: 'path\\to\\project\\src\\linttest.ts',
  dot: false,
  relativePath: 'src/linttest.ts',
  result: false
}
2022-08-10T13:49:11.940Z eslint:cli-engine Lint path\to\project\src\linttest.ts
2022-08-10T13:49:11.940Z eslint:linter Linting code for path\to\project\src\linttest.ts (pass 1)
2022-08-10T13:49:11.940Z eslint:linter Verify
2022-08-10T13:49:11.940Z eslint:linter With ConfigArray: path\to\project\src\linttest.ts
2022-08-10T13:49:11.942Z eslint:linter Parsing: path\to\project\src\linttest.ts
2022-08-10T13:49:13.314Z eslint:linter Parsing successful: path\to\project\src\linttest.ts
2022-08-10T13:49:13.315Z eslint:linter Scope analysis: path\to\project\src\linttest.ts
2022-08-10T13:49:13.315Z eslint:linter Scope analysis successful: path\to\project\src\linttest.ts
2022-08-10T13:49:13.339Z eslint:linter An error occurred while traversing
2022-08-10T13:49:13.339Z eslint:linter Filename: path\to\project\src\linttest.ts
2022-08-10T13:49:13.339Z eslint:linter Line: 5
2022-08-10T13:49:13.339Z eslint:linter Parser Options: { project: './tsconfig.json', ecmaVersion: undefined }
2022-08-10T13:49:13.339Z eslint:linter Parser Path: path\to\project\node_modules\@typescript-eslint\parser\dist\index.js
2022-08-10T13:49:13.339Z eslint:linter Settings: {}

Oops! Something went wrong! :(

ESLint: 8.21.0

TypeError: Cannot read properties of undefined (reading 'name')
Occurred while linting path\to\project\src\linttest.ts:5
Rule: "@typescript-eslint/require-await"
    at Object.getWellKnownSymbolPropertyOfType (path\to\project\node_modules\tsutils\util\type.js:181:102)
    at markAsHasDelegateGen (path\to\project\node_modules\@typescript-eslint\eslint-plugin\dist\rules\require-await.js:120:47)
    at ruleErrorHandler (path\to\project\node_modules\eslint\lib\linter\linter.js:1114:28)
    at path\to\project\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (path\to\project\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (path\to\project\node_modules\eslint\lib\linter\node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (path\to\project\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:795:23)

Versions

package version
@typescript-eslint/eslint-plugin 5.33.0
@typescript-eslint/parser 5.33.0
TypeScript 4.7.4
ESLint 8.21.0
node 18.7.0
@stevenwdv stevenwdv added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Aug 10, 2022
@stevenwdv stevenwdv changed the title Bug: [require-await] Crashes with yield* + Omit Bug: [require-await] Crash with yield* + Omit Aug 10, 2022
@JoshuaKGoldberg
Copy link
Member

(Unfortunately the playground does not show internal errors)

That is unfortunate! Filed #5459, thanks for mentioning!

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Aug 10, 2022
@Josh-Cena
Copy link
Member

Josh-Cena commented Aug 10, 2022

Looks like an upstream issue. type.getProperties()[0].valueDeclaration may be absent:

image

The library is force-casting for some reason:

https://github.com/ajafff/tsutils/blob/03b4df15d14702f9c7a128ac3fae77171778d613/util/type.ts#L216

Caveat: that repo seems dead for a year now.

@bradzacher
Copy link
Member

Looks like an upstream issue

This probably is intentional from TS's part.
They often create APIs that may be nullish that aren't typed as nullish.

Which is why we have this internal lint rule which warns against certain unsafe props

We should probably fork the util and fix it locally?

@Josh-Cena
Copy link
Member

It's actually nullish in the TS types. tsutils is casting it, as the link above shows.

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Feb 6, 2023

As of #6428, the v6 branch uses ts-api-utils. Which has the same bug as tsutils. Fix is in review here: JoshuaKGoldberg/ts-api-utils#16

@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Feb 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

4 participants