typescript typings - Augment an interface to remove the indexer

In @types/node the NodeJS.ProcessEnv interface is declared with an indexer:interface ProcessEnv { [key: string]: string | undefined;}And I'm augmenting it with my defined properties:declare module NodeJS { interface ProcessEnv { NODE_ENV: 'development' | 'production'; }}It successfully type-checks the value of process.env.NODE_ENV, but it still allows any property. If I use the wrong property name (e.g. MODE_ENB), it doesn't produce an error, because of the indexer.Is there a way to apply module augmentation to an interface that...Read more

How can I use the type from TypeScript for flowtype in React Native

I use VSCode IDE to develop React Native apps. I found that the IDE provides type info from TypeScript, but I can't use it directly with flowtype.For example render = () => ( <WebView onNavigationStateChange={this.onNavigationStateChange} />)onNavigationStateChange = (navState: NavState) => { //...};The type NavState could be found in the index.d.ts provided by VSCode, but it can't be used in the flow.js.Can I use types from TypeScript files in my React Native project?If not, how can I know the correct types in React Native?...Read more

typescript2.0 - Saving npm @types typings with --save or --save-dev

TypeScript 2 recommends using npm for types. In The Future of Declaration Files.the example is:npm install --save @types/lodashMy question is whether --save-dev should be used in an application, because TypeScript is transpiled and not deployed? Some comments on the article mention similar, but there is no answer I could see.Perhaps --save is useful in a library to drag around the types when others install your library?Am I missing something else this is useful for and what is the best practice? Thanks....Read more

typescript2.0 - How to fix tsc throwing errors for node typings?

I have started a new node project using typescript.I installed typescript via:$ npm install typescript@2 -gMy enviornment looks like this:$ tsc -vVersion 2.0.0$ node -vv7.10.0I installed the typings for node via:npm install --save @types/nodeI would expect:tscto just run through without errors. Instead, I get errors in regards to the typings themselves:366 isTTY?: true; ~~~~node_modules/@types/node/index.d.ts(366,17): error TS1110: Type expected.1907 all?: false; ~~~~~node_modules/@types/node...Read more

typescript typings - How to update an older version of a type

I have a project that runs AngularJS 1.5.x, and it uses type declarations from DefinitelyTyped: @types/angular@1.5.23. This is the last 1.5.x version, and it was published 3 years ago. Since then, the package has moved on to version 1.6.x.The problem with 1.5.23 is its use of an any indexer on IScope, which has since been patched in version 1.6.27. But we can't exactly upgrade to 1.6.27, because we're not using angular 1.6.x — we're locked to 1.5.My question is: what are my options for dealing with this? Does DefinitelyTyped have a mechanism fo...Read more

Global and Ambient Dependencies - typings

I am really confused between the ambient and global dependencies. I understood the concept of global dependencies, which means that installing the dependencies globally. But coming to ambient dependencies, I did not understand what it is and now typings recently declared that ambient is now global. I am completely lost.Can someone please help me clear this confusion....Read more

Typings install won't install existing definitions

I have migrated from tsd to typings. And am in the process of converting my gulpfile.js to gulpfile.ts. Hence I would like to use type definitions for such things as 'gulp-rename', 'gulp-uglify' etc. In the case of 'gulp-uglify' it appears that the type definition exists: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/gulp-uglify/gulp-uglify.d.tsAnd if I run the command typings search gulp-uglify I get the following response: NAME SOURCE HOMEPAGE DESCRIPTION VERSIONS UPDATEDgulp-ugli...Read more

typescript2.0 - Declare interface in TypeScript .d.ts file and consume from JavaScript file

I'm using Visual Studio Code and would like to have intellisense hint when declaring my configuration variable as plain javascript objectjsconfig.json{ "compilerOptions": { "checkJs": true }, "include": [ "src/**/*.js", "types/**/*.d.ts" ], "exclude": [ "node_modules" ]}types/index.d.tsinterface Foo { a: string; b: number;}declare var fooConfig: Foo;src/app.jsconst fooConfig = { a: 'hello', b: 123}I expect when declaring using const fooConfig VS Code might offer intellisense about a and ...Read more

typescript typings - Type an untyped package with types from another package

Is it possible to re-export an existing typed module and use its types for an untyped module?I am importing a library react-final-form-html5-validation that is just a tiny wrapper around typed react-final-form.Are there any options for this?I have tried many many many things ......., but this looks most promising, however, react-final-form does not declare a namespace and so I cannot use its types like I can use the React below.project/index.d.ts/// <reference types="react-final-form" />//// <reference types="./node_modules/react-final...Read more

I want to create typings file for crypto-json js library

I want to import this crypto-json JavaScript library in typescript file.When I tried running this command "typings install dt~crypto-json --global --save" but got the below error typings ERR! system Windows_NT 10.0.14393 typings ERR! command "D:\Backup\EnvironmentVariables\node-v6.9.5-win-x64\node.exe" "D:\Backup\EnvironmentVariables\node-v6.9.5-win-x64\node_modules\typings\dist\bin.js" "install" "dt~crypto-json" "--save" "--global" typings ERR! node -v v6.9.5 typings ERR! typings -v 2.1.1 typings ERR! typings ERR! If you need help, you m...Read more