Ts-node: declare global interface doesn't work

Created on 5 Sep 2019  Â·  1Comment  Â·  Source: TypeStrong/ts-node

gobal definations:

// typs/global.d.ts
declare interface CtxBody {
  err_no: number;
  err_msg: string;
  data?: any;
}
app.ts
const ctxBody:CtxBody = {
}

```
D:\Node\node_modules\ts-nodesrc\index.ts:245
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
src/app.ts:19:7 - error TS2304: Cannot find name 'CtxBody'.

19 (ctx.body) = {
~~~
at createTSError (D:\Node\node_modules\ts-nodesrc\index.ts:245:12)
at reportTSError (D:\Node\node_modules\ts-nodesrc\index.ts:249:19)
at getOutput (D:\Node\node_modules\ts-nodesrc\index.ts:362:34)
at Object.compile (D:\Node\node_modules\ts-nodesrc\index.ts:395:32)
at Module.m._compile (D:\Node\node_modules\ts-nodesrc\index.ts:473:43)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Object.require.extensions.(anonymous function) [as .ts] (D:\Node\node_modules\ts-nodesrc\index.ts:476:12)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)

```json

{
  "compilerOptions": {
    "outDir": "dist",
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "es2017",
    "removeComments": true,
    "sourceMap": false,
    "watch": false,
    "baseUrl": "./src",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitAny": false,
    "skipLibCheck": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitUseStrict": true,
    "rootDir": "./src",
    "paths": {
      "*": ["node_modules/*", "src/types/*"]
    },
    "typeRoots": ["./node_modules/@types", "./src/types"],
    "types": ["node"]
  },
  "include": ["src/**/*"]
}


>All comments

There’s a section in the README for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cevek picture cevek  Â·  4Comments

Borewit picture Borewit  Â·  3Comments

conordickinson picture conordickinson  Â·  4Comments

OliverJAsh picture OliverJAsh  Â·  3Comments

mattdell picture mattdell  Â·  4Comments