Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Buffer got wrong value when "downlevelIteration":"true" in tsconfig.json #760

@JaosnHsieh

Description

@JaosnHsieh

Current Behavior

$ tsdx create -> basic

Node.js Buffer object with spread operator has wrong value.

Screen Shot 2020-07-16 at 4 49 48 PM

tsconfig.json

{
  "include": ["src", "types"],
  "compilerOptions": {
    "module": "esnext",
    "lib": ["dom", "esnext"],
    "importHelpers": true,
    "declaration": true,
    "sourceMap": true,
    "rootDir": "./src",
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "*": ["src/*", "node_modules/*"]
    },
    "jsx": "react",
    "esModuleInterop": true,
    "downlevelIteration": true
  }
}

Expected behavior

Got value Buffer <[1,2,3,4,5,6]>

Suggested solution(s)

might be rollup config. because below tsconfig.js without tsdx transpiled and got values correctly. so at least it should not be typescript bug.

I avoid using spread operator ... on Buffer. Switch to ...Buffer.from([1,2,3]).toJSON().data for now as workaround.

Screen Shot 2020-07-16 at 5 00 28 PM

below tsconfig.json with typescript Version 3.9.6 works

{
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "outDir": "dist",
    "lib": ["es2018", "esnext.asynciterable", "DOM"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "downlevelIteration": true
  }
}


Additional context

Your environment

Software Version(s)
TSDX 0.13.2 with tsdx create -> basic
TypeScript 3.9.6
Browser
npm/Yarn 1.22.4
Node v13.7.0
Operating System MacOS Catalina 10.15.5 (19F101)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions