Typescript: Allow declarations:true to work with checkJs

Created on 10 May 2017  ยท  3Comments  ยท  Source: microsoft/TypeScript



First of all, I bow down to the typescript gods for blessing us with checkJs. It has kept our children fed. However puny humans still pray for more. :godmode: ๐Ÿ™ ๐Ÿ™‡ ๐Ÿ™‡โ€โ™€๏ธ

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)
2.3

Code

/**
 * @param {string} str
 * @returns {string}
 */
export function snakecase(str) {
  return str.replace(/\_/g, `-`);
}
// A *self-contained* demonstration of the problem follows...
{
  "compilerOptions":{
    "checkJs": true,
    "declaration": true,
    "noEmit": true
  }
}

Expected behavior:
Running tsc on a project that uses js types should allow emitting a .d.ts like you would in a typescript project. This would allow projects to automatically emit typings for their project without having to maintain a separate .d.ts file that they need to keep in sync.

typings are documentation and if they are separate from code, they will eventually fall out of sync. Making this super easy to do with auto-generation will help a ton of javascript projects keep their typings up-to-date.

Actual behavior:
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.

Duplicate

Most helpful comment

๐Ÿ˜ข I did try searching to see if there was an existing issue. I suppose my github kungfu was not good enough. Feel free to close it as a dupe.

Github really needs a feature that searches previous issues for possible duplicates. I can imagine how much time you spend just marking issues as dupes.

All 3 comments

This is a duplicate of #7546 but I don't want to close this issue because I like it too much.

๐Ÿ˜ข I did try searching to see if there was an existing issue. I suppose my github kungfu was not good enough. Feel free to close it as a dupe.

Github really needs a feature that searches previous issues for possible duplicates. I can imagine how much time you spend just marking issues as dupes.

indeed a duplicate, closing in favor of #7546

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blendsdk picture blendsdk  ยท  3Comments

Antony-Jones picture Antony-Jones  ยท  3Comments

wmaurer picture wmaurer  ยท  3Comments

CyrusNajmabadi picture CyrusNajmabadi  ยท  3Comments

kyasbal-1994 picture kyasbal-1994  ยท  3Comments