Skip to content

Feature Request: Include Definition File in Package Distribution #60

@jambonrose

Description

@jambonrose

I have a webpack config written in Typescript (webpack.config.ts; it allows me to use an interface to ensure I'm not misconfiguring webpack). When I try to import fork-ts-checker-webpack-plugin, however, I'm shown an error about missing Typescript definitions.

/Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:307
        throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
              ^
TSError: ⨯ Unable to compile TypeScript
webpack.config.ts (2,45): Could not find a declaration file for module 'fork-ts-checker-webpack-plugin'. '/Users/andrew/Development/ProjectName/node_modules/fork-ts-checker-webpack-plugin/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/fork-ts-checker-webpack-plugin` if it exists or add a new declaration (.d.ts) file containing `declare module 'fork-ts-checker-webpack-plugin';` (7016)
    at getOutput (/Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:307:15)
    at /Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:336:16
    at Object.compile (/Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:498:11)
    at Module.m._compile (/Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:392:43)
    at Module._extensions..js (module.js:635:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/andrew/Development/ProjectName/node_modules/ts-node/src/index.ts:395:12)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)

Given that the package is actually written in Typescript, it would be great if you included the type definitions with distributions.

Note that some work appears to be required. I had no problem downloading the package, installing dependencies with yarn and building the package with yarn build. However, when I add "declaration": true, to "compilerOptions" in src/tsconfig.json, yarn build fails unexpectedly:

$ yarn build
yarn run v1.2.0
$ tsc --version && tsc --project "./src"
Version 2.5.2
src/CancellationToken.ts(22,31): error TS4070: Parameter 'json' of public static method from exported class has or is using private name 'CancellationTokenData'.
src/FilesRegister.ts(10,55): error TS4031: Public property 'files' of exported class has or is using private name 'DataShape'.
src/FilesRegister.ts(11,33): error TS4031: Public property 'dataFactory' of exported class has or is using private name 'DataShape'.
src/FilesRegister.ts(13,45): error TS4063: Parameter 'dataFactory' of constructor from exported class has or is using private name 'DataShape'.
src/FilesRegister.ts(39,3): error TS4055: Return type of public method from exported class has or is using private name 'DataShape'.
src/FilesRegister.ts(53,3): error TS4055: Return type of public method from exported class has or is using private name 'DataShape'.
src/FilesRegister.ts(57,48): error TS4073: Parameter 'mutator' of public method from exported class has or is using private name 'DataShape'.
src/IncrementalChecker.ts(61,10): error TS4050: Return type of public static method from exported class has or is using name 'IConfigurationFile' from external module "/Users/andrew/.virtualenvs/tmp-d22ef013cf858b8/fork-ts-checker-webpack-plugin/node_modules/tslint/lib/configuration" but cannot be named.
src/IncrementalChecker.ts(107,10): error TS4050: Return type of public static method from exported class has or is using name 'Linter' from external module "/Users/andrew/.virtualenvs/tmp-d22ef013cf858b8/fork-ts-checker-webpack-plugin/node_modules/tslint/lib/linter" but cannot be named.
src/NormalizedMessage.ts(19,27): error TS4028: Public static property 'TYPE_DIAGNOSTIC' of exported class has or is using private name 'ErrorType'.
src/NormalizedMessage.ts(20,21): error TS4028: Public static property 'TYPE_LINT' of exported class has or is using private name 'ErrorType'.
src/NormalizedMessage.ts(23,26): error TS4028: Public static property 'SEVERITY_ERROR' of exported class has or is using private name 'Severity'.
src/NormalizedMessage.ts(24,28): error TS4028: Public static property 'SEVERITY_WARNING' of exported class has or is using private name 'Severity'.
src/NormalizedMessage.ts(26,9): error TS4031: Public property 'type' of exported class has or is using private name 'ErrorType'.
src/NormalizedMessage.ts(28,13): error TS4031: Public property 'severity' of exported class has or is using private name 'Severity'.
src/NormalizedMessage.ts(34,21): error TS4063: Parameter 'data' of constructor from exported class has or is using private name 'NormalizedMessageJson'.
src/NormalizedMessage.ts(74,31): error TS4070: Parameter 'json' of public static method from exported class has or is using private name 'NormalizedMessageJson'.
src/NormalizedMessage.ts(111,30): error TS4070: Parameter 'typeA' of public static method from exported class has or is using private name 'ErrorType'.
src/NormalizedMessage.ts(111,48): error TS4070: Parameter 'typeB' of public static method from exported class has or is using private name 'ErrorType'.
src/NormalizedMessage.ts(122,39): error TS4070: Parameter 'severityA' of public static method from exported class has or is using private name 'Severity'.
src/NormalizedMessage.ts(122,60): error TS4070: Parameter 'severityB' of public static method from exported class has or is using private name 'Severity'.
src/NormalizedMessage.ts(151,3): error TS4055: Return type of public method from exported class has or is using private name 'NormalizedMessageJson'.
src/index.ts(49,12): error TS4031: Public property 'options' of exported class has or is using private name 'Options'.
src/index.ts(63,14): error TS4031: Public property 'formatter' of exported class has or is using private name 'Formatter'.
src/index.ts(87,24): error TS4063: Parameter 'options' of constructor from exported class has or is using private name 'Options'.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Please note that these errors are show when running TSLint.

$ tslint --project src --type-check

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions