Typescript and ES6 import

1

I am trying to transpile a file with extension .ts to ES6 but it does not work and out of that nor does it throw me some typescript error. The problem occurs when I use the import of ES6 and do not require.

Note: I have updated node.

I appreciate your help.

    
asked by oscar leandro viera pereira 06.09.2016 в 05:38
source

2 answers

1

You must correctly define the tsconfig.json file, the one I use at this time to convert from TS 2.1 to JS.

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "strictNullChecks": true,
        "noEmitOnError": true
    },
    "exclude": [
        "node_modules"
    ]
}

Example of importing npm modules into a TS driver.

'use strict'

import * as path from 'path';
import * as fs from 'fs';
import { PaginateModel, Schema, model } from 'mongoose';
import * as mongoosePaginate from 'mongoose-paginate';
    
answered by 18.03.2017 в 04:18
0

Analyzing

Editing TypeScript

I can see some points

  • try defining a more basic tsconfig, remove for example the outDir
  • validate that you have the tasks.json
  • try generating the compile using Ctrl+Shift+B

When you say that nothing valid happens, the folder that you define in the outDir maybe there is where the generated .js leaves

    
answered by 06.09.2016 в 07:24