type-definition

TypeScript: Specify a directory to look for module type definitions

不想你离开。 提交于 2021-01-20 19:18:47
问题 Heyho, I want to use some javascript libraries in my typescript code for which there are no typings in npm. So I wrote the typings myself and put them in a definitions directory in my source tree. However, I could not get typescript to look in that directory for those modules. My directory structure looks like this: +-node_modules | | | +-moduleA | | | +-moduleB | +-src | | | +-definitions | | | | | +-moduleA.d.ts | | | | | +-moduleB.d.ts | | | +-ts | | | + ... all typescript code ... | +

TypeScript: Specify a directory to look for module type definitions

依然范特西╮ 提交于 2021-01-20 19:11:10
问题 Heyho, I want to use some javascript libraries in my typescript code for which there are no typings in npm. So I wrote the typings myself and put them in a definitions directory in my source tree. However, I could not get typescript to look in that directory for those modules. My directory structure looks like this: +-node_modules | | | +-moduleA | | | +-moduleB | +-src | | | +-definitions | | | | | +-moduleA.d.ts | | | | | +-moduleB.d.ts | | | +-ts | | | + ... all typescript code ... | +

TypeScript: Specify a directory to look for module type definitions

夙愿已清 提交于 2021-01-20 19:08:21
问题 Heyho, I want to use some javascript libraries in my typescript code for which there are no typings in npm. So I wrote the typings myself and put them in a definitions directory in my source tree. However, I could not get typescript to look in that directory for those modules. My directory structure looks like this: +-node_modules | | | +-moduleA | | | +-moduleB | +-src | | | +-definitions | | | | | +-moduleA.d.ts | | | | | +-moduleB.d.ts | | | +-ts | | | + ... all typescript code ... | +

TypeScript: Specify a directory to look for module type definitions

橙三吉。 提交于 2021-01-20 19:07:46
问题 Heyho, I want to use some javascript libraries in my typescript code for which there are no typings in npm. So I wrote the typings myself and put them in a definitions directory in my source tree. However, I could not get typescript to look in that directory for those modules. My directory structure looks like this: +-node_modules | | | +-moduleA | | | +-moduleB | +-src | | | +-definitions | | | | | +-moduleA.d.ts | | | | | +-moduleB.d.ts | | | +-ts | | | + ... all typescript code ... | +

Bootstrap 4 TypeScript Type Definition fails to compile - Cannot find module 'popper.js'

﹥>﹥吖頭↗ 提交于 2020-12-29 03:08:08
问题 I am attempting to set up a TypeScript project and get bootstrap 4 working along with Popper , jQuery , and Knockout in Visual Studio Code. I installed the knockout, jquery and bootstrap type definitions, npm install -–save @types/knockout npm install -–save @types/jquery npm install --save @types/bootstrap referenced the JS files in a require.js config declare var require: any; require.config({ paths: { "knockout": "externals/knockout-3.5.0", "jquery": "externals/jquery-3.3.1.min", "popper

Bootstrap 4 TypeScript Type Definition fails to compile - Cannot find module 'popper.js'

萝らか妹 提交于 2020-12-29 03:07:57
问题 I am attempting to set up a TypeScript project and get bootstrap 4 working along with Popper , jQuery , and Knockout in Visual Studio Code. I installed the knockout, jquery and bootstrap type definitions, npm install -–save @types/knockout npm install -–save @types/jquery npm install --save @types/bootstrap referenced the JS files in a require.js config declare var require: any; require.config({ paths: { "knockout": "externals/knockout-3.5.0", "jquery": "externals/jquery-3.3.1.min", "popper

How do I write the type definition for a module with a default export

╄→гoц情女王★ 提交于 2020-08-08 05:58:28
问题 I want to write a type definition for storybook-router. It needn't be that accurate, since this is a minor development tool (i.e. any s are acceptable), but I can't even seem to get that to work. What I want to represent is: import StoryRouter from 'storybook-router'; ...in which StoryRouter is a function that matches the interface StoryDecorator from @types/storybook__react . I tried the following definition file: import { StoryDecorator } from '@storybook/react'; declare type StoryRouter =

Define a type for an object where all values have the same type

寵の児 提交于 2020-06-26 12:09:34
问题 I'm trying to define a type for an object, such that every value of the object has the same type, and must have the same keys. I'd like to be able to do this where every value has the same keys, defined as the union of the types of all the values. const test = { a: { // I'd like to see a type error on this line x: 1, }, b: { x: 1, y: 2, }, } It's possible when you define the type in advance: interface IA { [key: string]: { x: number; y: number; } } const test: IA = { a: { // now we get a type

How do I create a TypeScript type definition for a stateless React component?

一曲冷凌霜 提交于 2020-06-24 07:16:21
问题 I'm trying create type definitions for an existing suite of stateless React components, so I can generate documentation automagically and to improve intellisense in my team's tooling. An example component could look like this: myComponent.js import React from 'react'; export const MyComponent = ({ prop1, prop2, prop3 }) => ( <div> { prop1 ? prop2 : prop3 } </div> ); I would like my type definition to: Define which props are allowed (and which are required) That it will return JSX Looking at

Length-parameterized passed object to type-bound procedure has gfortran complain

心不动则不痛 提交于 2020-05-09 03:18:28
问题 I'm learning Fortran and I'd like to encapsulate an array and a subroutine in a type. The problem appears to be in the type definition of the self-object. This is the minimal test case I came up with: module testing implicit none type test(para) integer, len :: para real, dimension(para) :: weights contains procedure :: testing => testing_test end type contains subroutine testing_test(self) class(test(*)) :: self end subroutine end module Compiling this with gfortran raises this error: module