Skip to content

JSDocs @typedef {typeof import()} doesn't work with @ts-check pragma (throws "not a module") #25480

Closed
@donaldpipowitch

Description

@donaldpipowitch

TypeScript Version: 3.0.0-dev.201xxxxx and 2.9.2

Search Terms:

  • JSDoc
  • typedef
  • import
  • ts-check

Code

Having jest and @types/jest installed this snippet...

/** @typedef {typeof import('jest')} */

/** @type jest.InitialConfig */
const config = {
  collectCoverage: true,
  coverageReporters: ['text'],
  transform: {
    '^.+\\.(ts?|tsx?)$': '<rootDir>/node_modules/ts-jest/preprocessor.js'
  },
  testRegex: '(/tests/.*)\\.unit\\.(ts?|tsx?)$',
  testPathIgnorePatterns: ['/node_modules/', '/tests/helper/'],
  moduleFileExtensions: ['ts', 'tsx', 'json', 'js']
};

module.exports = config;

...seems to correctly use ProjectConfig. But when I add // @ts-check in the first line I get an error.

Expected behavior:

No error. Just more type checks. (E.g. // @ts-check I could set collectCoverage: 'foo' without an error.)

Actual behavior:

/** @typedef {typeof import('jest')} */: File '../node_ modules/@types/jest/index.d.ts' is not a module.

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions